htmlemmurt 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/index.d.ts +5 -0
- package/index.js +1 -1
- package/lib/api.js +6 -1
- package/package.json +1 -1
- package/wasm/node/emmurt_wasm_bg.wasm +0 -0
- package/wasm/web/emmurt_wasm_bg.wasm +0 -0
- package/web.d.ts +2 -0
- package/web.js +1 -0
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ const { html, dependencies, errors } = compile('<cascett classe="a">Uè</cascett
|
|
|
19
19
|
|
|
20
20
|
`compile` non lancia mai eccezioni: gli errori stanno in `errors`, con `message`, `file`, `line`, `column` e `suggestion`, in napoletano. Le opzioni sono `filename`, `root` (la cartella per i percorsi che cominciano con `/`), `read` (per leggere i file in un altro modo) e `inline` (incolla nella pagina i file di `<fratm da>`). I moduli `.fratm` li compila il pacchetto [`fratmscript`](https://www.npmjs.com/package/fratmscript).
|
|
21
21
|
|
|
22
|
+
`format(source)` restituisce la pagina come la scrive `emmurt fmt`, cambiando solo spazi e a capo, oppure `null` se la pagina ha errori (li dice `compile`).
|
|
23
|
+
|
|
22
24
|
## Con Vite
|
|
23
25
|
|
|
24
26
|
```js
|
package/index.d.ts
CHANGED
|
@@ -48,6 +48,11 @@ export interface Vocabulary {
|
|
|
48
48
|
|
|
49
49
|
/** Compiles htmlemmurt to HTML. Never throws on invalid source: check `errors`. */
|
|
50
50
|
export function compile(source: string, options?: CompileOptions): CompileResult;
|
|
51
|
+
/**
|
|
52
|
+
* The page as `emmurt fmt` writes it: only spaces and line breaks change.
|
|
53
|
+
* Null when it has errors, which `compile` reports.
|
|
54
|
+
*/
|
|
55
|
+
export function format(source: string): string | null;
|
|
51
56
|
/** Every Neapolitan name and its HTML. */
|
|
52
57
|
export function vocabulary(): Vocabulary;
|
|
53
58
|
/** Version of the compiler. */
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createApi } from './lib/api.js';
|
|
|
7
7
|
const wasm = createRequire(import.meta.url)('./wasm/node/emmurt_wasm.js');
|
|
8
8
|
const api = createApi(wasm);
|
|
9
9
|
|
|
10
|
-
export const { vocabulary, version, runtimeError } = api;
|
|
10
|
+
export const { format, vocabulary, version, runtimeError } = api;
|
|
11
11
|
export { formatError } from './lib/api.js';
|
|
12
12
|
|
|
13
13
|
/**
|
package/lib/api.js
CHANGED
|
@@ -9,6 +9,11 @@ export function createApi(wasm) {
|
|
|
9
9
|
return { html: response.html, dependencies: response.dependencies, errors: response.errors };
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// Undefined from the bindings when the page cannot be formatted
|
|
13
|
+
function format(source) {
|
|
14
|
+
return wasm.format(String(source)) ?? null;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
function vocabulary() {
|
|
13
18
|
return JSON.parse(wasm.vocabulary());
|
|
14
19
|
}
|
|
@@ -19,7 +24,7 @@ export function createApi(wasm) {
|
|
|
19
24
|
return wasm.runtimeError(name, message);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
return { compile, vocabulary, version: wasm.version, runtimeError };
|
|
27
|
+
return { compile, format, vocabulary, version: wasm.version, runtimeError };
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
/** `file:line:column: message`, then the hint on its own line. */
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
package/web.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { CompileOptions, CompileResult, Vocabulary, EmmurtError } from './i
|
|
|
5
5
|
export function init(input?: string | URL | Request | Response | BufferSource | WebAssembly.Module): Promise<void>;
|
|
6
6
|
/** Compiles htmlemmurt to HTML. Without `read`, includes cannot be resolved. */
|
|
7
7
|
export function compile(source: string, options?: Omit<CompileOptions, 'root'>): CompileResult;
|
|
8
|
+
/** The page as `emmurt fmt` writes it, or null when it has errors: `compile` says which. */
|
|
9
|
+
export function format(source: string): string | null;
|
|
8
10
|
export function vocabulary(): Vocabulary;
|
|
9
11
|
export function version(): string;
|
|
10
12
|
export function runtimeError(error: unknown): string;
|
package/web.js
CHANGED
|
@@ -19,6 +19,7 @@ function loadedApi() {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export const compile = (source, options) => loadedApi().compile(source, options);
|
|
22
|
+
export const format = (source) => loadedApi().format(source);
|
|
22
23
|
export const vocabulary = () => loadedApi().vocabulary();
|
|
23
24
|
export const version = () => loadedApi().version();
|
|
24
25
|
export const runtimeError = (error) => loadedApi().runtimeError(error);
|