@elastic/isomer-sdk 0.2.0 → 0.3.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/NOTICE.txt +0 -286
- package/THIRD_PARTY_LICENSES.md +1 -885
- package/dist/author/authored_fields.d.ts +37 -12
- package/dist/author/authored_fields.d.ts.map +1 -1
- package/dist/author/authored_fields.js +45 -69
- package/dist/author/authored_fields.js.map +1 -1
- package/dist/author/authoring_input.d.ts.map +1 -1
- package/dist/author/authoring_input.js +12 -6
- package/dist/author/authoring_input.js.map +1 -1
- package/dist/author/authoring_model.d.ts +8 -2
- package/dist/author/authoring_model.d.ts.map +1 -1
- package/dist/author/authoring_model.js +67 -23
- package/dist/author/authoring_model.js.map +1 -1
- package/dist/author/declarations.d.ts.map +1 -1
- package/dist/author/declarations.js +45 -34
- package/dist/author/declarations.js.map +1 -1
- package/dist/author/index.d.ts +2 -1
- package/dist/author/index.d.ts.map +1 -1
- package/dist/author/index.js +2 -1
- package/dist/author/index.js.map +1 -1
- package/dist/author/jsx_shim.d.ts +49 -30
- package/dist/author/jsx_shim.d.ts.map +1 -1
- package/dist/author/jsx_shim.js +131 -40
- package/dist/author/jsx_shim.js.map +1 -1
- package/dist/author/print_jsx.d.ts +19 -0
- package/dist/author/print_jsx.d.ts.map +1 -0
- package/dist/author/print_jsx.js +372 -0
- package/dist/author/print_jsx.js.map +1 -0
- package/dist/author/prompt.d.ts +2 -2
- package/dist/author/prompt.d.ts.map +1 -1
- package/dist/author/prompt.js +7 -2
- package/dist/author/prompt.js.map +1 -1
- package/dist/author/schema_to_typescript.d.ts.map +1 -1
- package/dist/author/schema_to_typescript.js +6 -3
- package/dist/author/schema_to_typescript.js.map +1 -1
- package/dist/cjs/author/authored_fields.js +47 -70
- package/dist/cjs/author/authored_fields.js.map +1 -1
- package/dist/cjs/author/authoring_input.js +12 -6
- package/dist/cjs/author/authoring_input.js.map +1 -1
- package/dist/cjs/author/authoring_model.js +69 -24
- package/dist/cjs/author/authoring_model.js.map +1 -1
- package/dist/cjs/author/declarations.js +44 -33
- package/dist/cjs/author/declarations.js.map +1 -1
- package/dist/cjs/author/index.js +5 -1
- package/dist/cjs/author/index.js.map +1 -1
- package/dist/cjs/author/jsx_shim.js +130 -39
- package/dist/cjs/author/jsx_shim.js.map +1 -1
- package/dist/cjs/author/print_jsx.js +378 -0
- package/dist/cjs/author/print_jsx.js.map +1 -0
- package/dist/cjs/author/prompt.js +7 -2
- package/dist/cjs/author/prompt.js.map +1 -1
- package/dist/cjs/author/schema_to_typescript.js +6 -3
- package/dist/cjs/author/schema_to_typescript.js.map +1 -1
- package/dist/cjs/composition/error.js +1 -0
- package/dist/cjs/composition/error.js.map +1 -1
- package/dist/cjs/composition/structured_value.js.map +1 -1
- package/dist/cjs/define/primitive_module.js +10 -4
- package/dist/cjs/define/primitive_module.js.map +1 -1
- package/dist/cjs/entries/index.js +3 -2
- package/dist/cjs/entries/index.js.map +1 -1
- package/dist/cjs/entries/markdown.js +2 -1
- package/dist/cjs/entries/markdown.js.map +1 -1
- package/dist/cjs/pack/index.js +2 -1
- package/dist/cjs/pack/index.js.map +1 -1
- package/dist/cjs/pack/primitive_pack.js +14 -4
- package/dist/cjs/pack/primitive_pack.js.map +1 -1
- package/dist/cjs/render/format_number.js +2 -1
- package/dist/cjs/render/format_number.js.map +1 -1
- package/dist/cjs/render/html/envelope.js +12 -6
- package/dist/cjs/render/html/envelope.js.map +1 -1
- package/dist/cjs/render/markdown/builder.js +6 -2
- package/dist/cjs/render/markdown/builder.js.map +1 -1
- package/dist/cjs/render/markdown/format.js +46 -24
- package/dist/cjs/render/markdown/format.js.map +1 -1
- package/dist/cjs/render/markdown/host_tags.js +67 -0
- package/dist/cjs/render/markdown/host_tags.js.map +1 -0
- package/dist/cjs/render/markdown/index.js +3 -1
- package/dist/cjs/render/markdown/index.js.map +1 -1
- package/dist/cjs/render/markdown/split.js +325 -0
- package/dist/cjs/render/markdown/split.js.map +1 -0
- package/dist/cjs/render/react/content.js +3 -1
- package/dist/cjs/render/react/content.js.map +1 -1
- package/dist/cjs/render/slack/markdown_content.js +7 -1
- package/dist/cjs/render/slack/markdown_content.js.map +1 -1
- package/dist/cjs/validate/json_schema.js +10 -3
- package/dist/cjs/validate/json_schema.js.map +1 -1
- package/dist/cjs/validate/url.js +2 -1
- package/dist/cjs/validate/url.js.map +1 -1
- package/dist/composition/error.d.ts +1 -0
- package/dist/composition/error.d.ts.map +1 -1
- package/dist/composition/error.js +1 -0
- package/dist/composition/error.js.map +1 -1
- package/dist/composition/structured_value.d.ts +3 -3
- package/dist/composition/structured_value.d.ts.map +1 -1
- package/dist/composition/structured_value.js.map +1 -1
- package/dist/define/primitive_module.d.ts +7 -0
- package/dist/define/primitive_module.d.ts.map +1 -1
- package/dist/define/primitive_module.js +10 -4
- package/dist/define/primitive_module.js.map +1 -1
- package/dist/entries/index.d.ts +1 -1
- package/dist/entries/index.d.ts.map +1 -1
- package/dist/entries/index.js +1 -1
- package/dist/entries/index.js.map +1 -1
- package/dist/entries/markdown.d.ts +1 -1
- package/dist/entries/markdown.d.ts.map +1 -1
- package/dist/entries/markdown.js +1 -1
- package/dist/entries/markdown.js.map +1 -1
- package/dist/pack/index.d.ts +1 -1
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +1 -1
- package/dist/pack/index.js.map +1 -1
- package/dist/pack/primitive_pack.d.ts +3 -1
- package/dist/pack/primitive_pack.d.ts.map +1 -1
- package/dist/pack/primitive_pack.js +13 -3
- package/dist/pack/primitive_pack.js.map +1 -1
- package/dist/render/format_number.d.ts.map +1 -1
- package/dist/render/format_number.js +2 -1
- package/dist/render/format_number.js.map +1 -1
- package/dist/render/html/envelope.js +12 -6
- package/dist/render/html/envelope.js.map +1 -1
- package/dist/render/markdown/builder.d.ts +3 -0
- package/dist/render/markdown/builder.d.ts.map +1 -1
- package/dist/render/markdown/builder.js +3 -1
- package/dist/render/markdown/builder.js.map +1 -1
- package/dist/render/markdown/format.d.ts +2 -0
- package/dist/render/markdown/format.d.ts.map +1 -1
- package/dist/render/markdown/format.js +42 -22
- package/dist/render/markdown/format.js.map +1 -1
- package/dist/render/markdown/host_tags.d.ts +14 -0
- package/dist/render/markdown/host_tags.d.ts.map +1 -0
- package/dist/render/markdown/host_tags.js +63 -0
- package/dist/render/markdown/host_tags.js.map +1 -0
- package/dist/render/markdown/index.d.ts +1 -0
- package/dist/render/markdown/index.d.ts.map +1 -1
- package/dist/render/markdown/index.js +1 -0
- package/dist/render/markdown/index.js.map +1 -1
- package/dist/render/markdown/split.d.ts +32 -0
- package/dist/render/markdown/split.d.ts.map +1 -0
- package/dist/render/markdown/split.js +321 -0
- package/dist/render/markdown/split.js.map +1 -0
- package/dist/render/react/content.d.ts +1 -1
- package/dist/render/react/content.d.ts.map +1 -1
- package/dist/render/react/content.js +3 -1
- package/dist/render/react/content.js.map +1 -1
- package/dist/render/slack/markdown_content.d.ts.map +1 -1
- package/dist/render/slack/markdown_content.js +7 -1
- package/dist/render/slack/markdown_content.js.map +1 -1
- package/dist/validate/json_schema.d.ts.map +1 -1
- package/dist/validate/json_schema.js +10 -3
- package/dist/validate/json_schema.js.map +1 -1
- package/dist/validate/url.d.ts.map +1 -1
- package/dist/validate/url.js +2 -1
- package/dist/validate/url.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
|
+
* 2.0.
|
|
6
|
+
*/
|
|
7
|
+
const NAME = String.raw `[A-Za-z_:][\w.:-]*`;
|
|
8
|
+
// A quoted value stays on one line and holds no backtick, so a code span
|
|
9
|
+
// opened before the tag still closes where CommonMark closes it.
|
|
10
|
+
const VALUE = String.raw `[^\s"'=<>\x60]+|'[^'\r\n\x60]*'|"[^"\r\n\x60]*"`;
|
|
11
|
+
const ATTRIBUTE = String.raw `[ \t]+${NAME}(?:[ \t]*=[ \t]*(?:${VALUE}))?`;
|
|
12
|
+
const ATTRIBUTE_RE = new RegExp(String.raw `[ \t]+(${NAME})(?:[ \t]*=[ \t]*(${VALUE}))?`, 'g');
|
|
13
|
+
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
14
|
+
const tagPattern = (names) => new RegExp(`<(${names.map(escapeRegExp).join('|')})((?:${ATTRIBUTE})*)[ \\t]*/?>`, 'gi');
|
|
15
|
+
const parseAttributes = (body) => {
|
|
16
|
+
const attributes = Object.create(null);
|
|
17
|
+
for (const [, name, value = ''] of body.matchAll(ATTRIBUTE_RE)) {
|
|
18
|
+
const key = name.toLowerCase();
|
|
19
|
+
if (!(key in attributes)) {
|
|
20
|
+
attributes[key] =
|
|
21
|
+
value.startsWith('"') || value.startsWith("'")
|
|
22
|
+
? value.slice(1, -1)
|
|
23
|
+
: value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return attributes;
|
|
27
|
+
};
|
|
28
|
+
// `\<` is an escaped `<`. Where a backslash is literal (code, HTML), the tag
|
|
29
|
+
// is literal too, so skipping it there changes nothing.
|
|
30
|
+
const isEscaped = (source, index) => {
|
|
31
|
+
let backslashes = 0;
|
|
32
|
+
while (source[index - backslashes - 1] === '\\') {
|
|
33
|
+
backslashes += 1;
|
|
34
|
+
}
|
|
35
|
+
return backslashes % 2 === 1;
|
|
36
|
+
};
|
|
37
|
+
/** Every tag named in `names` (matched case-insensitively and whole), in source order. */
|
|
38
|
+
export const findHostTags = (source, names) => {
|
|
39
|
+
const canonical = new Map();
|
|
40
|
+
for (const name of names) {
|
|
41
|
+
const lower = name.toLowerCase();
|
|
42
|
+
if (lower !== '' && !canonical.has(lower)) {
|
|
43
|
+
canonical.set(lower, name);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (canonical.size === 0) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const tags = [];
|
|
50
|
+
for (const match of source.matchAll(tagPattern([...canonical.keys()]))) {
|
|
51
|
+
if (isEscaped(source, match.index)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
tags.push({
|
|
55
|
+
index: match.index,
|
|
56
|
+
raw: match[0],
|
|
57
|
+
name: canonical.get(match[1].toLowerCase()),
|
|
58
|
+
attributes: parseAttributes(match[2]),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return tags;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=host_tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host_tags.js","sourceRoot":"","sources":["../../../src/render/markdown/host_tags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAA,oBAAoB,CAAC;AAC5C,yEAAyE;AACzE,iEAAiE;AACjE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAA,iDAAiD,CAAC;AAC1E,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA,SAAS,IAAI,sBAAsB,KAAK,KAAK,CAAC;AAC1E,MAAM,YAAY,GAAG,IAAI,MAAM,CAC7B,MAAM,CAAC,GAAG,CAAA,UAAU,IAAI,qBAAqB,KAAK,KAAK,EACvD,GAAG,CACJ,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAa,EAAU,EAAE,CAC7C,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAE/C,MAAM,UAAU,GAAG,CAAC,KAAwB,EAAU,EAAE,CACtD,IAAI,MAAM,CACR,KAAK,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,SAAS,eAAe,EACtE,IAAI,CACL,CAAC;AAEJ,MAAM,eAAe,GAAG,CAAC,IAAY,EAA0B,EAAE;I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AAC;YAC1C,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,IAAI,GAAc,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,IAAI,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,SAAS;QACX,CAAC;QACD,IAAI,CAAC,IAAI,CAAC;YACR,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACb,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,CAAE;YAC7C,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n// Finds a host's own tags, such as `<render_attachment id=\"…\" />`, in\n// authored Markdown. The grammar is CommonMark's raw HTML open tag (§6.6) on\n// one line, with `_` allowed in the name. One scan serves both paths of\n// `splitAuthoredMarkdown`: the parsed path swaps each tag for a sentinel\n// before parsing, and the over-budget path cuts the source at each tag.\n\n/** A tag found by {@link findHostTags}. */\nexport interface HostTag {\n /** Offset of the `<` in the source. */\n readonly index: number;\n /** The tag as written. */\n readonly raw: string;\n /** The name as listed in the options. */\n readonly name: string;\n /** Values as written, keyed by lower-cased name; a bare attribute is `''`. */\n readonly attributes: Readonly<Record<string, string>>;\n}\n\nconst NAME = String.raw`[A-Za-z_:][\\w.:-]*`;\n// A quoted value stays on one line and holds no backtick, so a code span\n// opened before the tag still closes where CommonMark closes it.\nconst VALUE = String.raw`[^\\s\"'=<>\\x60]+|'[^'\\r\\n\\x60]*'|\"[^\"\\r\\n\\x60]*\"`;\nconst ATTRIBUTE = String.raw`[ \\t]+${NAME}(?:[ \\t]*=[ \\t]*(?:${VALUE}))?`;\nconst ATTRIBUTE_RE = new RegExp(\n String.raw`[ \\t]+(${NAME})(?:[ \\t]*=[ \\t]*(${VALUE}))?`,\n 'g'\n);\n\nconst escapeRegExp = (value: string): string =>\n value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\nconst tagPattern = (names: readonly string[]): RegExp =>\n new RegExp(\n `<(${names.map(escapeRegExp).join('|')})((?:${ATTRIBUTE})*)[ \\\\t]*/?>`,\n 'gi'\n );\n\nconst parseAttributes = (body: string): Record<string, string> => {\n const attributes = Object.create(null) as Record<string, string>;\n for (const [, name, value = ''] of body.matchAll(ATTRIBUTE_RE)) {\n const key = name!.toLowerCase();\n if (!(key in attributes)) {\n attributes[key] =\n value.startsWith('\"') || value.startsWith(\"'\")\n ? value.slice(1, -1)\n : value;\n }\n }\n return attributes;\n};\n\n// `\\<` is an escaped `<`. Where a backslash is literal (code, HTML), the tag\n// is literal too, so skipping it there changes nothing.\nconst isEscaped = (source: string, index: number): boolean => {\n let backslashes = 0;\n while (source[index - backslashes - 1] === '\\\\') {\n backslashes += 1;\n }\n return backslashes % 2 === 1;\n};\n\n/** Every tag named in `names` (matched case-insensitively and whole), in source order. */\nexport const findHostTags = (\n source: string,\n names: readonly string[]\n): HostTag[] => {\n const canonical = new Map<string, string>();\n for (const name of names) {\n const lower = name.toLowerCase();\n if (lower !== '' && !canonical.has(lower)) {\n canonical.set(lower, name);\n }\n }\n if (canonical.size === 0) {\n return [];\n }\n const tags: HostTag[] = [];\n for (const match of source.matchAll(tagPattern([...canonical.keys()]))) {\n if (isEscaped(source, match.index)) {\n continue;\n }\n tags.push({\n index: match.index,\n raw: match[0],\n name: canonical.get(match[1]!.toLowerCase())!,\n attributes: parseAttributes(match[2]!),\n });\n }\n return tags;\n};\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { md, serializeMarkdown } from './builder.js';
|
|
2
2
|
export { type MarkdownEnvelopeDispatcher, type MarkdownEnvelopeOptions, renderMarkdownEnvelope, } from './envelope.js';
|
|
3
|
+
export { type AuthoredMarkdownSegment, type SplitAuthoredMarkdownOptions, splitAuthoredMarkdown, } from './split.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/render/markdown/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/render/markdown/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/render/markdown/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/render/markdown/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAGL,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAGL,qBAAqB,GACtB,MAAM,SAAS,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nexport { md, serializeMarkdown } from './builder';\nexport {\n type MarkdownEnvelopeDispatcher,\n type MarkdownEnvelopeOptions,\n renderMarkdownEnvelope,\n} from './envelope';\n\nexport {\n type AuthoredMarkdownSegment,\n type SplitAuthoredMarkdownOptions,\n splitAuthoredMarkdown,\n} from './split';\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MarkdownContent } from '../../define/markdown_content.js';
|
|
2
|
+
/** A piece of authored Markdown, or one of the host's elements cut out of it. */
|
|
3
|
+
export type AuthoredMarkdownSegment = {
|
|
4
|
+
type: 'markdown';
|
|
5
|
+
content: MarkdownContent;
|
|
6
|
+
/** The text `content` was built from, for a host that stores a string and passes it to `md.authored` later. */
|
|
7
|
+
source: string;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'element';
|
|
10
|
+
/** The name as listed in {@link SplitAuthoredMarkdownOptions.elements}. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Attribute values as written, keyed by lower-cased name; a bare attribute is `''`. */
|
|
13
|
+
attributes: Readonly<Record<string, string>>;
|
|
14
|
+
};
|
|
15
|
+
export interface SplitAuthoredMarkdownOptions {
|
|
16
|
+
/** Tag names to cut out, matched case-insensitively and whole. */
|
|
17
|
+
readonly elements: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Splits authored Markdown at the host's own elements, such as
|
|
21
|
+
* `<render_attachment id="…" />`, so the host can replace each with content
|
|
22
|
+
* of its own without cutting the raw string. The source is parsed once, so a
|
|
23
|
+
* tag in code, a link destination or title, an image's alt text, or raw HTML
|
|
24
|
+
* stays text, and a list, table, quote, or emphasis around a tag stays whole.
|
|
25
|
+
* Each `markdown` segment is sanitized as `md.authored` sanitizes; past the
|
|
26
|
+
* parse budget the source is cut at each tag into inert pieces.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* splitAuthoredMarkdown(message, { elements: ['render_attachment'] })
|
|
30
|
+
*/
|
|
31
|
+
export declare const splitAuthoredMarkdown: (source: string, { elements }: SplitAuthoredMarkdownOptions) => AuthoredMarkdownSegment[];
|
|
32
|
+
//# sourceMappingURL=split.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../../src/render/markdown/split.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMrE,iFAAiF;AACjF,MAAM,MAAM,uBAAuB,GAC/B;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,eAAe,CAAC;IACzB,+GAA+G;IAC/G,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC9C,CAAC;AAEN,MAAM,WAAW,4BAA4B;IAC3C,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AA8UD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,MAAM,EACd,cAAc,4BAA4B,KACzC,uBAAuB,EAezB,CAAC"}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
|
+
* 2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { md, printParsed, verbatim } from './builder.js';
|
|
8
|
+
import { exceedsParseBudget, inert, parseGfmBlocks } from './format.js';
|
|
9
|
+
import { findHostTags } from './host_tags.js';
|
|
10
|
+
// A sentinel keeps the tag's own `<` and `>` as its edges, so emphasis and
|
|
11
|
+
// other delimiters around it read exactly as they did around the tag, and
|
|
12
|
+
// holds private-use characters between them, which no Markdown construct
|
|
13
|
+
// reads, so it parses as text wherever the tag was written. Any already in
|
|
14
|
+
// the source, literal or as a character reference (the only other way text
|
|
15
|
+
// can decode to one), are replaced first, so the parsed text holds sentinels
|
|
16
|
+
// only where tags were.
|
|
17
|
+
const SENTINEL_RE = /<\uE000(\d+)\uE001>/g;
|
|
18
|
+
// In a link destination the parser strips the angle brackets.
|
|
19
|
+
const SENTINEL_ANYWHERE_RE = /<?\uE000(\d+)\uE001>?/g;
|
|
20
|
+
const RESERVED_RE = /[\uE000\uE001]|&#(?:[xX]0*[eE]00[01]|0*5734[45]);/g;
|
|
21
|
+
const sentinel = (index) => `<\uE000${index}\uE001>`;
|
|
22
|
+
const withoutReserved = (source) => source.replace(RESERVED_RE, (match) => match.length === 1 ? '\uFFFD' : '�');
|
|
23
|
+
// Tags written identically get the same sentinel, so a reference label that
|
|
24
|
+
// holds one still matches a definition that holds the same. Sharing by
|
|
25
|
+
// exact text keeps each tag's attributes and spelling its own.
|
|
26
|
+
const substitute = (source, tags) => {
|
|
27
|
+
const first = new Map();
|
|
28
|
+
let out = '';
|
|
29
|
+
let cursor = 0;
|
|
30
|
+
tags.forEach((tag, index) => {
|
|
31
|
+
if (!first.has(tag.raw)) {
|
|
32
|
+
first.set(tag.raw, index);
|
|
33
|
+
}
|
|
34
|
+
out += source.slice(cursor, tag.index) + sentinel(first.get(tag.raw));
|
|
35
|
+
cursor = tag.index + tag.raw.length;
|
|
36
|
+
});
|
|
37
|
+
return out + source.slice(cursor);
|
|
38
|
+
};
|
|
39
|
+
// The GFM serializer's cost grows steeply with nesting depth, while the
|
|
40
|
+
// parse budget bounds breadth, not depth. Nothing authored nests this deep.
|
|
41
|
+
const MAX_DEPTH = 64;
|
|
42
|
+
const exceedsDepth = (nodes, depth = 1) => depth > MAX_DEPTH ||
|
|
43
|
+
nodes.some((node) => 'children' in node && exceedsDepth(node.children, depth + 1));
|
|
44
|
+
// The tag's node in the tree, until it is cut out again.
|
|
45
|
+
const HOST = 'isomerHostElement';
|
|
46
|
+
const isHost = (node) => node.type === HOST;
|
|
47
|
+
const hostTag = (node) => node.tag;
|
|
48
|
+
const element = ({ name, attributes }) => ({
|
|
49
|
+
type: 'element',
|
|
50
|
+
name,
|
|
51
|
+
attributes,
|
|
52
|
+
});
|
|
53
|
+
const markdown = (source) => source.trim() === ''
|
|
54
|
+
? []
|
|
55
|
+
: [{ type: 'markdown', content: md.authored(source), source }];
|
|
56
|
+
// A sentinel in a text node becomes a host node between the text around it.
|
|
57
|
+
// In any other string (code, alt, url, title, HTML) the tag text goes back. A
|
|
58
|
+
// footnote prints at the end of its segment, away from where it is cited, so
|
|
59
|
+
// a tag inside one is literal too.
|
|
60
|
+
const resolve = (node, tags, literal) => {
|
|
61
|
+
if (node.type === 'text' && !literal) {
|
|
62
|
+
const parts = [];
|
|
63
|
+
let cursor = 0;
|
|
64
|
+
for (const match of node.value.matchAll(SENTINEL_RE)) {
|
|
65
|
+
if (match.index > cursor) {
|
|
66
|
+
parts.push({
|
|
67
|
+
type: 'text',
|
|
68
|
+
value: node.value.slice(cursor, match.index),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
parts.push({
|
|
72
|
+
type: HOST,
|
|
73
|
+
tag: tags[Number(match[1])],
|
|
74
|
+
});
|
|
75
|
+
cursor = match.index + match[0].length;
|
|
76
|
+
}
|
|
77
|
+
if (parts.length === 0) {
|
|
78
|
+
return [node];
|
|
79
|
+
}
|
|
80
|
+
if (cursor < node.value.length) {
|
|
81
|
+
parts.push({ type: 'text', value: node.value.slice(cursor) });
|
|
82
|
+
}
|
|
83
|
+
return parts;
|
|
84
|
+
}
|
|
85
|
+
const restored = { ...node };
|
|
86
|
+
for (const [key, value] of Object.entries(restored)) {
|
|
87
|
+
if (typeof value === 'string') {
|
|
88
|
+
restored[key] = value.replace(SENTINEL_ANYWHERE_RE, (_, index) => tags[Number(index)].raw);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if ('children' in node) {
|
|
92
|
+
restored.children = node.children.flatMap((child) => resolve(child, tags, literal || node.type === 'footnoteDefinition'));
|
|
93
|
+
}
|
|
94
|
+
return [restored];
|
|
95
|
+
};
|
|
96
|
+
// Depth-first, in document order.
|
|
97
|
+
const walk = (node, visit) => {
|
|
98
|
+
visit(node);
|
|
99
|
+
if ('children' in node) {
|
|
100
|
+
node.children.forEach((child) => walk(child, visit));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const PHRASING_PARENTS = new Set([
|
|
104
|
+
'delete',
|
|
105
|
+
'emphasis',
|
|
106
|
+
'heading',
|
|
107
|
+
'link',
|
|
108
|
+
'linkReference',
|
|
109
|
+
'paragraph',
|
|
110
|
+
'strong',
|
|
111
|
+
'tableCell',
|
|
112
|
+
]);
|
|
113
|
+
// A wrapper the tag leaves empty would print its markers alone (`****` is a
|
|
114
|
+
// thematic break). Containers keep their place: an empty list item keeps the
|
|
115
|
+
// numbering of the items after it.
|
|
116
|
+
const DROPPED_WHEN_EMPTY = new Set([
|
|
117
|
+
'delete',
|
|
118
|
+
'emphasis',
|
|
119
|
+
'heading',
|
|
120
|
+
'link',
|
|
121
|
+
'linkReference',
|
|
122
|
+
'paragraph',
|
|
123
|
+
'strong',
|
|
124
|
+
]);
|
|
125
|
+
// Text either side of a removed tag joins, with one space if either side
|
|
126
|
+
// had one. The run's edges are trimmed, and a hard break left at an edge is
|
|
127
|
+
// dropped as `md.paragraph` drops it, since it would print as a bare `\\`.
|
|
128
|
+
const tidyPhrasing = (children) => {
|
|
129
|
+
const joined = [];
|
|
130
|
+
for (const child of children) {
|
|
131
|
+
const previous = joined[joined.length - 1];
|
|
132
|
+
if (previous?.type === 'text' && child.type === 'text') {
|
|
133
|
+
const left = previous.value.replace(/\s+$/, '');
|
|
134
|
+
const right = child.value.replace(/^\s+/, '');
|
|
135
|
+
const spaced = left !== previous.value || right !== child.value;
|
|
136
|
+
joined[joined.length - 1] = {
|
|
137
|
+
type: 'text',
|
|
138
|
+
value: left + (spaced ? ' ' : '') + right,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
joined.push(child);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const isEdge = (node) => node?.type === 'break' ||
|
|
146
|
+
(node?.type === 'text' && node.value.trim() === '');
|
|
147
|
+
while (isEdge(joined[0])) {
|
|
148
|
+
joined.shift();
|
|
149
|
+
}
|
|
150
|
+
while (isEdge(joined[joined.length - 1])) {
|
|
151
|
+
joined.pop();
|
|
152
|
+
}
|
|
153
|
+
const first = joined[0];
|
|
154
|
+
if (first?.type === 'text') {
|
|
155
|
+
joined[0] = { ...first, value: first.value.trimStart() };
|
|
156
|
+
}
|
|
157
|
+
const last = joined[joined.length - 1];
|
|
158
|
+
if (last?.type === 'text') {
|
|
159
|
+
joined[joined.length - 1] = { ...last, value: last.value.trimEnd() };
|
|
160
|
+
}
|
|
161
|
+
return joined;
|
|
162
|
+
};
|
|
163
|
+
// `node` without its host nodes, which are appended to `found` in document
|
|
164
|
+
// order; `[]` when nothing is left of it. Only a node a tag was removed
|
|
165
|
+
// from is tidied, so phrasing elsewhere in the block stays as written.
|
|
166
|
+
const strip = (node, found) => {
|
|
167
|
+
if (isHost(node)) {
|
|
168
|
+
found.push(hostTag(node));
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
if (!('children' in node)) {
|
|
172
|
+
return [node];
|
|
173
|
+
}
|
|
174
|
+
const before = found.length;
|
|
175
|
+
const stripped = node.children.flatMap((child) => strip(child, found));
|
|
176
|
+
if (found.length === before) {
|
|
177
|
+
return [node];
|
|
178
|
+
}
|
|
179
|
+
const children = PHRASING_PARENTS.has(node.type)
|
|
180
|
+
? tidyPhrasing(stripped)
|
|
181
|
+
: stripped;
|
|
182
|
+
return children.length === 0 && DROPPED_WHEN_EMPTY.has(node.type)
|
|
183
|
+
? []
|
|
184
|
+
: [{ ...node, children }];
|
|
185
|
+
};
|
|
186
|
+
// The first definition of each identifier, anywhere in the tree, as the
|
|
187
|
+
// parser resolved references.
|
|
188
|
+
const firstDefinitions = (blocks) => {
|
|
189
|
+
const definitions = new Map();
|
|
190
|
+
for (const block of blocks) {
|
|
191
|
+
walk(block, (node) => {
|
|
192
|
+
if (node.type === 'definition' && !definitions.has(node.identifier)) {
|
|
193
|
+
definitions.set(node.identifier, node);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return definitions;
|
|
198
|
+
};
|
|
199
|
+
// Each segment is a document of its own, so a definition another segment
|
|
200
|
+
// holds is copied ahead of the run that references it.
|
|
201
|
+
const printRun = (run, definitions) => {
|
|
202
|
+
const present = new Set();
|
|
203
|
+
const needed = new Map();
|
|
204
|
+
for (const block of run) {
|
|
205
|
+
walk(block, (node) => {
|
|
206
|
+
present.add(node);
|
|
207
|
+
if (node.type === 'linkReference' || node.type === 'imageReference') {
|
|
208
|
+
const definition = definitions.get(node.identifier);
|
|
209
|
+
if (definition) {
|
|
210
|
+
needed.set(node.identifier, definition);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const carried = [...needed.values()].filter((node) => !present.has(node));
|
|
216
|
+
return printParsed([...carried, ...run]);
|
|
217
|
+
};
|
|
218
|
+
const splitBlocks = (blocks, tags) => {
|
|
219
|
+
const resolved = blocks.flatMap((block) => resolve(block, tags, false));
|
|
220
|
+
const definitions = firstDefinitions(resolved);
|
|
221
|
+
const segments = [];
|
|
222
|
+
let run = [];
|
|
223
|
+
const flush = () => {
|
|
224
|
+
if (run.length > 0) {
|
|
225
|
+
segments.push(...markdown(printRun(run, definitions)));
|
|
226
|
+
}
|
|
227
|
+
run = [];
|
|
228
|
+
};
|
|
229
|
+
// `block` without its tags joins the run; each tag ends the run after it.
|
|
230
|
+
const push = (block) => {
|
|
231
|
+
const found = [];
|
|
232
|
+
run.push(...strip(block, found));
|
|
233
|
+
for (const tag of found) {
|
|
234
|
+
flush();
|
|
235
|
+
segments.push(element(tag));
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
for (const block of resolved) {
|
|
239
|
+
if (block.type === 'definition') {
|
|
240
|
+
// Prints nothing where it stands; it is copied where it is referenced.
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (block.type !== 'paragraph' || !block.children.some(isHost)) {
|
|
244
|
+
push(block);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
// A tag directly in a top-level paragraph splits it in place.
|
|
248
|
+
let piece = [];
|
|
249
|
+
const pushPiece = () => {
|
|
250
|
+
const children = tidyPhrasing(piece);
|
|
251
|
+
if (children.length > 0) {
|
|
252
|
+
push({ ...block, children });
|
|
253
|
+
}
|
|
254
|
+
piece = [];
|
|
255
|
+
};
|
|
256
|
+
for (const child of block.children) {
|
|
257
|
+
if (isHost(child)) {
|
|
258
|
+
pushPiece();
|
|
259
|
+
flush();
|
|
260
|
+
segments.push(element(hostTag(child)));
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
piece.push(child);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
pushPiece();
|
|
267
|
+
}
|
|
268
|
+
flush();
|
|
269
|
+
return segments;
|
|
270
|
+
};
|
|
271
|
+
// Past the parse budget there is no tree to consult, so the source is cut at
|
|
272
|
+
// each tag and every piece degrades to inert text, as `md.authored` degrades.
|
|
273
|
+
const cutLinearly = (source, tags) => {
|
|
274
|
+
const segments = [];
|
|
275
|
+
const push = (piece) => {
|
|
276
|
+
const text = piece.trim();
|
|
277
|
+
if (text !== '') {
|
|
278
|
+
segments.push({
|
|
279
|
+
type: 'markdown',
|
|
280
|
+
content: verbatim(inert(text), text),
|
|
281
|
+
source: text,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
let cursor = 0;
|
|
286
|
+
for (const tag of tags) {
|
|
287
|
+
push(source.slice(cursor, tag.index));
|
|
288
|
+
segments.push(element(tag));
|
|
289
|
+
cursor = tag.index + tag.raw.length;
|
|
290
|
+
}
|
|
291
|
+
push(source.slice(cursor));
|
|
292
|
+
return segments;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Splits authored Markdown at the host's own elements, such as
|
|
296
|
+
* `<render_attachment id="…" />`, so the host can replace each with content
|
|
297
|
+
* of its own without cutting the raw string. The source is parsed once, so a
|
|
298
|
+
* tag in code, a link destination or title, an image's alt text, or raw HTML
|
|
299
|
+
* stays text, and a list, table, quote, or emphasis around a tag stays whole.
|
|
300
|
+
* Each `markdown` segment is sanitized as `md.authored` sanitizes; past the
|
|
301
|
+
* parse budget the source is cut at each tag into inert pieces.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* splitAuthoredMarkdown(message, { elements: ['render_attachment'] })
|
|
305
|
+
*/
|
|
306
|
+
export const splitAuthoredMarkdown = (source, { elements }) => {
|
|
307
|
+
const cleaned = withoutReserved(source);
|
|
308
|
+
const tags = findHostTags(cleaned, elements);
|
|
309
|
+
if (tags.length === 0) {
|
|
310
|
+
return markdown(source);
|
|
311
|
+
}
|
|
312
|
+
// The budget applies to the source as written: a long attribute value
|
|
313
|
+
// shrinks to a sentinel, but comes back in full wherever it is literal.
|
|
314
|
+
const blocks = exceedsParseBudget(cleaned)
|
|
315
|
+
? null
|
|
316
|
+
: parseGfmBlocks(substitute(cleaned, tags));
|
|
317
|
+
return blocks && !exceedsDepth(blocks)
|
|
318
|
+
? splitBlocks(blocks, tags)
|
|
319
|
+
: cutLinearly(cleaned, tags);
|
|
320
|
+
};
|
|
321
|
+
//# sourceMappingURL=split.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../../src/render/markdown/split.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAC;AAuBzD,2EAA2E;AAC3E,0EAA0E;AAC1E,yEAAyE;AACzE,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,wBAAwB;AACxB,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAC3C,8DAA8D;AAC9D,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AACtD,MAAM,WAAW,GAAG,oDAAoD,CAAC;AACzE,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,UAAU,KAAK,SAAS,CAAC;AACrE,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE,CACjD,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CACpC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAC3C,CAAC;AAEJ,4EAA4E;AAC5E,uEAAuE;AACvE,+DAA+D;AAC/D,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,IAAwB,EAAU,EAAE;IACtE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC1B,I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KAAK,CAAC,CAAC,CAAC;QACtC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;IACtC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,MAAc,EACd,EAAE,QAAQ,EAAgC,EACf,EAAE;IAC7B,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IACD,sEAAsE;IACtE,wEAAwE;IACxE,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC;QACxC,CAAC,CAAC,IAAI;QACN,CAAC,CAAE,cAAc,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CACT,CAAC;IACrC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QACpC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC;QAC3B,CAAC,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n// Splits authored Markdown at a host's own tags without a second grammar:\n// each tag becomes a sentinel, the stock GFM parser parses the whole source\n// once, and where the sentinel lands says what the tag is. In a `text`\n// node it is a tag; anywhere else (a code span or block, an image's alt, a\n// link destination or title, raw HTML) it is literal and the tag text goes\n// back. Blocks that held a tag are then printed from the tree.\n\nimport type { Definition, Nodes, RootContent } from 'mdast';\n\nimport type { MarkdownContent } from '../../define/markdown_content';\n\nimport { md, printParsed, verbatim } from './builder';\nimport { exceedsParseBudget, inert, parseGfmBlocks } from './format';\nimport { findHostTags, type HostTag } from './host_tags';\n\n/** A piece of authored Markdown, or one of the host's elements cut out of it. */\nexport type AuthoredMarkdownSegment =\n | {\n type: 'markdown';\n content: MarkdownContent;\n /** The text `content` was built from, for a host that stores a string and passes it to `md.authored` later. */\n source: string;\n }\n | {\n type: 'element';\n /** The name as listed in {@link SplitAuthoredMarkdownOptions.elements}. */\n name: string;\n /** Attribute values as written, keyed by lower-cased name; a bare attribute is `''`. */\n attributes: Readonly<Record<string, string>>;\n };\n\nexport interface SplitAuthoredMarkdownOptions {\n /** Tag names to cut out, matched case-insensitively and whole. */\n readonly elements: readonly string[];\n}\n\n// A sentinel keeps the tag's own `<` and `>` as its edges, so emphasis and\n// other delimiters around it read exactly as they did around the tag, and\n// holds private-use characters between them, which no Markdown construct\n// reads, so it parses as text wherever the tag was written. Any already in\n// the source, literal or as a character reference (the only other way text\n// can decode to one), are replaced first, so the parsed text holds sentinels\n// only where tags were.\nconst SENTINEL_RE = /<\\uE000(\\d+)\\uE001>/g;\n// In a link destination the parser strips the angle brackets.\nconst SENTINEL_ANYWHERE_RE = /<?\\uE000(\\d+)\\uE001>?/g;\nconst RESERVED_RE = /[\\uE000\\uE001]|&#(?:[xX]0*[eE]00[01]|0*5734[45]);/g;\nconst sentinel = (index: number): string => `<\\uE000${index}\\uE001>`;\nconst withoutReserved = (source: string): string =>\n source.replace(RESERVED_RE, (match) =>\n match.length === 1 ? '\\uFFFD' : '�'\n );\n\n// Tags written identically get the same sentinel, so a reference label that\n// holds one still matches a definition that holds the same. Sharing by\n// exact text keeps each tag's attributes and spelling its own.\nconst substitute = (source: string, tags: readonly HostTag[]): string => {\n const first = new Map<string, number>();\n let out = '';\n let cursor = 0;\n tags.forEach((tag, index) => {\n if (!first.has(tag.raw)) {\n first.set(tag.raw, index);\n }\n out += source.slice(cursor, tag.index) + sentinel(first.get(tag.raw)!);\n cursor = tag.index + tag.raw.length;\n });\n return out + source.slice(cursor);\n};\n\n// The GFM serializer's cost grows steeply with nesting depth, while the\n// parse budget bounds breadth, not depth. Nothing authored nests this deep.\nconst MAX_DEPTH = 64;\n\nconst exceedsDepth = (nodes: readonly Nodes[], depth = 1): boolean =>\n depth > MAX_DEPTH ||\n nodes.some(\n (node) => 'children' in node && exceedsDepth(node.children, depth + 1)\n );\n\n// The tag's node in the tree, until it is cut out again.\nconst HOST = 'isomerHostElement';\ninterface HostNode {\n type: typeof HOST;\n tag: HostTag;\n}\n\nconst isHost = (node: Nodes): boolean => (node.type as string) === HOST;\nconst hostTag = (node: Nodes): HostTag => (node as unknown as HostNode).tag;\n\nconst element = ({ name, attributes }: HostTag): AuthoredMarkdownSegment => ({\n type: 'element',\n name,\n attributes,\n});\n\nconst markdown = (source: string): AuthoredMarkdownSegment[] =>\n source.trim() === ''\n ? []\n : [{ type: 'markdown', content: md.authored(source), source }];\n\n// A sentinel in a text node becomes a host node between the text around it.\n// In any other string (code, alt, url, title, HTML) the tag text goes back. A\n// footnote prints at the end of its segment, away from where it is cited, so\n// a tag inside one is literal too.\nconst resolve = (\n node: Nodes,\n tags: readonly HostTag[],\n literal: boolean\n): Nodes[] => {\n if (node.type === 'text' && !literal) {\n const parts: Nodes[] = [];\n let cursor = 0;\n for (const match of node.value.matchAll(SENTINEL_RE)) {\n if (match.index > cursor) {\n parts.push({\n type: 'text',\n value: node.value.slice(cursor, match.index),\n });\n }\n parts.push({\n type: HOST,\n tag: tags[Number(match[1])]!,\n } as unknown as Nodes);\n cursor = match.index + match[0].length;\n }\n if (parts.length === 0) {\n return [node];\n }\n if (cursor < node.value.length) {\n parts.push({ type: 'text', value: node.value.slice(cursor) });\n }\n return parts;\n }\n const restored = { ...node } as Record<string, unknown>;\n for (const [key, value] of Object.entries(restored)) {\n if (typeof value === 'string') {\n restored[key] = value.replace(\n SENTINEL_ANYWHERE_RE,\n (_, index: string) => tags[Number(index)]!.raw\n );\n }\n }\n if ('children' in node) {\n restored.children = node.children.flatMap((child) =>\n resolve(child, tags, literal || node.type === 'footnoteDefinition')\n );\n }\n return [restored as unknown as Nodes];\n};\n\n// Depth-first, in document order.\nconst walk = (node: Nodes, visit: (node: Nodes) => void): void => {\n visit(node);\n if ('children' in node) {\n node.children.forEach((child) => walk(child, visit));\n }\n};\n\nconst PHRASING_PARENTS = new Set([\n 'delete',\n 'emphasis',\n 'heading',\n 'link',\n 'linkReference',\n 'paragraph',\n 'strong',\n 'tableCell',\n]);\n\n// A wrapper the tag leaves empty would print its markers alone (`****` is a\n// thematic break). Containers keep their place: an empty list item keeps the\n// numbering of the items after it.\nconst DROPPED_WHEN_EMPTY = new Set([\n 'delete',\n 'emphasis',\n 'heading',\n 'link',\n 'linkReference',\n 'paragraph',\n 'strong',\n]);\n\n// Text either side of a removed tag joins, with one space if either side\n// had one. The run's edges are trimmed, and a hard break left at an edge is\n// dropped as `md.paragraph` drops it, since it would print as a bare `\\\\`.\nconst tidyPhrasing = (children: Nodes[]): Nodes[] => {\n const joined: Nodes[] = [];\n for (const child of children) {\n const previous = joined[joined.length - 1];\n if (previous?.type === 'text' && child.type === 'text') {\n const left = previous.value.replace(/\\s+$/, '');\n const right = child.value.replace(/^\\s+/, '');\n const spaced = left !== previous.value || right !== child.value;\n joined[joined.length - 1] = {\n type: 'text',\n value: left + (spaced ? ' ' : '') + right,\n };\n } else {\n joined.push(child);\n }\n }\n const isEdge = (node: Nodes | undefined): boolean =>\n node?.type === 'break' ||\n (node?.type === 'text' && node.value.trim() === '');\n while (isEdge(joined[0])) {\n joined.shift();\n }\n while (isEdge(joined[joined.length - 1])) {\n joined.pop();\n }\n const first = joined[0];\n if (first?.type === 'text') {\n joined[0] = { ...first, value: first.value.trimStart() };\n }\n const last = joined[joined.length - 1];\n if (last?.type === 'text') {\n joined[joined.length - 1] = { ...last, value: last.value.trimEnd() };\n }\n return joined;\n};\n\n// `node` without its host nodes, which are appended to `found` in document\n// order; `[]` when nothing is left of it. Only a node a tag was removed\n// from is tidied, so phrasing elsewhere in the block stays as written.\nconst strip = (node: Nodes, found: HostTag[]): Nodes[] => {\n if (isHost(node)) {\n found.push(hostTag(node));\n return [];\n }\n if (!('children' in node)) {\n return [node];\n }\n const before = found.length;\n const stripped = node.children.flatMap((child) => strip(child, found));\n if (found.length === before) {\n return [node];\n }\n const children = PHRASING_PARENTS.has(node.type)\n ? tidyPhrasing(stripped)\n : stripped;\n return children.length === 0 && DROPPED_WHEN_EMPTY.has(node.type)\n ? []\n : [{ ...node, children } as Nodes];\n};\n\n// The first definition of each identifier, anywhere in the tree, as the\n// parser resolved references.\nconst firstDefinitions = (\n blocks: readonly Nodes[]\n): ReadonlyMap<string, Definition> => {\n const definitions = new Map<string, Definition>();\n for (const block of blocks) {\n walk(block, (node) => {\n if (node.type === 'definition' && !definitions.has(node.identifier)) {\n definitions.set(node.identifier, node);\n }\n });\n }\n return definitions;\n};\n\n// Each segment is a document of its own, so a definition another segment\n// holds is copied ahead of the run that references it.\nconst printRun = (\n run: readonly Nodes[],\n definitions: ReadonlyMap<string, Definition>\n): string => {\n const present = new Set<Nodes>();\n const needed = new Map<string, Definition>();\n for (const block of run) {\n walk(block, (node) => {\n present.add(node);\n if (node.type === 'linkReference' || node.type === 'imageReference') {\n const definition = definitions.get(node.identifier);\n if (definition) {\n needed.set(node.identifier, definition);\n }\n }\n });\n }\n const carried = [...needed.values()].filter((node) => !present.has(node));\n return printParsed([...carried, ...run]);\n};\n\nconst splitBlocks = (\n blocks: readonly Nodes[],\n tags: readonly HostTag[]\n): AuthoredMarkdownSegment[] => {\n const resolved = blocks.flatMap((block) => resolve(block, tags, false));\n const definitions = firstDefinitions(resolved);\n const segments: AuthoredMarkdownSegment[] = [];\n let run: Nodes[] = [];\n const flush = (): void => {\n if (run.length > 0) {\n segments.push(...markdown(printRun(run, definitions)));\n }\n run = [];\n };\n // `block` without its tags joins the run; each tag ends the run after it.\n const push = (block: Nodes): void => {\n const found: HostTag[] = [];\n run.push(...strip(block, found));\n for (const tag of found) {\n flush();\n segments.push(element(tag));\n }\n };\n for (const block of resolved) {\n if (block.type === 'definition') {\n // Prints nothing where it stands; it is copied where it is referenced.\n continue;\n }\n if (block.type !== 'paragraph' || !block.children.some(isHost)) {\n push(block);\n continue;\n }\n // A tag directly in a top-level paragraph splits it in place.\n let piece: Nodes[] = [];\n const pushPiece = (): void => {\n const children = tidyPhrasing(piece);\n if (children.length > 0) {\n push({ ...block, children } as Nodes);\n }\n piece = [];\n };\n for (const child of block.children) {\n if (isHost(child)) {\n pushPiece();\n flush();\n segments.push(element(hostTag(child)));\n } else {\n piece.push(child);\n }\n }\n pushPiece();\n }\n flush();\n return segments;\n};\n\n// Past the parse budget there is no tree to consult, so the source is cut at\n// each tag and every piece degrades to inert text, as `md.authored` degrades.\nconst cutLinearly = (\n source: string,\n tags: readonly HostTag[]\n): AuthoredMarkdownSegment[] => {\n const segments: AuthoredMarkdownSegment[] = [];\n const push = (piece: string): void => {\n const text = piece.trim();\n if (text !== '') {\n segments.push({\n type: 'markdown',\n content: verbatim(inert(text), text),\n source: text,\n });\n }\n };\n let cursor = 0;\n for (const tag of tags) {\n push(source.slice(cursor, tag.index));\n segments.push(element(tag));\n cursor = tag.index + tag.raw.length;\n }\n push(source.slice(cursor));\n return segments;\n};\n\n/**\n * Splits authored Markdown at the host's own elements, such as\n * `<render_attachment id=\"…\" />`, so the host can replace each with content\n * of its own without cutting the raw string. The source is parsed once, so a\n * tag in code, a link destination or title, an image's alt text, or raw HTML\n * stays text, and a list, table, quote, or emphasis around a tag stays whole.\n * Each `markdown` segment is sanitized as `md.authored` sanitizes; past the\n * parse budget the source is cut at each tag into inert pieces.\n *\n * @example\n * splitAuthoredMarkdown(message, { elements: ['render_attachment'] })\n */\nexport const splitAuthoredMarkdown = (\n source: string,\n { elements }: SplitAuthoredMarkdownOptions\n): AuthoredMarkdownSegment[] => {\n const cleaned = withoutReserved(source);\n const tags = findHostTags(cleaned, elements);\n if (tags.length === 0) {\n return markdown(source);\n }\n // The budget applies to the source as written: a long attribute value\n // shrinks to a sentinel, but comes back in full wherever it is literal.\n const blocks = exceedsParseBudget(cleaned)\n ? null\n : (parseGfmBlocks(substitute(cleaned, tags)) as\n readonly RootContent[] | null);\n return blocks && !exceedsDepth(blocks)\n ? splitBlocks(blocks, tags)\n : cutLinearly(cleaned, tags);\n};\n"]}
|
|
@@ -27,7 +27,7 @@ export interface CompositionWrapperOptions {
|
|
|
27
27
|
framed?: boolean;
|
|
28
28
|
/** Adds the `fluid` class. */
|
|
29
29
|
fluid?: boolean;
|
|
30
|
-
/** Sets `data-theme
|
|
30
|
+
/** Sets `data-theme` and `color-scheme`, which `light-dark()` resolves against; defaults to the composition's `theme`, and `auto` sets nothing so the page's scheme applies. */
|
|
31
31
|
theme?: RenderTheme;
|
|
32
32
|
/** Used only when the composition has neither `meta.ariaLabel` nor a `title`. Defaults to `'View'`. */
|
|
33
33
|
defaultAriaLabel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/render/react/content.ts"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE1E,4DAA4D;AAC5D,MAAM,WAAW,sBAAsB,CACrC,KAAK,SAAS,aAAa,EAC3B,QAAQ,GAAG,sBAAsB;IAEjC,4GAA4G;IAC5G,WA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MAAM,wBAAwB,GACnC,KAAK,SAAS,aAAa,EAC3B,QAAQ,GAAG,sBAAsB,EAEjC,aAAa,WAAW,CAAC,KAAK,CAAC,EAC/B,YAAY,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,EACnD,SAAS,QAAQ,EACjB,cAAoB,mBAAwB,KAC3C,SAwBA,CAAC;AAkBJ,kDAAkD;AAClD,MAAM,WAAW,yBAAyB;IACxC,mDAAmD;IACnD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gLAAgL;IAChL,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,uGAAuG;IACvG,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,SAAS,aAAa,EAChE,SAAS,SAAS,EAClB,aAAa,WAAW,CAAC,KAAK,CAAC,EAC/B,8CAKG,yBAA8B,KAChC,YAeA,CAAC"}
|
|
@@ -34,6 +34,8 @@ export const wrapCompositionContent = (content, composition, { framed = true, fl
|
|
|
34
34
|
.join(' '),
|
|
35
35
|
role: 'group',
|
|
36
36
|
'aria-label': composition.meta?.ariaLabel ?? composition.title ?? defaultAriaLabel,
|
|
37
|
-
...(theme === 'auto'
|
|
37
|
+
...(theme === 'auto'
|
|
38
|
+
? {}
|
|
39
|
+
: { 'data-theme': theme, style: { colorScheme: theme } }),
|
|
38
40
|
}, content);
|
|
39
41
|
//# sourceMappingURL=content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/render/react/content.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,aAAa,EACb,QAAQ,GAGT,MAAM,OAAO,CAAC;AAyBf;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAItC,WAA+B,EAC/B,UAAmD,EACnD,OAAiB,EACjB,E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GAAG,CAAwC,EACtE,IAAI,EACJ,OAAO,EACP,UAAU,GACoC,EAAa,EAAE,CAC7D,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAcxC;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAkB,EAClB,WAA+B,EAC/B,EACE,MAAM,GAAG,IAAI,EACb,KAAK,GAAG,KAAK,EACb,KAAK,GAAG,WAAW,CAAC,KAAK,IAAI,MAAM,EACnC,gBAAgB,GAAG,MAAM,MACI,EAAE,EACnB,EAAE,CAChB,aAAa,CACX,SAAS,EACT;IACE,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;SAChE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC;IACZ,IAAI,EAAE,OAAO;IACb,YAAY,EACV,WAAW,CAAC,IAAI,EAAE,SAAS,IAAI,WAAW,CAAC,KAAK,IAAI,gBAAgB;IACtE,GAAG,CAAC,KAAK,KAAK,MAAM;QAClB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC;CAC5D,EACD,OAAO,CACR,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport {\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\nimport type { Composition } from '../../composition';\nimport type { RenderTheme } from '../../composition/named_color';\nimport type { PrimitiveNode, PrimitiveRenderContext } from '../../define';\n\n/** A pack's React renderer for one node of its own type. */\nexport interface ReactContentDispatcher<\n TNode extends PrimitiveNode,\n TContext = PrimitiveRenderContext,\n> {\n /** Must be side-effect free: the HTML surface calls it twice, once to collect styles and once to render. */\n renderReact(node: TNode, context?: TContext): ReactNode;\n}\n\n/** Options for {@link renderCompositionContent}. */\nexport interface ReactContentOptions {\n /**\n * Renders the composition's title and subtitle as the leading `h2` / `p.sub`.\n * Defaults to `true`. Pass `false` when the host already shows the title\n * itself; the title still backs the wrapper's `aria-label`.\n */\n heading?: boolean;\n}\n\n/**\n * A composition's heading and body as React nodes, without the surrounding\n * document or wrapper element.\n */\nexport const renderCompositionContent = <\n TNode extends PrimitiveNode,\n TContext = PrimitiveRenderContext,\n>(\n composition: Composition<TNode>,\n dispatcher: ReactContentDispatcher<TNode, TContext>,\n context: TContext,\n { heading = true }: ReactContentOptions = {}\n): ReactNode =>\n createElement(\n Fragment,\n null,\n ...[\n heading && composition.title\n ? createElement('h2', { key: 'title' }, composition.title)\n : null,\n heading && composition.subtitle\n ? createElement(\n 'p',\n { key: 'subtitle', className: 'sub' },\n composition.subtitle\n )\n : null,\n ...composition.body.map((node, index) =>\n createElement(RenderedCompositionNode<TNode, TContext>, {\n key: `body-${index}`,\n node,\n context,\n dispatcher,\n })\n ),\n ].filter(Boolean)\n );\n\ninterface RenderedCompositionNodeProps<\n TNode extends PrimitiveNode,\n TContext = PrimitiveRenderContext,\n> {\n node: TNode;\n context: TContext;\n dispatcher: ReactContentDispatcher<TNode, TContext>;\n}\n\nconst RenderedCompositionNode = <TNode extends PrimitiveNode, TContext>({\n node,\n context,\n dispatcher,\n}: RenderedCompositionNodeProps<TNode, TContext>): ReactNode =>\n dispatcher.renderReact(node, context);\n\n/** Options for {@link wrapCompositionContent}. */\nexport interface CompositionWrapperOptions {\n /** Adds the `framed` class. Defaults to `true`. */\n framed?: boolean;\n /** Adds the `fluid` class. */\n fluid?: boolean;\n /** Sets `data-theme` and `color-scheme`, which `light-dark()` resolves against; defaults to the composition's `theme`, and `auto` sets nothing so the page's scheme applies. */\n theme?: RenderTheme;\n /** Used only when the composition has neither `meta.ariaLabel` nor a `title`. Defaults to `'View'`. */\n defaultAriaLabel?: string;\n}\n\n/**\n * The one `.isomer[.framed][.fluid]` `section` every surface wraps rendered\n * content in: the `html` surface's document wrapper and a React host's.\n */\nexport const wrapCompositionContent = <TNode extends PrimitiveNode>(\n content: ReactNode,\n composition: Composition<TNode>,\n {\n framed = true,\n fluid = false,\n theme = composition.theme ?? 'auto',\n defaultAriaLabel = 'View',\n }: CompositionWrapperOptions = {}\n): ReactElement =>\n createElement(\n 'section',\n {\n className: ['isomer', framed ? 'framed' : '', fluid ? 'fluid' : '']\n .filter(Boolean)\n .join(' '),\n role: 'group',\n 'aria-label':\n composition.meta?.ariaLabel ?? composition.title ?? defaultAriaLabel,\n ...(theme === 'auto'\n ? {}\n : { 'data-theme': theme, style: { colorScheme: theme } }),\n },\n content\n );\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown_content.d.ts","sourceRoot":"","sources":["../../../src/render/slack/markdown_content.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIrE,OAAO,EAEL,KAAK,UAAU,EAOhB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown_content.d.ts","sourceRoot":"","sources":["../../../src/render/slack/markdown_content.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIrE,OAAO,EAEL,KAAK,UAAU,EAOhB,MAAM,UAAU,CAAC;AAoelB;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,SAAS,eAAe,KACvB,UAAU,EAKV,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,UAAU,EAC1B,CAAC"}
|
|
@@ -107,7 +107,8 @@ const unquoted = (node) => node.type === 'blockquote' ? node.children.flatMap(un
|
|
|
107
107
|
// nested list follows at the next indent; any other block, such as a table,
|
|
108
108
|
// follows on its own; what the item holds after either follows unbulleted,
|
|
109
109
|
// since a Slack list item cannot resume; and the list resumes at its next
|
|
110
|
-
// number.
|
|
110
|
+
// number. An empty item keeps its number, so the list resumes past it. A task
|
|
111
|
+
// item's first line leads with its box.
|
|
111
112
|
const listPieces = (list, indent) => {
|
|
112
113
|
const style = list.ordered ? 'ordered' : 'bullet';
|
|
113
114
|
const out = [];
|
|
@@ -167,6 +168,11 @@ const listPieces = (list, indent) => {
|
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
emit();
|
|
171
|
+
if (item.children.length === 0) {
|
|
172
|
+
flush();
|
|
173
|
+
number += 1;
|
|
174
|
+
offset = number - 1;
|
|
175
|
+
}
|
|
170
176
|
}
|
|
171
177
|
flush();
|
|
172
178
|
return out;
|