@driftsys/markspec 0.10.2 → 0.10.3
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/esm/decl/mod.d.ts +18 -0
- package/esm/decl/mod.d.ts.map +1 -0
- package/esm/decl/mod.js +14 -0
- package/esm/decl/resolve.d.ts +104 -0
- package/esm/decl/resolve.d.ts.map +1 -0
- package/esm/decl/resolve.js +66 -0
- package/esm/decl/surfaces.d.ts +96 -0
- package/esm/decl/surfaces.d.ts.map +1 -0
- package/esm/decl/surfaces.js +122 -0
- package/esm/decl/table.d.ts +50 -0
- package/esm/decl/table.d.ts.map +1 -0
- package/esm/decl/table.js +124 -0
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/parser/directives.d.ts +6 -0
- package/esm/parser/directives.d.ts.map +1 -1
- package/esm/parser/directives.js +17 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +9 -0
- package/esm/typl/bullet.d.ts +13 -23
- package/esm/typl/bullet.d.ts.map +1 -1
- package/esm/typl/bullet.js +6 -40
- package/esm/typl/fence.d.ts +12 -21
- package/esm/typl/fence.d.ts.map +1 -1
- package/esm/typl/fence.js +5 -20
- package/esm/typl/inline.d.ts +15 -24
- package/esm/typl/inline.d.ts.map +1 -1
- package/esm/typl/inline.js +6 -44
- package/esm/typl/recognize.d.ts +14 -0
- package/esm/typl/recognize.d.ts.map +1 -0
- package/esm/typl/recognize.js +19 -0
- package/esm/validator/body_blocks.d.ts.map +1 -1
- package/esm/validator/body_blocks.js +3 -9
- package/package.json +1 -1
- package/script/decl/mod.d.ts +18 -0
- package/script/decl/mod.d.ts.map +1 -0
- package/script/decl/mod.js +24 -0
- package/script/decl/resolve.d.ts +104 -0
- package/script/decl/resolve.d.ts.map +1 -0
- package/script/decl/resolve.js +70 -0
- package/script/decl/surfaces.d.ts +96 -0
- package/script/decl/surfaces.d.ts.map +1 -0
- package/script/decl/surfaces.js +128 -0
- package/script/decl/table.d.ts +50 -0
- package/script/decl/table.d.ts.map +1 -0
- package/script/decl/table.js +127 -0
- package/script/mod.d.ts +1 -1
- package/script/mod.js +1 -1
- package/script/parser/directives.d.ts +6 -0
- package/script/parser/directives.d.ts.map +1 -1
- package/script/parser/directives.js +18 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +9 -0
- package/script/typl/bullet.d.ts +13 -23
- package/script/typl/bullet.d.ts.map +1 -1
- package/script/typl/bullet.js +6 -40
- package/script/typl/fence.d.ts +12 -21
- package/script/typl/fence.d.ts.map +1 -1
- package/script/typl/fence.js +5 -20
- package/script/typl/inline.d.ts +15 -24
- package/script/typl/inline.d.ts.map +1 -1
- package/script/typl/inline.js +6 -44
- package/script/typl/recognize.d.ts +14 -0
- package/script/typl/recognize.d.ts.map +1 -0
- package/script/typl/recognize.js +22 -0
- package/script/validator/body_blocks.d.ts.map +1 -1
- package/script/validator/body_blocks.js +3 -9
package/script/typl/bullet.js
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractTyplBullets = extractTyplBullets;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
/** Matches a typl typedef bullet (paragraph text). */
|
|
7
|
-
const BULLET_TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
|
|
8
|
-
function isTyplBulletText(text) {
|
|
9
|
-
return BULLET_BINDING_RE.test(text) || BULLET_TYPEDEF_RE.test(text);
|
|
10
|
-
}
|
|
4
|
+
const mod_js_1 = require("../decl/mod.js");
|
|
5
|
+
const recognize_js_1 = require("./recognize.js");
|
|
11
6
|
/**
|
|
12
|
-
* Walk a body AST and return every bullet-list item whose first
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* list are picked up).
|
|
16
|
-
*
|
|
17
|
-
* Returns matches in source order (depth-first).
|
|
7
|
+
* Walk a body AST and return every bullet-list item whose first paragraph
|
|
8
|
+
* is a typl declaration, in source order (depth-first, recursing into
|
|
9
|
+
* nested lists). Delegates traversal to {@linkcode extractBulletDeclarations}.
|
|
18
10
|
*/
|
|
19
11
|
function extractTyplBullets(blocks) {
|
|
20
|
-
|
|
21
|
-
for (const block of blocks) {
|
|
22
|
-
if (block.kind === "list") {
|
|
23
|
-
for (const item of block.items) {
|
|
24
|
-
if (item.blocks.length === 0)
|
|
25
|
-
continue;
|
|
26
|
-
const first = item.blocks[0];
|
|
27
|
-
if (first.kind === "paragraph") {
|
|
28
|
-
const para = first;
|
|
29
|
-
if (isTyplBulletText(para.content.text)) {
|
|
30
|
-
results.push({
|
|
31
|
-
source: para.content.text,
|
|
32
|
-
range: para.range,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// Recurse into nested blocks (the item may itself contain a list)
|
|
37
|
-
if (item.blocks.length > 1) {
|
|
38
|
-
results.push(...extractTyplBullets(item.blocks.slice(1)));
|
|
39
|
-
}
|
|
40
|
-
else if (first.kind === "list") {
|
|
41
|
-
results.push(...extractTyplBullets([first]));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return results;
|
|
12
|
+
return (0, mod_js_1.extractBulletDeclarations)(blocks, recognize_js_1.isTyplDeclarationText);
|
|
47
13
|
}
|
package/script/typl/fence.d.ts
CHANGED
|
@@ -2,30 +2,21 @@
|
|
|
2
2
|
* @module typl/fence
|
|
3
3
|
*
|
|
4
4
|
* Fence surface adapter — extracts typl source from fenced code blocks
|
|
5
|
-
* whose info-string is "typl".
|
|
6
|
-
* (
|
|
5
|
+
* whose info-string is "typl". A thin wrapper over the shared
|
|
6
|
+
* declaration-surface machinery (core/decl): it supplies typl's fence
|
|
7
|
+
* recognizer and re-exports the common declaration node as
|
|
8
|
+
* {@linkcode TyplFenceExtraction}.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
* its source range. PR 3 will wire the extracted source through
|
|
10
|
-
* parseTyplBlock and attach results to Entry.types.
|
|
10
|
+
* See ADR-019.
|
|
11
11
|
*/
|
|
12
|
-
import type { BodyBlock
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly source: string;
|
|
17
|
-
/** Source range of the whole fence (opening ``` through closing ```). */
|
|
18
|
-
readonly range: SourceRange;
|
|
19
|
-
}
|
|
12
|
+
import type { BodyBlock } from "../ast/nodes.js";
|
|
13
|
+
import { type BlockDeclaration } from "../decl/mod.js";
|
|
14
|
+
/** A single typl fence found inside a body: `{ source, range }`. */
|
|
15
|
+
export type TyplFenceExtraction = BlockDeclaration;
|
|
20
16
|
/**
|
|
21
|
-
* Walk a body AST and return every typl fence found
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* BlockquoteNode and NoteNode carry only InlineContent (not nested
|
|
26
|
-
* BodyBlock[]), so they are not recursed into.
|
|
27
|
-
*
|
|
28
|
-
* Returns fences in source order (depth-first traversal).
|
|
17
|
+
* Walk a body AST and return every typl fence (```typl) found, in source
|
|
18
|
+
* order (depth-first, recursing into list items). Delegates traversal to
|
|
19
|
+
* {@linkcode extractFenceDeclarations}.
|
|
29
20
|
*/
|
|
30
21
|
export declare function extractTyplFences(blocks: readonly BodyBlock[]): readonly TyplFenceExtraction[];
|
|
31
22
|
//# sourceMappingURL=fence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/typl/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/typl/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAC;AAExB,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,mBAAmB,EAAE,CAEhC"}
|
package/script/typl/fence.js
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractTyplFences = extractTyplFences;
|
|
4
|
+
const mod_js_1 = require("../decl/mod.js");
|
|
4
5
|
/**
|
|
5
|
-
* Walk a body AST and return every typl fence found
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* BlockquoteNode and NoteNode carry only InlineContent (not nested
|
|
10
|
-
* BodyBlock[]), so they are not recursed into.
|
|
11
|
-
*
|
|
12
|
-
* Returns fences in source order (depth-first traversal).
|
|
6
|
+
* Walk a body AST and return every typl fence (```typl) found, in source
|
|
7
|
+
* order (depth-first, recursing into list items). Delegates traversal to
|
|
8
|
+
* {@linkcode extractFenceDeclarations}.
|
|
13
9
|
*/
|
|
14
10
|
function extractTyplFences(blocks) {
|
|
15
|
-
|
|
16
|
-
for (const block of blocks) {
|
|
17
|
-
if (block.kind === "code" && block.lang === "typl") {
|
|
18
|
-
results.push({ source: block.text, range: block.range });
|
|
19
|
-
}
|
|
20
|
-
else if (block.kind === "list") {
|
|
21
|
-
for (const item of block.items) {
|
|
22
|
-
results.push(...extractTyplFences(item.blocks));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return results;
|
|
11
|
+
return (0, mod_js_1.extractFenceDeclarations)(blocks, (lang) => lang === "typl");
|
|
27
12
|
}
|
package/script/typl/inline.d.ts
CHANGED
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module typl/inline
|
|
3
3
|
*
|
|
4
|
-
* Inline backtick surface adapter — recognises typl declarations
|
|
5
|
-
*
|
|
6
|
-
* scattered through entry prose.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
4
|
+
* Inline backtick surface adapter — recognises typl declarations wrapped
|
|
5
|
+
* in CommonMark code spans, e.g. `` `$X : signal float[0..300]` ``
|
|
6
|
+
* scattered through entry prose. A thin wrapper over the shared
|
|
7
|
+
* declaration-surface machinery (core/decl): it supplies typl's text
|
|
8
|
+
* recognizer and re-exports the common declaration node as
|
|
9
|
+
* {@linkcode TyplInlineExtraction}. The shared machinery strips the
|
|
10
|
+
* backtick delimiters `Entry.bodyTokens` (ADR-016) records before
|
|
11
|
+
* recognizing, so `source` is the raw typl text.
|
|
12
12
|
*
|
|
13
13
|
* See ADR-019.
|
|
14
14
|
*/
|
|
15
|
-
import type { BodyToken
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
readonly source: string;
|
|
20
|
-
/** File-relative location of the code span. */
|
|
21
|
-
readonly location: SourceLocation;
|
|
22
|
-
}
|
|
15
|
+
import type { BodyToken } from "../model/mod.js";
|
|
16
|
+
import { type InlineDeclaration } from "../decl/mod.js";
|
|
17
|
+
/** A single typl inline-code declaration: `{ source, location }`. */
|
|
18
|
+
export type TyplInlineExtraction = InlineDeclaration;
|
|
23
19
|
/**
|
|
24
|
-
* Filter bodyTokens to inline-code spans whose contents
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* `inline-code` tokens in `bodyTokens` store their `text` field with
|
|
29
|
-
* surrounding backtick delimiters (e.g., `` `$X : signal` ``). This
|
|
30
|
-
* function strips those delimiters before pattern-matching and before
|
|
31
|
-
* setting `source`, so `parseTyplBlock` receives the raw typl source.
|
|
20
|
+
* Filter `Entry.bodyTokens` to inline-code spans whose contents are typl
|
|
21
|
+
* declarations, in source order. Delegates to
|
|
22
|
+
* {@linkcode extractInlineDeclarations}.
|
|
32
23
|
*/
|
|
33
24
|
export declare function extractTyplInlines(bodyTokens: readonly BodyToken[]): readonly TyplInlineExtraction[];
|
|
34
25
|
//# sourceMappingURL=inline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/typl/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/typl/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAGxB,qEAAqE;AACrE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,SAAS,oBAAoB,EAAE,CAEjC"}
|
package/script/typl/inline.js
CHANGED
|
@@ -1,51 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractTyplInlines = extractTyplInlines;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
/** Matches a typl typedef span (code-span text). */
|
|
7
|
-
const INLINE_TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
|
|
8
|
-
function isTyplInlineText(text) {
|
|
9
|
-
return INLINE_BINDING_RE.test(text) || INLINE_TYPEDEF_RE.test(text);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Strip the surrounding backtick delimiter(s) from an inline-code token's
|
|
13
|
-
* `text` field. `body_tokens.ts` stores inline-code text as `` `value` ``
|
|
14
|
-
* (with backtick delimiters). The typl patterns and `parseTyplBlock` need
|
|
15
|
-
* the inner value only.
|
|
16
|
-
*
|
|
17
|
-
* Handles both single-backtick (`` `…` ``) and double-backtick (` ``…`` `)
|
|
18
|
-
* delimiters. Returns the original string unchanged when it does not start
|
|
19
|
-
* and end with a matching backtick fence.
|
|
20
|
-
*/
|
|
21
|
-
function stripBackticks(text) {
|
|
22
|
-
if (text.startsWith("``") && text.endsWith("``") && text.length > 4) {
|
|
23
|
-
return text.slice(2, -2);
|
|
24
|
-
}
|
|
25
|
-
if (text.startsWith("`") && text.endsWith("`") && text.length > 2) {
|
|
26
|
-
return text.slice(1, -1);
|
|
27
|
-
}
|
|
28
|
-
return text;
|
|
29
|
-
}
|
|
4
|
+
const mod_js_1 = require("../decl/mod.js");
|
|
5
|
+
const recognize_js_1 = require("./recognize.js");
|
|
30
6
|
/**
|
|
31
|
-
* Filter bodyTokens to inline-code spans whose contents
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* `inline-code` tokens in `bodyTokens` store their `text` field with
|
|
36
|
-
* surrounding backtick delimiters (e.g., `` `$X : signal` ``). This
|
|
37
|
-
* function strips those delimiters before pattern-matching and before
|
|
38
|
-
* setting `source`, so `parseTyplBlock` receives the raw typl source.
|
|
7
|
+
* Filter `Entry.bodyTokens` to inline-code spans whose contents are typl
|
|
8
|
+
* declarations, in source order. Delegates to
|
|
9
|
+
* {@linkcode extractInlineDeclarations}.
|
|
39
10
|
*/
|
|
40
11
|
function extractTyplInlines(bodyTokens) {
|
|
41
|
-
|
|
42
|
-
for (const token of bodyTokens) {
|
|
43
|
-
if (token.kind !== "inline-code")
|
|
44
|
-
continue;
|
|
45
|
-
const inner = stripBackticks(token.text);
|
|
46
|
-
if (!isTyplInlineText(inner))
|
|
47
|
-
continue;
|
|
48
|
-
results.push({ source: inner, location: token.location });
|
|
49
|
-
}
|
|
50
|
-
return results;
|
|
12
|
+
return (0, mod_js_1.extractInlineDeclarations)(bodyTokens, recognize_js_1.isTyplDeclarationText);
|
|
51
13
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module typl/recognize
|
|
3
|
+
*
|
|
4
|
+
* typl declaration recognizer — the DSL-specific predicate the shared
|
|
5
|
+
* declaration-surface machinery (core/decl) is parameterized by. A typl
|
|
6
|
+
* declaration is a binding (`$Name : …`) or a typedef (`type Name = …`).
|
|
7
|
+
* The bullet and inline surfaces share this text recognizer; the fence
|
|
8
|
+
* surface is recognized by its `typl` info-string (see fence.ts).
|
|
9
|
+
*
|
|
10
|
+
* See ADR-019.
|
|
11
|
+
*/
|
|
12
|
+
/** True when `text` begins a typl binding or typedef declaration. */
|
|
13
|
+
export declare function isTyplDeclarationText(text: string): boolean;
|
|
14
|
+
//# sourceMappingURL=recognize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recognize.d.ts","sourceRoot":"","sources":["../../src/typl/recognize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,qEAAqE;AACrE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module typl/recognize
|
|
4
|
+
*
|
|
5
|
+
* typl declaration recognizer — the DSL-specific predicate the shared
|
|
6
|
+
* declaration-surface machinery (core/decl) is parameterized by. A typl
|
|
7
|
+
* declaration is a binding (`$Name : …`) or a typedef (`type Name = …`).
|
|
8
|
+
* The bullet and inline surfaces share this text recognizer; the fence
|
|
9
|
+
* surface is recognized by its `typl` info-string (see fence.ts).
|
|
10
|
+
*
|
|
11
|
+
* See ADR-019.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.isTyplDeclarationText = isTyplDeclarationText;
|
|
15
|
+
/** Matches a typl binding: `$Name :`. */
|
|
16
|
+
const BINDING_RE = /^\$[A-Za-z_][A-Za-z0-9_]*\s*:/;
|
|
17
|
+
/** Matches a typl typedef: `type Name =`. */
|
|
18
|
+
const TYPEDEF_RE = /^type\s+[A-Za-z_][A-Za-z0-9_]*\s*=/;
|
|
19
|
+
/** True when `text` begins a typl binding or typedef declaration. */
|
|
20
|
+
function isTyplDeclarationText(text) {
|
|
21
|
+
return BINDING_RE.test(text) || TYPEDEF_RE.test(text);
|
|
22
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body_blocks.d.ts","sourceRoot":"","sources":["../../src/validator/body_blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"body_blocks.d.ts","sourceRoot":"","sources":["../../src/validator/body_blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AA2LzD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,UAAU,EAAE,CAsBtE"}
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.validateBodyBlocks = validateBodyBlocks;
|
|
33
|
+
const directives_js_1 = require("../parser/directives.js");
|
|
33
34
|
/**
|
|
34
35
|
* HTML tag detection. Matches an opening, closing, or self-closing tag
|
|
35
36
|
* (`<tag>`, `</tag>`, `<tag/>`). Doesn't match HTML comments — those
|
|
@@ -40,13 +41,6 @@ exports.validateBodyBlocks = validateBodyBlocks;
|
|
|
40
41
|
const HTML_TAG_RE = /<\/?[A-Za-z][A-Za-z0-9]*(\s[^>]*)?\/?>/;
|
|
41
42
|
/** Any HTML comment, `<!--…-->`. */
|
|
42
43
|
const HTML_COMMENT_RE = /<!--[\s\S]*?-->/;
|
|
43
|
-
/**
|
|
44
|
-
* A whole-line markspec directive comment: `<!-- markspec:<rest> -->`
|
|
45
|
-
* occupying the line on its own (optional leading/trailing
|
|
46
|
-
* whitespace). The directive form is the one exception spec §2.4.1
|
|
47
|
-
* carves out from the "no raw HTML" rule.
|
|
48
|
-
*/
|
|
49
|
-
const MARKSPEC_DIRECTIVE_LINE_RE = /^\s*<!--\s*markspec:[\s\S]*?-->\s*$/;
|
|
50
44
|
/**
|
|
51
45
|
* Return `true` when `line` contains raw HTML the body model forbids:
|
|
52
46
|
* any tag, or any comment that isn't a standalone markspec directive.
|
|
@@ -54,7 +48,7 @@ const MARKSPEC_DIRECTIVE_LINE_RE = /^\s*<!--\s*markspec:[\s\S]*?-->\s*$/;
|
|
|
54
48
|
function hasForbiddenHtml(line) {
|
|
55
49
|
if (HTML_TAG_RE.test(line))
|
|
56
50
|
return true;
|
|
57
|
-
if (HTML_COMMENT_RE.test(line) && !
|
|
51
|
+
if (HTML_COMMENT_RE.test(line) && !(0, directives_js_1.isMarkspecDirectiveComment)(line)) {
|
|
58
52
|
return true;
|
|
59
53
|
}
|
|
60
54
|
return false;
|
|
@@ -126,7 +120,7 @@ function violationsFromBlock(block) {
|
|
|
126
120
|
else if (block.subkind === "html") {
|
|
127
121
|
// Block-level HTML: check if it is a markspec directive (exempt)
|
|
128
122
|
// or forbidden HTML. The `raw` field carries the verbatim source.
|
|
129
|
-
if (!
|
|
123
|
+
if (!(0, directives_js_1.isMarkspecDirectiveComment)(block.raw)) {
|
|
130
124
|
out.push({ diag: RAW_HTML_DIAG, bodyLine });
|
|
131
125
|
}
|
|
132
126
|
}
|