@dxos/markdown 0.0.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/LICENSE +105 -0
- package/README.md +12 -0
- package/dist/lib/browser/index.mjs +51 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/node-esm/index.mjs +53 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/markdown.d.ts +11 -0
- package/dist/types/src/markdown.d.ts.map +1 -0
- package/dist/types/src/markdown.test.d.ts +2 -0
- package/dist/types/src/markdown.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +38 -0
- package/src/index.ts +5 -0
- package/src/markdown.test.ts +188 -0
- package/src/markdown.ts +113 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @dxos/markdown
|
|
2
|
+
|
|
3
|
+
HTML to Markdown conversion and text normalization utilities.
|
|
4
|
+
|
|
5
|
+
## Example
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { normalizeText } from '@dxos/markdown';
|
|
9
|
+
|
|
10
|
+
const markdown = normalizeText('<p>Hello <strong>world</strong></p>');
|
|
11
|
+
// "Hello **world**"
|
|
12
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/markdown.ts
|
|
2
|
+
import { parseHTML } from "linkedom";
|
|
3
|
+
import TurndownService from "turndown";
|
|
4
|
+
var turndown = new TurndownService({
|
|
5
|
+
bulletListMarker: "-"
|
|
6
|
+
}).remove("script").remove("style").addRule("cleanListSpacing", {
|
|
7
|
+
filter: "li",
|
|
8
|
+
replacement: (content, node, options) => {
|
|
9
|
+
content = content.replace(/\n{2,}/g, "\n").trim();
|
|
10
|
+
const parent = node.parentNode;
|
|
11
|
+
const isOrdered = parent && parent.nodeName === "OL";
|
|
12
|
+
if (isOrdered) {
|
|
13
|
+
const index = Array.prototype.indexOf.call(parent.children, node) + 1;
|
|
14
|
+
return `${index}. ${content}
|
|
15
|
+
`;
|
|
16
|
+
} else {
|
|
17
|
+
return `${options.bulletListMarker} ${content}
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var isHtml = (str) => {
|
|
23
|
+
return /<(\/?(p|div|span|ul|ol|li|a|strong|em|br|table|tr|td|h[1-6]))\b[^>]*>/i.test(str);
|
|
24
|
+
};
|
|
25
|
+
var preprocessHtml = (html) => {
|
|
26
|
+
const wrappedHtml = html.trim().startsWith("<html") ? html : `<html><body>${html}</body></html>`;
|
|
27
|
+
return wrappedHtml;
|
|
28
|
+
};
|
|
29
|
+
var htmlToMarkdown = (html) => turndown.turndown(parseHTML(preprocessHtml(html), {}).document.body);
|
|
30
|
+
var stripResidualTags = (str, { fromHtml = false } = {}) => {
|
|
31
|
+
const cleaned = str.replace(/<!--\s*\[if[^\]]*\][\s\S]*?<!\[endif\]\s*-->/gi, "").replace(/<\/?[a-zA-Z][\w-]*:[^>]*>/g, "");
|
|
32
|
+
return fromHtml ? cleaned.replace(/<\/?(span|font|u|div)\b[^>]*>/gi, "") : cleaned;
|
|
33
|
+
};
|
|
34
|
+
var stripWhitespace = (str) => {
|
|
35
|
+
const INVISIBLE = " \\t\\u00A0\\u00AD\\u034F\\u200B-\\u200D\\u2060\\uFEFF";
|
|
36
|
+
const WHITESPACE = /[ \t\u00A0]*\n[ \t\u00A0]*\n[\s\u00A0]*/g;
|
|
37
|
+
return str.trim().replace(new RegExp(`^[${INVISIBLE}]+$`, "gm"), "").replace(/^[ \t\u00A0]*[=-]{3,}[ \t\u00A0]*$/gm, "---").replace(/\\--/g, "---").replace(/^(?!---$)[^\p{L}\p{N}\n]*$/gmu, "").replace(WHITESPACE, "\n\n").replace(new RegExp(`[${INVISIBLE}]+$`, "gm"), "").replace(/^(>.*)\n\n+(?=>)/gm, "$1\n");
|
|
38
|
+
};
|
|
39
|
+
var normalizeText = (text) => {
|
|
40
|
+
const fromHtml = isHtml(text);
|
|
41
|
+
const converted = fromHtml ? htmlToMarkdown(text) : text;
|
|
42
|
+
return stripWhitespace(stripResidualTags(converted, {
|
|
43
|
+
fromHtml
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
htmlToMarkdown,
|
|
48
|
+
isHtml,
|
|
49
|
+
normalizeText
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/markdown.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { parseHTML } from 'linkedom';\nimport TurndownService from 'turndown';\n\n/**\n * https://www.npmjs.com/package/turndown\n */\nconst turndown = new TurndownService({\n bulletListMarker: '-',\n})\n .remove('script')\n .remove('style')\n .addRule('cleanListSpacing', {\n filter: 'li',\n replacement: (content, node, options) => {\n content = content.replace(/\\n{2,}/g, '\\n').trim();\n const parent = node.parentNode;\n const isOrdered = parent && parent.nodeName === 'OL';\n if (isOrdered) {\n // Find the item index for ordered lists.\n const index = Array.prototype.indexOf.call(parent.children, node) + 1;\n return `${index}. ${content}\\n`;\n } else {\n // Unordered list: single dash + single space.\n return `${options.bulletListMarker} ${content}\\n`;\n }\n },\n });\n\n/** Heuristically detect whether a string contains HTML markup. */\nexport const isHtml = (str: string): boolean => {\n return /<(\\/?(p|div|span|ul|ol|li|a|strong|em|br|table|tr|td|h[1-6]))\\b[^>]*>/i.test(str);\n};\n\nconst preprocessHtml = (html: string): string => {\n // Ensure HTML has proper structure for linkedom parsing.\n // If the HTML is a fragment without html/body tags, wrap it.\n const wrappedHtml = html.trim().startsWith('<html') ? html : `<html><body>${html}</body></html>`;\n return wrappedHtml;\n};\n\n/** Convert an HTML string to Markdown. */\nexport const htmlToMarkdown = (html: string): string =>\n turndown.turndown(parseHTML(preprocessHtml(html), {}).document.body);\n\n/**\n * Strip residual HTML/XML tags that survive turndown conversion (e.g., MS Office namespaced\n * tags like <o:p>, <v:shape>, conditional comments, stray <span style=...>).\n *\n * Namespaced tags and MS conditional comments are stripped unconditionally — they have no\n * meaning in genuine plaintext bodies. The generic inline-tag pass (<span>, <font>, <u>,\n * <div>) is opt-in via `fromHtml` so we don't eat literal angle-bracketed text in plaintext\n * messages.\n */\nconst stripResidualTags = (str: string, { fromHtml = false }: { fromHtml?: boolean } = {}): string => {\n const cleaned = str\n // 1. Conditional comments: <!--[if mso]>...<![endif]-->.\n .replace(/<!--\\s*\\[if[^\\]]*\\][\\s\\S]*?<!\\[endif\\]\\s*-->/gi, '')\n // 2. Namespaced tags (<o:p>, <v:shape>, <w:WordDocument/>, <m:mathPr>, etc.).\n .replace(/<\\/?[a-zA-Z][\\w-]*:[^>]*>/g, '');\n\n // 3. Stray known-bad inline tags that survive turndown in edge cases — HTML pipeline only.\n return fromHtml ? cleaned.replace(/<\\/?(span|font|u|div)\\b[^>]*>/gi, '') : cleaned;\n};\n\nconst stripWhitespace = (str: string): string => {\n // Invisible/whitespace characters that newsletters use to pad preview text:\n // soft hyphen (U+00AD), combining grapheme joiner (U+034F), zero-width\n // space/non-joiner/joiner (U+200B-U+200D), word joiner (U+2060), and BOM/\n // ZWNBSP (U+FEFF), plus regular space, tab, and NBSP.\n const INVISIBLE = ' \\\\t\\\\u00A0\\\\u00AD\\\\u034F\\\\u200B-\\\\u200D\\\\u2060\\\\uFEFF';\n const WHITESPACE = /[ \\t\\u00A0]*\\n[ \\t\\u00A0]*\\n[\\s\\u00A0]*/g;\n return (\n str\n .trim()\n // Blank out lines that contain only invisible/whitespace characters (newsletter padding).\n .replace(new RegExp(`^[${INVISIBLE}]+$`, 'gm'), '')\n // Convert setext-underline / horizontal-rule lines (3+ `=` or `-`) to a markdown HR.\n .replace(/^[ \\t\\u00A0]*[=-]{3,}[ \\t\\u00A0]*$/gm, '---')\n // Replace old-school sign-off dash with horizontal rule.\n .replace(/\\\\--/g, '---')\n // Blank out lines that contain no letter or digit (e.g., junk separators like `*****`, `,,,,`).\n // Uses Unicode property escapes so non-Latin scripts (Cyrillic, CJK, etc.) are preserved.\n // Empty lines are preserved as paragraph breaks; the `---` HR we just inserted is exempted so it survives.\n .replace(/^(?!---$)[^\\p{L}\\p{N}\\n]*$/gmu, '')\n // Replace multiple newlines with double newlines.\n .replace(WHITESPACE, '\\n\\n')\n // Trim trailing whitespace \\u2014 including the invisible/zero-width chars (soft hyphen, zero-width\n // space/joiners, word joiner, ZWNBSP) that `.trim()` and the visible-whitespace set miss \\u2014 from\n // every line.\n .replace(new RegExp(`[${INVISIBLE}]+$`, 'gm'), '')\n // Keep a quoted block contiguous: drop blank lines between consecutive quoted (`>`) lines.\n // Turndown prefixes every blockquote line with `> `, so paragraph breaks within a quote\n // surface as a bare `> ` line that the no-letter pass above blanks; this rejoins them (and\n // also collapses blank-separated quotes in plaintext bodies).\n .replace(/^(>.*)\\n\\n+(?=>)/gm, '$1\\n')\n );\n};\n\n/**\n * Normalize arbitrary text (HTML or plaintext) into clean Markdown. HTML input is converted to\n * Markdown; plaintext is passed through. In both cases runs of blank lines are collapsed so the\n * rendered result never shows more than one blank line between paragraphs.\n */\n// TODO(burdon): Replace legal disclaimers, etc.\nexport const normalizeText = (text: string): string => {\n const fromHtml = isHtml(text);\n const converted = fromHtml ? htmlToMarkdown(text) : text;\n return stripWhitespace(stripResidualTags(converted, { fromHtml }));\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,iBAAiB;AAC1B,OAAOC,qBAAqB;AAK5B,IAAMC,WAAW,IAAID,gBAAgB;EACnCE,kBAAkB;AACpB,CAAA,EACGC,OAAO,QAAA,EACPA,OAAO,OAAA,EACPC,QAAQ,oBAAoB;EAC3BC,QAAQ;EACRC,aAAa,CAACC,SAASC,MAAMC,YAAAA;AAC3BF,cAAUA,QAAQG,QAAQ,WAAW,IAAA,EAAMC,KAAI;AAC/C,UAAMC,SAASJ,KAAKK;AACpB,UAAMC,YAAYF,UAAUA,OAAOG,aAAa;AAChD,QAAID,WAAW;AAEb,YAAME,QAAQC,MAAMC,UAAUC,QAAQC,KAAKR,OAAOS,UAAUb,IAAAA,IAAQ;AACpE,aAAO,GAAGQ,KAAAA,KAAUT,OAAAA;;IACtB,OAAO;AAEL,aAAO,GAAGE,QAAQP,gBAAgB,IAAIK,OAAAA;;IACxC;EACF;AACF,CAAA;AAGK,IAAMe,SAAS,CAACC,QAAAA;AACrB,SAAO,yEAAyEC,KAAKD,GAAAA;AACvF;AAEA,IAAME,iBAAiB,CAACC,SAAAA;AAGtB,QAAMC,cAAcD,KAAKf,KAAI,EAAGiB,WAAW,OAAA,IAAWF,OAAO,eAAeA,IAAAA;AAC5E,SAAOC;AACT;AAGO,IAAME,iBAAiB,CAACH,SAC7BzB,SAASA,SAASF,UAAU0B,eAAeC,IAAAA,GAAO,CAAC,CAAA,EAAGI,SAASC,IAAI;AAWrE,IAAMC,oBAAoB,CAACT,KAAa,EAAEU,WAAW,MAAK,IAA6B,CAAC,MAAC;AACvF,QAAMC,UAAUX,IAEbb,QAAQ,kDAAkD,EAAA,EAE1DA,QAAQ,8BAA8B,EAAA;AAGzC,SAAOuB,WAAWC,QAAQxB,QAAQ,mCAAmC,EAAA,IAAMwB;AAC7E;AAEA,IAAMC,kBAAkB,CAACZ,QAAAA;AAKvB,QAAMa,YAAY;AAClB,QAAMC,aAAa;AACnB,SACEd,IACGZ,KAAI,EAEJD,QAAQ,IAAI4B,OAAO,KAAKF,SAAAA,OAAgB,IAAA,GAAO,EAAA,EAE/C1B,QAAQ,wCAAwC,KAAA,EAEhDA,QAAQ,SAAS,KAAA,EAIjBA,QAAQ,iCAAiC,EAAA,EAEzCA,QAAQ2B,YAAY,MAAA,EAIpB3B,QAAQ,IAAI4B,OAAO,IAAIF,SAAAA,OAAgB,IAAA,GAAO,EAAA,EAK9C1B,QAAQ,sBAAsB,MAAA;AAErC;AAQO,IAAM6B,gBAAgB,CAACC,SAAAA;AAC5B,QAAMP,WAAWX,OAAOkB,IAAAA;AACxB,QAAMC,YAAYR,WAAWJ,eAAeW,IAAAA,IAAQA;AACpD,SAAOL,gBAAgBH,kBAAkBS,WAAW;IAAER;EAAS,CAAA,CAAA;AACjE;",
|
|
6
|
+
"names": ["parseHTML", "TurndownService", "turndown", "bulletListMarker", "remove", "addRule", "filter", "replacement", "content", "node", "options", "replace", "trim", "parent", "parentNode", "isOrdered", "nodeName", "index", "Array", "prototype", "indexOf", "call", "children", "isHtml", "str", "test", "preprocessHtml", "html", "wrappedHtml", "startsWith", "htmlToMarkdown", "document", "body", "stripResidualTags", "fromHtml", "cleaned", "stripWhitespace", "INVISIBLE", "WHITESPACE", "RegExp", "normalizeText", "text", "converted"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/markdown.ts":{"bytes":15667,"imports":[{"path":"linkedom","kind":"import-statement","external":true},{"path":"turndown","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":376,"imports":[{"path":"src/markdown.ts","kind":"import-statement","original":"./markdown"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7481},"dist/lib/browser/index.mjs":{"imports":[{"path":"linkedom","kind":"import-statement","external":true},{"path":"turndown","kind":"import-statement","external":true}],"exports":["htmlToMarkdown","isHtml","normalizeText"],"entryPoint":"src/index.ts","inputs":{"src/markdown.ts":{"bytesInOutput":1986},"src/index.ts":{"bytesInOutput":0}},"bytes":2096}}}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/markdown.ts
|
|
4
|
+
import { parseHTML } from "linkedom";
|
|
5
|
+
import TurndownService from "turndown";
|
|
6
|
+
var turndown = new TurndownService({
|
|
7
|
+
bulletListMarker: "-"
|
|
8
|
+
}).remove("script").remove("style").addRule("cleanListSpacing", {
|
|
9
|
+
filter: "li",
|
|
10
|
+
replacement: (content, node, options) => {
|
|
11
|
+
content = content.replace(/\n{2,}/g, "\n").trim();
|
|
12
|
+
const parent = node.parentNode;
|
|
13
|
+
const isOrdered = parent && parent.nodeName === "OL";
|
|
14
|
+
if (isOrdered) {
|
|
15
|
+
const index = Array.prototype.indexOf.call(parent.children, node) + 1;
|
|
16
|
+
return `${index}. ${content}
|
|
17
|
+
`;
|
|
18
|
+
} else {
|
|
19
|
+
return `${options.bulletListMarker} ${content}
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var isHtml = (str) => {
|
|
25
|
+
return /<(\/?(p|div|span|ul|ol|li|a|strong|em|br|table|tr|td|h[1-6]))\b[^>]*>/i.test(str);
|
|
26
|
+
};
|
|
27
|
+
var preprocessHtml = (html) => {
|
|
28
|
+
const wrappedHtml = html.trim().startsWith("<html") ? html : `<html><body>${html}</body></html>`;
|
|
29
|
+
return wrappedHtml;
|
|
30
|
+
};
|
|
31
|
+
var htmlToMarkdown = (html) => turndown.turndown(parseHTML(preprocessHtml(html), {}).document.body);
|
|
32
|
+
var stripResidualTags = (str, { fromHtml = false } = {}) => {
|
|
33
|
+
const cleaned = str.replace(/<!--\s*\[if[^\]]*\][\s\S]*?<!\[endif\]\s*-->/gi, "").replace(/<\/?[a-zA-Z][\w-]*:[^>]*>/g, "");
|
|
34
|
+
return fromHtml ? cleaned.replace(/<\/?(span|font|u|div)\b[^>]*>/gi, "") : cleaned;
|
|
35
|
+
};
|
|
36
|
+
var stripWhitespace = (str) => {
|
|
37
|
+
const INVISIBLE = " \\t\\u00A0\\u00AD\\u034F\\u200B-\\u200D\\u2060\\uFEFF";
|
|
38
|
+
const WHITESPACE = /[ \t\u00A0]*\n[ \t\u00A0]*\n[\s\u00A0]*/g;
|
|
39
|
+
return str.trim().replace(new RegExp(`^[${INVISIBLE}]+$`, "gm"), "").replace(/^[ \t\u00A0]*[=-]{3,}[ \t\u00A0]*$/gm, "---").replace(/\\--/g, "---").replace(/^(?!---$)[^\p{L}\p{N}\n]*$/gmu, "").replace(WHITESPACE, "\n\n").replace(new RegExp(`[${INVISIBLE}]+$`, "gm"), "").replace(/^(>.*)\n\n+(?=>)/gm, "$1\n");
|
|
40
|
+
};
|
|
41
|
+
var normalizeText = (text) => {
|
|
42
|
+
const fromHtml = isHtml(text);
|
|
43
|
+
const converted = fromHtml ? htmlToMarkdown(text) : text;
|
|
44
|
+
return stripWhitespace(stripResidualTags(converted, {
|
|
45
|
+
fromHtml
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
htmlToMarkdown,
|
|
50
|
+
isHtml,
|
|
51
|
+
normalizeText
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/markdown.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { parseHTML } from 'linkedom';\nimport TurndownService from 'turndown';\n\n/**\n * https://www.npmjs.com/package/turndown\n */\nconst turndown = new TurndownService({\n bulletListMarker: '-',\n})\n .remove('script')\n .remove('style')\n .addRule('cleanListSpacing', {\n filter: 'li',\n replacement: (content, node, options) => {\n content = content.replace(/\\n{2,}/g, '\\n').trim();\n const parent = node.parentNode;\n const isOrdered = parent && parent.nodeName === 'OL';\n if (isOrdered) {\n // Find the item index for ordered lists.\n const index = Array.prototype.indexOf.call(parent.children, node) + 1;\n return `${index}. ${content}\\n`;\n } else {\n // Unordered list: single dash + single space.\n return `${options.bulletListMarker} ${content}\\n`;\n }\n },\n });\n\n/** Heuristically detect whether a string contains HTML markup. */\nexport const isHtml = (str: string): boolean => {\n return /<(\\/?(p|div|span|ul|ol|li|a|strong|em|br|table|tr|td|h[1-6]))\\b[^>]*>/i.test(str);\n};\n\nconst preprocessHtml = (html: string): string => {\n // Ensure HTML has proper structure for linkedom parsing.\n // If the HTML is a fragment without html/body tags, wrap it.\n const wrappedHtml = html.trim().startsWith('<html') ? html : `<html><body>${html}</body></html>`;\n return wrappedHtml;\n};\n\n/** Convert an HTML string to Markdown. */\nexport const htmlToMarkdown = (html: string): string =>\n turndown.turndown(parseHTML(preprocessHtml(html), {}).document.body);\n\n/**\n * Strip residual HTML/XML tags that survive turndown conversion (e.g., MS Office namespaced\n * tags like <o:p>, <v:shape>, conditional comments, stray <span style=...>).\n *\n * Namespaced tags and MS conditional comments are stripped unconditionally — they have no\n * meaning in genuine plaintext bodies. The generic inline-tag pass (<span>, <font>, <u>,\n * <div>) is opt-in via `fromHtml` so we don't eat literal angle-bracketed text in plaintext\n * messages.\n */\nconst stripResidualTags = (str: string, { fromHtml = false }: { fromHtml?: boolean } = {}): string => {\n const cleaned = str\n // 1. Conditional comments: <!--[if mso]>...<![endif]-->.\n .replace(/<!--\\s*\\[if[^\\]]*\\][\\s\\S]*?<!\\[endif\\]\\s*-->/gi, '')\n // 2. Namespaced tags (<o:p>, <v:shape>, <w:WordDocument/>, <m:mathPr>, etc.).\n .replace(/<\\/?[a-zA-Z][\\w-]*:[^>]*>/g, '');\n\n // 3. Stray known-bad inline tags that survive turndown in edge cases — HTML pipeline only.\n return fromHtml ? cleaned.replace(/<\\/?(span|font|u|div)\\b[^>]*>/gi, '') : cleaned;\n};\n\nconst stripWhitespace = (str: string): string => {\n // Invisible/whitespace characters that newsletters use to pad preview text:\n // soft hyphen (U+00AD), combining grapheme joiner (U+034F), zero-width\n // space/non-joiner/joiner (U+200B-U+200D), word joiner (U+2060), and BOM/\n // ZWNBSP (U+FEFF), plus regular space, tab, and NBSP.\n const INVISIBLE = ' \\\\t\\\\u00A0\\\\u00AD\\\\u034F\\\\u200B-\\\\u200D\\\\u2060\\\\uFEFF';\n const WHITESPACE = /[ \\t\\u00A0]*\\n[ \\t\\u00A0]*\\n[\\s\\u00A0]*/g;\n return (\n str\n .trim()\n // Blank out lines that contain only invisible/whitespace characters (newsletter padding).\n .replace(new RegExp(`^[${INVISIBLE}]+$`, 'gm'), '')\n // Convert setext-underline / horizontal-rule lines (3+ `=` or `-`) to a markdown HR.\n .replace(/^[ \\t\\u00A0]*[=-]{3,}[ \\t\\u00A0]*$/gm, '---')\n // Replace old-school sign-off dash with horizontal rule.\n .replace(/\\\\--/g, '---')\n // Blank out lines that contain no letter or digit (e.g., junk separators like `*****`, `,,,,`).\n // Uses Unicode property escapes so non-Latin scripts (Cyrillic, CJK, etc.) are preserved.\n // Empty lines are preserved as paragraph breaks; the `---` HR we just inserted is exempted so it survives.\n .replace(/^(?!---$)[^\\p{L}\\p{N}\\n]*$/gmu, '')\n // Replace multiple newlines with double newlines.\n .replace(WHITESPACE, '\\n\\n')\n // Trim trailing whitespace \\u2014 including the invisible/zero-width chars (soft hyphen, zero-width\n // space/joiners, word joiner, ZWNBSP) that `.trim()` and the visible-whitespace set miss \\u2014 from\n // every line.\n .replace(new RegExp(`[${INVISIBLE}]+$`, 'gm'), '')\n // Keep a quoted block contiguous: drop blank lines between consecutive quoted (`>`) lines.\n // Turndown prefixes every blockquote line with `> `, so paragraph breaks within a quote\n // surface as a bare `> ` line that the no-letter pass above blanks; this rejoins them (and\n // also collapses blank-separated quotes in plaintext bodies).\n .replace(/^(>.*)\\n\\n+(?=>)/gm, '$1\\n')\n );\n};\n\n/**\n * Normalize arbitrary text (HTML or plaintext) into clean Markdown. HTML input is converted to\n * Markdown; plaintext is passed through. In both cases runs of blank lines are collapsed so the\n * rendered result never shows more than one blank line between paragraphs.\n */\n// TODO(burdon): Replace legal disclaimers, etc.\nexport const normalizeText = (text: string): string => {\n const fromHtml = isHtml(text);\n const converted = fromHtml ? htmlToMarkdown(text) : text;\n return stripWhitespace(stripResidualTags(converted, { fromHtml }));\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,iBAAiB;AAC1B,OAAOC,qBAAqB;AAK5B,IAAMC,WAAW,IAAID,gBAAgB;EACnCE,kBAAkB;AACpB,CAAA,EACGC,OAAO,QAAA,EACPA,OAAO,OAAA,EACPC,QAAQ,oBAAoB;EAC3BC,QAAQ;EACRC,aAAa,CAACC,SAASC,MAAMC,YAAAA;AAC3BF,cAAUA,QAAQG,QAAQ,WAAW,IAAA,EAAMC,KAAI;AAC/C,UAAMC,SAASJ,KAAKK;AACpB,UAAMC,YAAYF,UAAUA,OAAOG,aAAa;AAChD,QAAID,WAAW;AAEb,YAAME,QAAQC,MAAMC,UAAUC,QAAQC,KAAKR,OAAOS,UAAUb,IAAAA,IAAQ;AACpE,aAAO,GAAGQ,KAAAA,KAAUT,OAAAA;;IACtB,OAAO;AAEL,aAAO,GAAGE,QAAQP,gBAAgB,IAAIK,OAAAA;;IACxC;EACF;AACF,CAAA;AAGK,IAAMe,SAAS,CAACC,QAAAA;AACrB,SAAO,yEAAyEC,KAAKD,GAAAA;AACvF;AAEA,IAAME,iBAAiB,CAACC,SAAAA;AAGtB,QAAMC,cAAcD,KAAKf,KAAI,EAAGiB,WAAW,OAAA,IAAWF,OAAO,eAAeA,IAAAA;AAC5E,SAAOC;AACT;AAGO,IAAME,iBAAiB,CAACH,SAC7BzB,SAASA,SAASF,UAAU0B,eAAeC,IAAAA,GAAO,CAAC,CAAA,EAAGI,SAASC,IAAI;AAWrE,IAAMC,oBAAoB,CAACT,KAAa,EAAEU,WAAW,MAAK,IAA6B,CAAC,MAAC;AACvF,QAAMC,UAAUX,IAEbb,QAAQ,kDAAkD,EAAA,EAE1DA,QAAQ,8BAA8B,EAAA;AAGzC,SAAOuB,WAAWC,QAAQxB,QAAQ,mCAAmC,EAAA,IAAMwB;AAC7E;AAEA,IAAMC,kBAAkB,CAACZ,QAAAA;AAKvB,QAAMa,YAAY;AAClB,QAAMC,aAAa;AACnB,SACEd,IACGZ,KAAI,EAEJD,QAAQ,IAAI4B,OAAO,KAAKF,SAAAA,OAAgB,IAAA,GAAO,EAAA,EAE/C1B,QAAQ,wCAAwC,KAAA,EAEhDA,QAAQ,SAAS,KAAA,EAIjBA,QAAQ,iCAAiC,EAAA,EAEzCA,QAAQ2B,YAAY,MAAA,EAIpB3B,QAAQ,IAAI4B,OAAO,IAAIF,SAAAA,OAAgB,IAAA,GAAO,EAAA,EAK9C1B,QAAQ,sBAAsB,MAAA;AAErC;AAQO,IAAM6B,gBAAgB,CAACC,SAAAA;AAC5B,QAAMP,WAAWX,OAAOkB,IAAAA;AACxB,QAAMC,YAAYR,WAAWJ,eAAeW,IAAAA,IAAQA;AACpD,SAAOL,gBAAgBH,kBAAkBS,WAAW;IAAER;EAAS,CAAA,CAAA;AACjE;",
|
|
6
|
+
"names": ["parseHTML", "TurndownService", "turndown", "bulletListMarker", "remove", "addRule", "filter", "replacement", "content", "node", "options", "replace", "trim", "parent", "parentNode", "isOrdered", "nodeName", "index", "Array", "prototype", "indexOf", "call", "children", "isHtml", "str", "test", "preprocessHtml", "html", "wrappedHtml", "startsWith", "htmlToMarkdown", "document", "body", "stripResidualTags", "fromHtml", "cleaned", "stripWhitespace", "INVISIBLE", "WHITESPACE", "RegExp", "normalizeText", "text", "converted"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/markdown.ts":{"bytes":15667,"imports":[{"path":"linkedom","kind":"import-statement","external":true},{"path":"turndown","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":376,"imports":[{"path":"src/markdown.ts","kind":"import-statement","original":"./markdown"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7483},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"linkedom","kind":"import-statement","external":true},{"path":"turndown","kind":"import-statement","external":true}],"exports":["htmlToMarkdown","isHtml","normalizeText"],"entryPoint":"src/index.ts","inputs":{"src/markdown.ts":{"bytesInOutput":1986},"src/index.ts":{"bytesInOutput":0}},"bytes":2189}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Heuristically detect whether a string contains HTML markup. */
|
|
2
|
+
export declare const isHtml: (str: string) => boolean;
|
|
3
|
+
/** Convert an HTML string to Markdown. */
|
|
4
|
+
export declare const htmlToMarkdown: (html: string) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Normalize arbitrary text (HTML or plaintext) into clean Markdown. HTML input is converted to
|
|
7
|
+
* Markdown; plaintext is passed through. In both cases runs of blank lines are collapsed so the
|
|
8
|
+
* rendered result never shows more than one blank line between paragraphs.
|
|
9
|
+
*/
|
|
10
|
+
export declare const normalizeText: (text: string) => string;
|
|
11
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/markdown.ts"],"names":[],"mappings":"AAgCA,kEAAkE;AAClE,eAAO,MAAM,MAAM,QAAS,MAAM,KAAG,OAEpC,CAAC;AASF,0CAA0C;AAC1C,eAAO,MAAM,cAAc,SAAU,MAAM,KAAG,MACwB,CAAC;AAwDvE;;;;GAIG;AAEH,eAAO,MAAM,aAAa,SAAU,MAAM,KAAG,MAI5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.test.d.ts","sourceRoot":"","sources":["../../../src/markdown.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"7.0.0-dev.20260421.2","root":[[190,191],240],"fileNames":["lib.es5.d.ts","lib.es2015.d.ts","lib.es2016.d.ts","lib.es2017.d.ts","lib.es2018.d.ts","lib.es2019.d.ts","lib.es2020.d.ts","lib.es2021.d.ts","lib.es2022.d.ts","lib.es2023.d.ts","lib.es2024.d.ts","lib.es2025.d.ts","lib.esnext.d.ts","lib.dom.d.ts","lib.es2015.core.d.ts","lib.es2015.collection.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.intl.d.ts","lib.es2017.arraybuffer.d.ts","lib.es2017.date.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.intl.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2019.intl.d.ts","lib.es2020.bigint.d.ts","lib.es2020.date.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2021.intl.d.ts","lib.es2022.array.d.ts","lib.es2022.error.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.string.d.ts","lib.es2022.regexp.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.intl.d.ts","lib.es2024.arraybuffer.d.ts","lib.es2024.collection.d.ts","lib.es2024.object.d.ts","lib.es2024.promise.d.ts","lib.es2024.regexp.d.ts","lib.es2024.sharedmemory.d.ts","lib.es2024.string.d.ts","lib.es2025.collection.d.ts","lib.es2025.float16.d.ts","lib.es2025.intl.d.ts","lib.es2025.iterator.d.ts","lib.es2025.promise.d.ts","lib.es2025.regexp.d.ts","lib.esnext.array.d.ts","lib.esnext.collection.d.ts","lib.esnext.date.d.ts","lib.esnext.decorators.d.ts","lib.esnext.disposable.d.ts","lib.esnext.error.d.ts","lib.esnext.intl.d.ts","lib.esnext.sharedmemory.d.ts","lib.esnext.temporal.d.ts","lib.esnext.typedarrays.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/shared/facades.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/event-target.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/node-list.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/shared/symbols.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/node.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/shared/constants.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/mixin/parent-node.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/mixin/non-element-parent-node.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/shadow-root.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/template-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/html-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/text-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/script-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/frame-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/i-frame-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/object-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/head-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/body-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/style-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/time-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/field-set-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/embed-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/hr-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/progress-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/paragraph-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/table-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/frame-set-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/li-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/base-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/data-list-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/input-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/param-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/media-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/audio-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/heading-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/directory-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/quote-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/canvas-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/legend-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/option-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/span-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/meter-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/video-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/table-cell-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/title-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/output-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/table-row-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/data-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/menu-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/select-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/br-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/button-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/map-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/opt-group-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/d-list-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/text-area-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/font-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/div-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/link-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/slot-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/form-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/image-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/pre-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/u-list-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/meta-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/picture-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/area-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/o-list-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/table-caption-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/anchor-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/label-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/unknown-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/mod-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/details-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/source-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/track-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/marquee-element.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/shared/html-classes.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/event.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/custom-event.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/input-event.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/node-filter.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/document-type.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/attr.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/character-data.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/cdata-section.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/comment.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/document-fragment.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/range.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/text.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/tree-walker.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/interface/document.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/html/document.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/svg/document.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/xml/document.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/dom/parser.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/shared/parse-json.d.ts","../../../../../node_modules/.pnpm/linkedom@0.18.12_canvas@3.2.0/node_modules/linkedom/types/esm/index.d.ts","../../../../../node_modules/.pnpm/@types+turndown@5.0.5/node_modules/@types/turndown/index.d.ts","../../src/markdown.ts","../../src/index.ts","../../../../../node_modules/.pnpm/@vitest+pretty-format@4.1.7/node_modules/@vitest/pretty-format/dist/index.d.ts","../../../../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/display.d.ts","../../../../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/types.d.ts","../../../../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/helpers.d.ts","../../../../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/timers.d.ts","../../../../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/index.d.ts","../../../../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/types.d-bcelap-c.d.ts","../../../../../node_modules/.pnpm/@vitest+utils@4.1.7/node_modules/@vitest/utils/dist/diff.d.ts","../../../../../node_modules/.pnpm/@vitest+runner@4.1.7/node_modules/@vitest/runner/dist/tasks.d-deyaimiu.d.ts","../../../../../node_modules/.pnpm/@vitest+runner@4.1.7/node_modules/@vitest/runner/dist/index.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/traces.d.d2t_r8rx.d.ts","../../../../../node_modules/.pnpm/vite@8.0.10_@types+node@22.10.2_esbuild@0.28.0_jiti@2.6.1_terser@5.46.0_tsx@4.21.0_yaml@2.8.2/node_modules/vite/types/hmrpayload.d.ts","../../../../../node_modules/.pnpm/vite@8.0.10_@types+node@22.10.2_esbuild@0.28.0_jiti@2.6.1_terser@5.46.0_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/chunks/modulerunnertransport.d.ts","../../../../../node_modules/.pnpm/vite@8.0.10_@types+node@22.10.2_esbuild@0.28.0_jiti@2.6.1_terser@5.46.0_tsx@4.21.0_yaml@2.8.2/node_modules/vite/types/customevent.d.ts","../../../../../node_modules/.pnpm/vite@8.0.10_@types+node@22.10.2_esbuild@0.28.0_jiti@2.6.1_terser@5.46.0_tsx@4.21.0_yaml@2.8.2/node_modules/vite/types/hot.d.ts","../../../../../node_modules/.pnpm/vite@8.0.10_@types+node@22.10.2_esbuild@0.28.0_jiti@2.6.1_terser@5.46.0_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/module-runner.d.ts","../../../../../node_modules/.pnpm/@vitest+snapshot@4.1.7/node_modules/@vitest/snapshot/dist/environment.d-dojxxzv9.d.ts","../../../../../node_modules/.pnpm/@vitest+snapshot@4.1.7/node_modules/@vitest/snapshot/dist/rawsnapshot.d-d_x3-62x.d.ts","../../../../../node_modules/.pnpm/@vitest+snapshot@4.1.7/node_modules/@vitest/snapshot/dist/index.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/config.d.a1h_y6jt.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/environment.d.crsxczp1.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/rpc.d.b_8spu0w.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/worker.d.zphpo4yb.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/browser.d.bcoexmfg.d.ts","../../../../../node_modules/.pnpm/@vitest+spy@4.1.7/node_modules/@vitest/spy/optional-types.d.ts","../../../../../node_modules/.pnpm/@vitest+spy@4.1.7/node_modules/@vitest/spy/dist/index.d.ts","../../../../../node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.d.ts","../../../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts","../../../../../node_modules/.pnpm/@types+deep-eql@4.0.2/node_modules/@types/deep-eql/index.d.ts","../../../../../node_modules/.pnpm/@types+chai@5.2.2/node_modules/@types/chai/index.d.ts","../../../../../node_modules/.pnpm/@vitest+expect@4.1.7/node_modules/@vitest/expect/dist/index.d.ts","../../../../../node_modules/.pnpm/@vitest+runner@4.1.7/node_modules/@vitest/runner/dist/utils.d.ts","../../../../../node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/benchmark.d.daahlpsq.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/global.d.dvssrdq5.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/optional-runtime-types.d.ts","../../../../../node_modules/.pnpm/@vitest+mocker@4.1.7_vite@8.0.10_@types+node@22.10.2_esbuild@0.28.0_jiti@2.6.1_terser@5.46.0_tsx@4.21.0_yaml@2.8.2_/node_modules/@vitest/mocker/dist/types.d-bji5eawu.d.ts","../../../../../node_modules/.pnpm/@vitest+mocker@4.1.7_vite@8.0.10_@types+node@22.10.2_esbuild@0.28.0_jiti@2.6.1_terser@5.46.0_tsx@4.21.0_yaml@2.8.2_/node_modules/@vitest/mocker/dist/index.d-b41z0auw.d.ts","../../../../../node_modules/.pnpm/@vitest+mocker@4.1.7_vite@8.0.10_@types+node@22.10.2_esbuild@0.28.0_jiti@2.6.1_terser@5.46.0_tsx@4.21.0_yaml@2.8.2_/node_modules/@vitest/mocker/dist/index.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/suite.d.udjtyagw.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/chunks/evaluatedmodules.d.bxj5omdx.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/runners.d.ts","../../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.d.ts","../../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.d.ts","../../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.d.ts","../../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.d.ts","../../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.d.ts","../../../../../node_modules/.pnpm/vitest@4.1.7_patch_hash=a7bf6a3d21c2bc782d60d0f0f916d76f304c0eb6fbf2827e8d981408c7b5120_f5e8822b697295853ac07de0a31a074c/node_modules/vitest/dist/index.d.ts","../../src/markdown.test.ts","../../../typings/src/dxos.d.ts","../../../typings/src/growing-file.d.ts","../../../typings/src/hypercore.d.ts","../../../typings/src/hypercore-crypto.d.ts","../../../typings/src/hypercore-protocol.d.ts","../../../typings/src/hypercore-streams.d.ts","../../../typings/src/misc.d.ts","../../../typings/src/nanoerror.d.ts","../../../typings/src/nanomessage.d.ts","../../../typings/src/nanoresource.d.ts","../../../typings/src/nanoresource-promise.d.ts","../../../typings/src/race-as-promised.d.ts","../../../typings/src/random-access-storage.d.ts","../../../typings/src/streamx.d.ts","../../../../../node_modules/.pnpm/@types+zen-observable@0.8.3/node_modules/@types/zen-observable/index.d.ts","../../../../../node_modules/.pnpm/@types+zen-observable@0.8.3/node_modules/@types/zen-observable/extras.d.ts","../../../../../node_modules/.pnpm/@types+zen-observable@0.8.3/node_modules/@types/zen-observable/esm.d.ts","../../../typings/src/zen-push.d.ts","../../../typings/src/index.d.ts"],"fileInfos":[{"version":"a1aa1a5e065d48ef5c7bb99e38412f96","affectsGlobalScope":true,"impliedNodeFormat":1},"d4306fb2e47f74835e8674ffac07d76f","e437c5c1302869326c3bb93da85bbbcf","e4324975a566567b21d350615f1fc6ac","333b1b9a2a9ac3b8497dba5c63b5ba50","6cffacd662b6eb5fa7a36aa2ea366bfa","b4c34f9c23304dbef2d23698637ed638","e5cb86a5fc491796ecd1d2dd348d208f","feb6c6fb19cdb246a5d8acb36a6901c7","9443a7f109277ffaa79d893ed2549995","793cee405385076e27c24f409659dccd","09f69c6610266eaee1ac9e3e30df2c71","62bad718844246b8e17547f37bad6085",{"version":"aae8996e8b5684814785a42cbbefcd79","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"01ac052ec4a79e87229f90466a9645f8","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"edba5df642941aa062a62f6328c6df3d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6344b55f26a4e81d9608777dbfb877dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3c0ed28e53d3695b363e256ec1c023fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4c2761daba7f17141c25baa0821ac5da","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b87656acabd63e69379ff6ffcfe52fc7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"597469522da047a5af5222cc6989f405","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bb3a710cbcda0533bb127712927cbe37","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"55d97a8c6fbf34a30450a7b1e5f7a298","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0ee05eb59426d33e374226d8dcfa708b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e347c14030993906efcfbb88915b6a05","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b0231263857c9b6a03641acdc9280ceb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3b15c4a83b598cacb4067676e6f0abed","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b417d97b7934cef63b1889abec0bbfbf","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"09a6cf4032ebba60ce22a501e663f881","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7a42de379b489e8f7b647455bebfc576","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e22cc07e3f3cc242ba52fa3f8ea1fc58","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2c45da767a1bfbb220848df1bc4029e4","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b44c3e0fbaf2130cdcf6ac38b120ffa1","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b612fb5cf8e5d964b92063a75207632a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"02705151a5e1551b9162a9ed8ab763f7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"41025e398be9215d32e4337335da8f0b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"52684c2b1f353a5538e4f275182a54cd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6dedb6a4f90d1df3a6fbe5693e44886c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ca3f36fe3562c07e0f0d71c2bebd3f6d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"409974d6129befbb8226ddd1c6558568","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4d9cfde2a1ae1b4925f1f9bc10848e5d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7e1daecc66dd564144e3bb1a0266b5fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a8e1d9bb35fd0637f2f9fd2b2a54f2ec","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4f168501772a6543182765bfd5f2fbfe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19c80aad1b2162103496f5ba293a732","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b69afa63cd5d059851c78adb2856ee09","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ae2fc5d954e9b0f5feee3d481b953c27","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1cfd3091a071d8b6feec15277643bafe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"692bcd75364db0f65d428801c7884466","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a0d87491913d843139e0c993650a3235","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4ef72aa378127e7b7abba915b0110b1e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3ec74c6a7d4463f0254db3a74cf75646","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"84c2bdfa470d075526cce6322d81b0b6","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0b3844c2b8c73e4e1ab91431411cad11","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4fc71cf4a15b8d99675a31df77f26e07","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d1b49564ddaeca3df5b6dbae925d2242","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6a25be566d60ccfc2d6e8b7bfdeefa83","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8a20e27646985dfd58c57ca6566553dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9969f02ad3cdcbf4f709405cda44167f","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9c9be4792a7a4f42c15ae7360bf28779","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8cf777fe00349b71ee9c4b6f3fe7fd19","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"74f96bc192530c9723f572bfff3d3078","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1df91c56b25955c56387426f378173c5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"38856f70edcd2115c355d96ec77cc09e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"de8700156c1275465bcd473c28b359aa","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d47cfdb6ede40518357bb5a4cd7cd9fb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6e5773860cd9e5b15e683113f642ab47","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"30ff5fe1682f7fcd629880476ca3c2e0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf23d7d1b40b9015b694ddc2f011752f","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2cc585d42e2c548f9f24a30a1989fd33","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"713906ce9d332d2242b7f05ed9304be3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0219894bfe5042c7e1aa2d22e4a91ed0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6009ffff7e43c93318804d2d28e37fe3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"03be89b227587594fbb50509fc1c2e45","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b30df52dc24740c0bad7c55c3511df7d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ab8d3c9b5ed5c2ab8f383607eef439f0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d950ec671d0a8e07f3c1a31e94abed86","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1abef2ace5eccb02d60dd73cd5a5ee4c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f5f0a3044029d1cc081b5887eb4deb07","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d57c697f1446940ec4bfe669c962e2c4","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"be41035d7b941482a1e1ae6a5c5dcca5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"10f7d9da7564f27f8ddf4a162b6da6d3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1d0520af549e0c3581f15173cc713ca1","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d65083f97fd741cff028472563eddb79","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"da7f24f00653ebac660ac1c0821ed33d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7cb5ae9e65516ea2235f0721f6aac43c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f64453cbf9671f28158677fa5c43967a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"33f317af5428801f944a478d2c1e38e5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"74cddd5a4a23f96aabb37b5fde0a3c73","impliedNodeFormat":99},{"version":"744c09bec755b4042a60fb504f02aa5f","impliedNodeFormat":99},{"version":"2c09936f37691664c564f67b623f2d59","impliedNodeFormat":99},{"version":"be103bda1c45435e55c911fd0f2196b7","impliedNodeFormat":99},{"version":"770a07988c47fcf2249c7c51622cc90e","impliedNodeFormat":99},{"version":"0e7b41f507f874597c73335d617d2cce","impliedNodeFormat":99},{"version":"8a15f8d4d0f68458e20de7041c809355","impliedNodeFormat":99},{"version":"1e267f1d5b68821bec08fbce3234119c","impliedNodeFormat":99},{"version":"d96079d751b2fb8a468d5e37ec6f7bf0","impliedNodeFormat":99},{"version":"5d838dfbadc7a92f32d59cd418c150d6","impliedNodeFormat":99},{"version":"4088274913e92dccb784a7594b810de2","impliedNodeFormat":99},{"version":"210c52d3af32ce25da8319be90fe4d77","impliedNodeFormat":99},{"version":"9e8fec6b319ed5705a3dfc2c61b9df21","impliedNodeFormat":99},{"version":"4fa8dc6bcac3e0d42b2cb783940c02a9","impliedNodeFormat":99},{"version":"be952510d14a2686bfcf9383857bf9a4","impliedNodeFormat":99},{"version":"82d26137cb667f29dc2f8011cd28340c","impliedNodeFormat":99},{"version":"e86cdbea2fe92855ac32a25756106af4","impliedNodeFormat":99},{"version":"5240165454e79c4a8b0ddd1014cea598","impliedNodeFormat":99},{"version":"2e29625b26269b1007776e22dad46df7","impliedNodeFormat":99},{"version":"c29dd629b828204b964ee78ae8648cc0","impliedNodeFormat":99},{"version":"0fa793b3668ec870d734c7afa6c63b69","impliedNodeFormat":99},{"version":"9f7073b331d92d7d67129bca27bcda93","impliedNodeFormat":99},{"version":"1b89d3e841194f70ff853c1867cda496","impliedNodeFormat":99},{"version":"c22bc7db3c3309f4087c82bbeb11645c","impliedNodeFormat":99},{"version":"680b4b583172368e8701e75379677129","impliedNodeFormat":99},{"version":"cc4c70efdac45fb4d19584791767eecc","impliedNodeFormat":99},{"version":"545de3f2fd9a54e24922ace863bceef0","impliedNodeFormat":99},{"version":"5881127b047effc37a71318cc5a62ef8","impliedNodeFormat":99},{"version":"8f36f3860adb2a50483ad30dc51507b1","impliedNodeFormat":99},{"version":"d481de5cfd11bded5f51a6c1af9e2834","impliedNodeFormat":99},{"version":"c54c40cd5c2a8db3e0032e0712dbba81","impliedNodeFormat":99},{"version":"b19955c68a88a3023f7bfa5d587af2b5","impliedNodeFormat":99},{"version":"a47c946d1f0c8f6dd05c76b6413d8f02","impliedNodeFormat":99},{"version":"05706a9c70b98e9c2680038c9d59e103","impliedNodeFormat":99},{"version":"3d3db32cd555608fd6aaed90246b778f","impliedNodeFormat":99},{"version":"acdddadaeb75d2f80cf744234c474993","impliedNodeFormat":99},{"version":"84e2b65b43e5bb388da0c7ed0a2fb014","impliedNodeFormat":99},{"version":"5c9c1a8f816c9b8712c3da3467c0745f","impliedNodeFormat":99},{"version":"df776cf651c9ffab0eb4714ef06a73d9","impliedNodeFormat":99},{"version":"e114961d07ef26d44de57a0de62ef983","impliedNodeFormat":99},{"version":"d5c2748ecb39d9193ab8a7d8dde92fe7","impliedNodeFormat":99},{"version":"07a1e8aadae16a17f2f8d1334434cca7","impliedNodeFormat":99},{"version":"99dbdf942d4ee5fceeac1f6085365b23","impliedNodeFormat":99},{"version":"60b3bdac8fe0987eb3cee7938ebf44d1","impliedNodeFormat":99},{"version":"e7678b07269c8ad543480d50535b64c7","impliedNodeFormat":99},{"version":"0f2b3459c792dc2690e57f5868b138c8","impliedNodeFormat":99},{"version":"fc3aea6c5eb06a74beac081881b9a3e7","impliedNodeFormat":99},{"version":"d11af76ebf13079573beb1cb9956e60e","impliedNodeFormat":99},{"version":"717f544490b6166e7dc8df63e6b557bb","impliedNodeFormat":99},{"version":"ada6ec2fc1e84c2782910e9f74044c19","impliedNodeFormat":99},{"version":"4164d082785abb56b5c7a267934d29bd","impliedNodeFormat":99},{"version":"35d72da6f5b1659d69b004d6f884cbf5","impliedNodeFormat":99},{"version":"e68f21560e3a6b5b3cd30ac7cbdd5252","impliedNodeFormat":99},{"version":"d5f769d5046460147ae95f6eeff46243","impliedNodeFormat":99},{"version":"0aa7b7928c3922ec6cf05a48876d32cc","impliedNodeFormat":99},{"version":"a1bafb8622afa462266721a81cef9567","impliedNodeFormat":99},{"version":"cb9b3ea33a16a322c7f812e91b4da107","impliedNodeFormat":99},{"version":"c6d1d0fe22acb3d2591157f3bb3e2bd6","impliedNodeFormat":99},{"version":"74ced9e07fd274076f86cec4747c24e7","impliedNodeFormat":99},{"version":"ad91da93386ceeb8a7d8e66b994ff6e6","impliedNodeFormat":99},{"version":"9b8182770d1443b65e1f64d4e36311ed","impliedNodeFormat":99},{"version":"c8a2c6030a092abc00453cea0e7582bc","impliedNodeFormat":99},{"version":"b2873d11ae61f86f1e12a3b8bb855d7b","impliedNodeFormat":99},{"version":"db388f359074f031f14881fa6953c21b","impliedNodeFormat":99},{"version":"ec6a5d1038abe0bc12929c740421211c","impliedNodeFormat":99},{"version":"0c3a01653234bd67e4018b19feba474d","impliedNodeFormat":99},{"version":"109354465dec651e2aebabe46cea78d1","impliedNodeFormat":99},{"version":"42039f9ef13efc76439311d787acc36b","impliedNodeFormat":99},{"version":"f64655537b3cb8e6b10791b05d6b2610","impliedNodeFormat":99},{"version":"3c8014a0b7c5a77b70d1ebff2a0280d5","impliedNodeFormat":99},{"version":"65f720ebd7550200efe207019f3078e7","impliedNodeFormat":99},{"version":"82711743c65af6f53ac28775ceeb630b","impliedNodeFormat":99},{"version":"2798f6eb0048b1545db6d558dcad37e9","impliedNodeFormat":99},{"version":"c10c90394bf5411d83e427ee010c3f31","impliedNodeFormat":99},{"version":"0a17f165f039c69bdb1fd960a4d33733","impliedNodeFormat":99},{"version":"8e7cb83e068abb8369ff84d4d66840c3","impliedNodeFormat":99},{"version":"459fde04607ffb5197cbc912afc4209d","impliedNodeFormat":99},{"version":"363685c4185a70afe72b0f81ad7a9866","impliedNodeFormat":99},{"version":"2cea1eec226f7545708980cf7e26cab6","impliedNodeFormat":99},{"version":"c8c32bd7b60ab2d08d929a879dbb8df1","impliedNodeFormat":99},{"version":"489800fa2b4293dbf31579d6624d9193","impliedNodeFormat":99},{"version":"9217deee495549ce2d7d865cb35c0941","impliedNodeFormat":99},{"version":"35f83126763633267035369f83473d98","impliedNodeFormat":99},{"version":"91e45a26a9de8cada3edf5af8f9d0fee","impliedNodeFormat":99},{"version":"1ed8419a43b050334c25bebfec2f9cf7","impliedNodeFormat":99},{"version":"5b910e329be73a6f19908e37fb40a08b","impliedNodeFormat":99},{"version":"a15ce4005d6b3cfb399dd9e24f36cdc4","impliedNodeFormat":99},{"version":"acecbd6813a31a0dd4a438e468f1475c","impliedNodeFormat":99},{"version":"edaa62a71a63f208671dfcee71806f02","impliedNodeFormat":99},{"version":"f431c8b506a5d7ed776bd075c32ff92c","impliedNodeFormat":99},{"version":"6cea281fdc34d809ea7eda56ba2a41af","impliedNodeFormat":99},{"version":"bb651d13ca2fb5b92c0a1aec36debc08","impliedNodeFormat":99},{"version":"c6d48e8f998faed50948d7f1286a5007","impliedNodeFormat":99},{"version":"32a5e9d5e8e26446a1ba6cc9fe09afc9","impliedNodeFormat":99},{"version":"00b155d2a19cd03e0d48b424d30aeab9","impliedNodeFormat":99},{"version":"e757f289551da7c8009baaff70e30417","impliedNodeFormat":99},{"version":"d603e39e4eb4f1fb64d689fb2cee946b","impliedNodeFormat":99},{"version":"911ce0c8bfe99f4295471d9ce85a89b4","impliedNodeFormat":99},{"version":"473c122fac15d9657e9efc1dfaf8fa09","impliedNodeFormat":99},{"version":"42f7a76a08e60ab1b73183f90c63a0cd","impliedNodeFormat":99},"8d21f6708584ac0a432a01bbd30614b0",{"version":"3d8b798ff909a78ed9a21d8e0389411e","signature":"3fd38a66af8a7a7749b566b68a0189dc","impliedNodeFormat":1},{"version":"5d05bafb6612147549130caa09471d52","signature":"c70b791cd6e281e829aa05b54d6376cf","impliedNodeFormat":1},{"version":"ed63d99e1e5c371dc120bef1b84057fc","impliedNodeFormat":99},{"version":"4d3fb552bfc7fb53c9195b2fafb512c0","impliedNodeFormat":99},{"version":"fbf7ba69043f86dc506ba28263e2e783","impliedNodeFormat":99},{"version":"a611eb6935df7737a77b34b01c631a4a","impliedNodeFormat":99},{"version":"6d08f6f1d0ee294c119d0e66f826331a","impliedNodeFormat":99},{"version":"d0abb8fa314728650d85450ff59db909","impliedNodeFormat":99},{"version":"abe007be89c2ad52c4d67fc2b0f6da6b","impliedNodeFormat":99},{"version":"ae1fe3925f3a2c8dfbb269ac2a50f5a6","impliedNodeFormat":99},{"version":"ee8ce731ff781ae7011350481a1af176","impliedNodeFormat":99},{"version":"08dcd98985ae16732a9be03d2b56aea6","impliedNodeFormat":99},{"version":"47f7401876f3c0a5b80bd01fbdfaed2b","impliedNodeFormat":99},{"version":"c5156ca866ebe97e9684210705e65b18","impliedNodeFormat":99},{"version":"cf03c427cb6cbebe8bd7cbad8932b8e3","impliedNodeFormat":99},{"version":"421606974dd976bfc5ae48946dc1afac","impliedNodeFormat":99},{"version":"4aeb817c2b1122f77bdaeb4e884e9479","impliedNodeFormat":99},{"version":"c52142a849d48e8e4286c2eec06173ff","impliedNodeFormat":99},{"version":"0221e2868d1f0d6df8321d945764aadb","impliedNodeFormat":99},{"version":"d2f6ad6f161f0a522886f64842c96a0e","impliedNodeFormat":99},{"version":"618ace1500cc84e42bc2e47c64f8c407","impliedNodeFormat":99},{"version":"9dd3c481cc870c4bf19e59d34f030a27","impliedNodeFormat":99},{"version":"b5c81396e966d59acab5a45f66b70866","impliedNodeFormat":99},{"version":"f94aa434ddb9e71f6e80395de85f6850","impliedNodeFormat":99},{"version":"3486e8f7f01b9874a793ddd451eb62a5","impliedNodeFormat":99},{"version":"cb0e7222aae349c2fb4f89b26efa81bd","impliedNodeFormat":99},{"version":"b9129d694ae6cf810850117dda49d045","impliedNodeFormat":99},{"version":"0d7bbad7f82c886c5f36730065aec119","impliedNodeFormat":99},{"version":"369460c2755240ac2d3d006f09adb5ca","impliedNodeFormat":99},{"version":"4509fca76e721cdf9edb2d028395a117","impliedNodeFormat":99},"548472bfd4ebe2f1c8f494b960a27836",{"version":"31d11e53cef40d113a56c173ad0ac9f4","affectsGlobalScope":true,"impliedNodeFormat":99},{"version":"2c51637edf65b89d39356deff680ed36","affectsGlobalScope":true,"impliedNodeFormat":99},{"version":"0bf0efdacfd4bfadb631a4376097e382","impliedNodeFormat":99},{"version":"bd01f3bcdc72c9256e5cd5093d132df3","impliedNodeFormat":99},{"version":"b01bdc9acbaf3eb24eef464959e8e627","impliedNodeFormat":99},{"version":"2a75a1a065e5d0439fa1514d9c89b0eb","impliedNodeFormat":99},{"version":"b9129d694ae6cf810850117dda49d045","impliedNodeFormat":99},{"version":"c01d22bc96b89eedc0ed1f11d8c270ab","impliedNodeFormat":99},{"version":"c15bc5b81c64386efb6f85fb596c4349","impliedNodeFormat":99},{"version":"5794a694c1f75a9cc38cb5e9c757224e","impliedNodeFormat":99},{"version":"4040d5640775a803b2ca1aa914f7a1d4","impliedNodeFormat":99},{"version":"5ed96746ee2e7eb084ad54f0e0e518bc","impliedNodeFormat":99},{"version":"eba7786b00a4e551c36bafa71bfb1876","impliedNodeFormat":99},"8d8a98bf45979ce5401d9ca4027940cd","7d98e95d38525423bbe0f05e0a508a41","96920299d013de56061cbc74a1d658b2","439adabdf29be1212ec7acc292679f21","3eb46d20ed056dcbfa5e75bad9014661",{"version":"b46aa1886055db890de9be52a97b301e","impliedNodeFormat":99},{"version":"62ce00c21e70ecec9506af90b593aa58","signature":"abe7d9981d6018efb6b2b794f40a1607","impliedNodeFormat":1},"69cbb09ea2ba999a311e6bb7b06948cc","92585b7b332b633db9cf4085ac2b2ee8","6dc2e1f5017b9497255f3d2149c433fb","daa86fc8e6387f3058d8472e963c541a","40b6049b8a740216392a561fa21cedec","8cc5f3686ee802e2bffeff26af148dc9","7f43bf2c3cc2d6018090769b56eedc0a","e50641a7c7e8cde82beb71d667c65c8b","9802b3a46f874e515ddf7ac507db6a37","33f78207073b14fcca3605577c96af8f","d7f188434661e066ed8c16895272fc7b","ff4cd8f7728d92fe57851b2a38983b66","dc1ef08bc762e9499933e1212e93d029","69042201c41f40609dbb12d5931c6102",{"version":"daf9e6061237ef223ece36c39c14da49","affectsGlobalScope":true,"impliedNodeFormat":1},"094051ed9cc5f1684278dea75e7583b1","6ecb8634c341968afbcd9cb898d67a16","6b46398501ef11113cb27e4bdffe67f2","31ed0e331d139e92c3fb7f58dae06419"],"fileIdsList":[[241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[220,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,258],[241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,258],[193,199,217,218,219,221,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[228,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[228,229,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[197,199,200,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[197,199,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[197,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,197,208,209,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,197,208,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[216,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,198,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[194,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,193,194,195,196,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[234,235,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[234,235,236,237,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[234,236,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[234,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[183,184,185,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[99,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[92,99,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[91,182,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[98,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[102,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[91,99,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[92,102,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[89,90,91,168,169,170,171,172,186,187,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[92,93,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[175,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[169,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[96,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[93,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[90,91,92,95,96,98,173,174,176,177,178,179,180,181,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[91,92,95,97,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[90,91,92,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[92,178,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[92,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[95,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[91,92,93,94,98,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[99,100,101,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[183,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[182,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[203,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[203,204,205,206,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[205,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[201,223,224,226,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[201,202,214,226,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,199,201,202,210,226,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[207,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,201,202,210,222,225,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[201,202,207,210,226,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[201,223,224,225,226,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[201,207,211,212,213,226,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,197,199,201,202,207,210,211,212,213,214,215,217,222,223,224,225,226,227,230,231,232,233,238,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[192,199,201,202,210,211,223,224,225,226,231,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[190,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[190,239,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[188,189,241,242,243,244,245,246,247,248,249,250,251,252,253,254,258],[242,243,244,245,246,247,248,249,250,251,252,253,254,258],[241,243,244,245,246,247,248,249,250,251,252,253,254,258],[241,242,243,245,246,247,248,249,250,251,252,253,254,258],[241,242,243,244,246,247,248,249,250,251,252,253,254,258],[241,242,243,244,245,247,248,249,250,251,252,253,254,258],[241,242,244,245,246,247,248,249,250,251,252,253,254,258],[241,242,243,244,245,246,248,249,250,251,252,253,254,258],[241,242,243,244,245,246,247,249,250,251,252,253,254,258],[241,242,243,244,245,246,247,248,250,251,252,253,254,258],[241,242,243,244,245,246,247,248,249,250,252,253,254,258],[241,242,243,244,245,246,247,248,249,251,252,253,254,258],[241,242,243,244,245,246,247,248,249,250,251,253,254,258],[241,242,243,244,245,246,247,248,249,250,251,252,254,258],[241,242,243,244,245,246,247,248,249,250,251,252,253,258],[241,242,243,244,245,246,247,248,249,250,251,252,253,254,257]],"options":{"allowJs":false,"composite":true,"emitDeclarationOnly":true,"declaration":true,"declarationMap":true,"experimentalDecorators":true,"jsx":3,"module":200,"noImplicitOverride":true,"noUncheckedSideEffectImports":false,"outDir":"./","rewriteRelativeImportExtensions":true,"skipLibCheck":true,"strict":true,"stripInternal":true,"sourceMap":true,"target":99,"esModuleInterop":true},"referencedMap":[[219,1],[221,2],[220,1],[189,1],[257,3],[256,4],[255,1],[87,1],[88,1],[14,1],[16,1],[15,1],[2,1],[17,1],[18,1],[19,1],[20,1],[21,1],[22,1],[23,1],[24,1],[3,1],[25,1],[26,1],[4,1],[27,1],[31,1],[28,1],[29,1],[30,1],[32,1],[33,1],[34,1],[5,1],[35,1],[36,1],[37,1],[38,1],[6,1],[42,1],[39,1],[40,1],[41,1],[43,1],[7,1],[44,1],[49,1],[50,1],[45,1],[46,1],[47,1],[48,1],[8,1],[54,1],[51,1],[52,1],[53,1],[55,1],[9,1],[56,1],[57,1],[58,1],[60,1],[59,1],[61,1],[62,1],[10,1],[63,1],[64,1],[65,1],[11,1],[66,1],[67,1],[68,1],[69,1],[70,1],[71,1],[12,1],[72,1],[73,1],[74,1],[75,1],[76,1],[1,1],[77,1],[78,1],[13,1],[79,1],[80,1],[81,1],[82,1],[83,1],[84,1],[85,1],[86,1],[222,5],[229,6],[230,7],[228,1],[192,1],[201,8],[200,9],[223,8],[208,10],[210,11],[209,12],[217,13],[216,1],[199,14],[193,15],[195,16],[197,17],[196,1],[198,15],[194,1],[236,18],[238,19],[237,20],[235,21],[234,1],[186,22],[160,23],[157,23],[124,23],[119,23],[108,23],[141,23],[142,23],[128,24],[145,23],[138,23],[120,23],[164,23],[126,23],[148,23],[183,25],[99,26],[112,23],[111,23],[147,23],[151,23],[104,23],[117,23],[107,23],[125,23],[113,23],[101,23],[105,23],[152,23],[121,23],[161,23],[129,23],[118,23],[149,23],[143,23],[167,23],[123,23],[139,23],[155,23],[132,23],[163,23],[158,23],[106,23],[144,23],[130,23],[136,23],[115,23],[122,23],[156,23],[153,23],[114,23],[127,23],[103,27],[140,28],[150,23],[165,23],[131,23],[109,29],[159,23],[134,23],[116,23],[137,23],[100,24],[146,27],[102,23],[110,23],[135,27],[166,23],[154,23],[162,23],[133,23],[188,30],[174,31],[176,32],[175,31],[177,32],[170,33],[178,34],[173,35],[182,36],[98,37],[90,1],[169,1],[171,33],[172,1],[91,1],[93,38],[179,39],[97,34],[180,32],[181,40],[96,41],[95,42],[94,1],[89,1],[168,43],[187,44],[92,1],[184,45],[185,45],[224,1],[218,1],[204,46],[207,47],[205,46],[203,1],[206,48],[225,49],[215,50],[211,51],[212,10],[232,52],[226,53],[213,54],[231,55],[202,1],[214,56],[239,57],[233,58],[227,1],[191,59],[240,60],[190,61],[241,62],[242,63],[244,64],[245,65],[246,66],[243,67],[259,1],[247,68],[248,69],[249,70],[251,71],[250,72],[252,73],[253,74],[254,75],[258,76]],"latestChangedDtsFile":"./src/markdown.test.d.ts"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dxos/markdown",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "HTML to Markdown conversion and text normalization utilities",
|
|
5
|
+
"homepage": "https://dxos.org",
|
|
6
|
+
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
|
+
"author": "DXOS.org",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"source": "./src/index.ts",
|
|
18
|
+
"types": "./dist/types/src/index.d.ts",
|
|
19
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
20
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"types": "dist/types/src/index.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"linkedom": "catalog:",
|
|
30
|
+
"turndown": "catalog:"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/turndown": "catalog:"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { normalizeText } from './markdown';
|
|
8
|
+
|
|
9
|
+
describe('markdown', () => {
|
|
10
|
+
test('stripNewlines', ({ expect }) => {
|
|
11
|
+
const text = '<p>aaa</p><p><br></p><p><br></p><p>bbb</p>';
|
|
12
|
+
expect(normalizeText(text)).to.equal('aaa\n\nbbb');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('markdown', ({ expect }) => {
|
|
16
|
+
const text =
|
|
17
|
+
'<p>Another quick reminder to kindly complete this short questionnaire <a href="https://blueyard.typeform.com/to/OLmO8o4k">link</a> to indicate your preferred Day.</p>';
|
|
18
|
+
const markdown = normalizeText(text);
|
|
19
|
+
expect(markdown).to.equal(
|
|
20
|
+
'Another quick reminder to kindly complete this short questionnaire [link](https://blueyard.typeform.com/to/OLmO8o4k) to indicate your preferred Day.',
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('strip html (full)', ({ expect }) => {
|
|
25
|
+
const text = '<html><body><p>test</p></body></html>';
|
|
26
|
+
const markdown = normalizeText(text);
|
|
27
|
+
expect(markdown).to.equal('test');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('strip html', ({ expect }) => {
|
|
31
|
+
const text = '<p>test</p>';
|
|
32
|
+
const markdown = normalizeText(text);
|
|
33
|
+
expect(markdown).to.equal('test');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('converts setext underlines / horizontal rules to markdown HR', ({ expect }) => {
|
|
37
|
+
expect(normalizeText('Heading\n===\n\nbody')).to.equal('Heading\n---\n\nbody');
|
|
38
|
+
expect(normalizeText('Title\n---\n\nbody')).to.equal('Title\n---\n\nbody');
|
|
39
|
+
expect(normalizeText('above\n\n---\n\nbelow')).to.equal('above\n\n---\n\nbelow');
|
|
40
|
+
// Mixed and longer runs (3+) also normalize to `---`.
|
|
41
|
+
expect(normalizeText('above\n\n=====\n\nbelow')).to.equal('above\n\n---\n\nbelow');
|
|
42
|
+
expect(normalizeText('above\n\n-=-=-\n\nbelow')).to.equal('above\n\n---\n\nbelow');
|
|
43
|
+
// Fewer than 3 characters → not an HR; removed by the no-word-char rule instead.
|
|
44
|
+
expect(normalizeText('above\n\n--\n\nbelow')).to.equal('above\n\nbelow');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('removes lines without word characters', ({ expect }) => {
|
|
48
|
+
// Junk separator lines collapse; paragraphs remain separated by one blank line.
|
|
49
|
+
expect(normalizeText('above\n\n****\n\nbelow')).to.equal('above\n\nbelow');
|
|
50
|
+
expect(normalizeText('above\n,,,,\n~~~~\nbelow')).to.equal('above\n\nbelow');
|
|
51
|
+
// The `---` HR we insert is preserved through the no-word-char pass.
|
|
52
|
+
expect(normalizeText('above\n\n---\n\n***\n\nbelow')).to.equal('above\n\n---\n\nbelow');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('trims trailing whitespace from each line', ({ expect }) => {
|
|
56
|
+
expect(normalizeText('aaa \nbbb\t\nccc')).to.equal('aaa\nbbb\nccc');
|
|
57
|
+
expect(normalizeText('aaa \nbbb')).to.equal('aaa\nbbb');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('strips trailing invisible characters from each line', ({ expect }) => {
|
|
61
|
+
// Zero-width space, soft hyphen, word joiner, combining grapheme joiner, ZWNBSP — the invisible
|
|
62
|
+
// chars that `.trim()` and the visible-whitespace pass leave behind when they trail visible text.
|
|
63
|
+
expect(normalizeText('aaa\nbbb')).to.equal('aaa\nbbb');
|
|
64
|
+
expect(normalizeText('word')).to.equal('word');
|
|
65
|
+
expect(normalizeText('a\nb͏')).to.equal('a\nb');
|
|
66
|
+
expect(normalizeText('mixed \nnext')).to.equal('mixed\nnext');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('collapses multiple blank lines in plain text', ({ expect }) => {
|
|
70
|
+
// Three or more blank lines between text → one blank line.
|
|
71
|
+
expect(normalizeText('aaa\n\n\n\nbbb')).to.equal('aaa\n\nbbb');
|
|
72
|
+
// Whitespace-only lines also count as blank.
|
|
73
|
+
expect(normalizeText('aaa\n \n\n \nbbb')).to.equal('aaa\n\nbbb');
|
|
74
|
+
// One blank line is preserved unchanged.
|
|
75
|
+
expect(normalizeText('aaa\n\nbbb')).to.equal('aaa\n\nbbb');
|
|
76
|
+
// No blank line is preserved unchanged.
|
|
77
|
+
expect(normalizeText('aaa\nbbb')).to.equal('aaa\nbbb');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('residual tags', () => {
|
|
81
|
+
test('strips MS Office namespaced tags', ({ expect }) => {
|
|
82
|
+
// <o:p>...</o:p> is the most common turndown leftover from Outlook emails.
|
|
83
|
+
expect(normalizeText('<p>Hello<o:p></o:p>world</p>')).to.equal('Helloworld');
|
|
84
|
+
// Self-closing namespaced tag (VML shape).
|
|
85
|
+
expect(normalizeText('<p>before<v:shape id="x"/>after</p>')).to.equal('beforeafter');
|
|
86
|
+
// <w:...> (Word) and <m:...> (math) variants.
|
|
87
|
+
expect(normalizeText('<p>a<w:WordDocument/>b<m:mathPr/>c</p>')).to.equal('abc');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('strips MS Office conditional comments', ({ expect }) => {
|
|
91
|
+
expect(normalizeText('<!--[if mso]><p>hidden</p><![endif]-->visible')).to.equal('visible');
|
|
92
|
+
expect(normalizeText('before<!--[if gte mso 9]>junk<![endif]-->after')).to.equal('beforeafter');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('strips stray inline tags that survive turndown', ({ expect }) => {
|
|
96
|
+
// turndown leaves attribute-laden spans/fonts in some edge cases.
|
|
97
|
+
expect(normalizeText('<p>hello <span style="color:red">world</span></p>')).to.equal('hello world');
|
|
98
|
+
expect(normalizeText('<p><font face="Arial">text</font></p>')).to.equal('text');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('preserves text when stripping tags', ({ expect }) => {
|
|
102
|
+
// The closing tag without a matching opener must not eat surrounding text.
|
|
103
|
+
expect(normalizeText('keep this </o:p> and this')).to.equal('keep this and this');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('preserves literal angle-bracketed inline tags in plaintext', ({ expect }) => {
|
|
107
|
+
// Plaintext bodies that mention <font>/<u> literally must NOT be stripped — they're
|
|
108
|
+
// meaningful content, not residual HTML noise. The generic inline-tag pass only runs on
|
|
109
|
+
// HTML-converted text. Note: <div>/<span> trigger HTML detection upstream so they hit
|
|
110
|
+
// the HTML pipeline; this test covers tags that escape isHTML().
|
|
111
|
+
expect(normalizeText('Set <font> tags are deprecated.')).to.equal('Set <font> tags are deprecated.');
|
|
112
|
+
expect(normalizeText('Press <u>OK</u> to confirm.')).to.equal('Press <u>OK</u> to confirm.');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('handles namespaced tags inside plaintext (non-HTML) input', ({ expect }) => {
|
|
116
|
+
// Some Gmail plaintext bodies contain HTML fragments inline; we still want them cleaned.
|
|
117
|
+
// Input has no recognized HTML tags so isHTML() is false, but residual tags must still be stripped.
|
|
118
|
+
// Trailing whitespace from the stripped tag location is trimmed by stripWhitespace().
|
|
119
|
+
expect(normalizeText('Meeting reminder <o:p></o:p>\n\nDetails below.')).to.equal(
|
|
120
|
+
'Meeting reminder\n\nDetails below.',
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('blank line collapsing (extended)', () => {
|
|
126
|
+
test('collapses blank lines that appear after residual-tag removal', ({ expect }) => {
|
|
127
|
+
// The <o:p></o:p> sits between content, leaving an effectively-empty line after strip.
|
|
128
|
+
// Pipeline must end with exactly one blank line between the two paragraphs.
|
|
129
|
+
expect(normalizeText('aaa\n<o:p></o:p>\n\n\nbbb')).to.equal('aaa\n\nbbb');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('HTML <br><br><br> sequence collapses to a single blank line', ({ expect }) => {
|
|
133
|
+
// Outlook-style "many <br>" between paragraphs must end up as one blank line, not several.
|
|
134
|
+
expect(normalizeText('<p>a</p><br><br><br><p>b</p>')).to.equal('a\n\nb');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('strips leading and trailing blank lines from whole document', ({ expect }) => {
|
|
138
|
+
// Leading/trailing blank lines (with whitespace) must be removed entirely.
|
|
139
|
+
expect(normalizeText('\n\n \naaa\nbbb\n\n \n\n')).to.equal('aaa\nbbb');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('a single blank line is preserved across HTML pipeline', ({ expect }) => {
|
|
143
|
+
// Two paragraphs separated by a single empty paragraph → one blank line.
|
|
144
|
+
expect(normalizeText('<p>a</p><p></p><p>b</p>')).to.equal('a\n\nb');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('strips newsletter preheader padding (invisible whitespace)', ({ expect }) => {
|
|
148
|
+
// Substack-style preheader: a real preview line followed by a line of
|
|
149
|
+
// U+00AD (soft hyphen), U+034F (combining grapheme joiner), and spaces
|
|
150
|
+
// used to push preview text out of the inbox list view.
|
|
151
|
+
const padding = '͏ '.repeat(10);
|
|
152
|
+
expect(normalizeText(`Watch now\n\n${padding}\n\nForwarded this email?`)).to.equal(
|
|
153
|
+
'Watch now\n\nForwarded this email?',
|
|
154
|
+
);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('blanks lines containing only zero-width characters', ({ expect }) => {
|
|
158
|
+
// ZWSP, ZWNJ, ZWJ, word joiner, BOM/ZWNBSP — all invisible padding.
|
|
159
|
+
// The blanked middle line collapses with its neighboring newlines into
|
|
160
|
+
// a single blank line between aaa and bbb.
|
|
161
|
+
expect(normalizeText('aaa\n\nbbb')).to.equal('aaa\n\nbbb');
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('blockquotes stay contiguous', () => {
|
|
166
|
+
test('HTML blockquote paragraphs do not gain blank lines between quoted lines', ({ expect }) => {
|
|
167
|
+
// Turndown prefixes every blockquote line with `> `; the paragraph break must not become a
|
|
168
|
+
// blank line between the two quoted lines.
|
|
169
|
+
const html = '<blockquote><p>Hello Hello.</p><p>I am resending this since you missed it.</p></blockquote>';
|
|
170
|
+
expect(normalizeText(html)).to.equal('> Hello Hello.\n> I am resending this since you missed it.');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('plaintext quotes separated by blank lines are rejoined', ({ expect }) => {
|
|
174
|
+
expect(normalizeText('> Hello Hello.\n\n> I am resending this since you missed it.')).to.equal(
|
|
175
|
+
'> Hello Hello.\n> I am resending this since you missed it.',
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('blank line between a quote and following body text is preserved', ({ expect }) => {
|
|
180
|
+
// Only blank lines *between* two quoted lines collapse; a quote→body break stays.
|
|
181
|
+
expect(normalizeText('> quoted line\n\nMy reply.')).to.equal('> quoted line\n\nMy reply.');
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('non-quoted paragraphs keep their blank-line separation', ({ expect }) => {
|
|
185
|
+
expect(normalizeText('above\n\nbelow')).to.equal('above\n\nbelow');
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
});
|
package/src/markdown.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { parseHTML } from 'linkedom';
|
|
6
|
+
import TurndownService from 'turndown';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* https://www.npmjs.com/package/turndown
|
|
10
|
+
*/
|
|
11
|
+
const turndown = new TurndownService({
|
|
12
|
+
bulletListMarker: '-',
|
|
13
|
+
})
|
|
14
|
+
.remove('script')
|
|
15
|
+
.remove('style')
|
|
16
|
+
.addRule('cleanListSpacing', {
|
|
17
|
+
filter: 'li',
|
|
18
|
+
replacement: (content, node, options) => {
|
|
19
|
+
content = content.replace(/\n{2,}/g, '\n').trim();
|
|
20
|
+
const parent = node.parentNode;
|
|
21
|
+
const isOrdered = parent && parent.nodeName === 'OL';
|
|
22
|
+
if (isOrdered) {
|
|
23
|
+
// Find the item index for ordered lists.
|
|
24
|
+
const index = Array.prototype.indexOf.call(parent.children, node) + 1;
|
|
25
|
+
return `${index}. ${content}\n`;
|
|
26
|
+
} else {
|
|
27
|
+
// Unordered list: single dash + single space.
|
|
28
|
+
return `${options.bulletListMarker} ${content}\n`;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** Heuristically detect whether a string contains HTML markup. */
|
|
34
|
+
export const isHtml = (str: string): boolean => {
|
|
35
|
+
return /<(\/?(p|div|span|ul|ol|li|a|strong|em|br|table|tr|td|h[1-6]))\b[^>]*>/i.test(str);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const preprocessHtml = (html: string): string => {
|
|
39
|
+
// Ensure HTML has proper structure for linkedom parsing.
|
|
40
|
+
// If the HTML is a fragment without html/body tags, wrap it.
|
|
41
|
+
const wrappedHtml = html.trim().startsWith('<html') ? html : `<html><body>${html}</body></html>`;
|
|
42
|
+
return wrappedHtml;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** Convert an HTML string to Markdown. */
|
|
46
|
+
export const htmlToMarkdown = (html: string): string =>
|
|
47
|
+
turndown.turndown(parseHTML(preprocessHtml(html), {}).document.body);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Strip residual HTML/XML tags that survive turndown conversion (e.g., MS Office namespaced
|
|
51
|
+
* tags like <o:p>, <v:shape>, conditional comments, stray <span style=...>).
|
|
52
|
+
*
|
|
53
|
+
* Namespaced tags and MS conditional comments are stripped unconditionally — they have no
|
|
54
|
+
* meaning in genuine plaintext bodies. The generic inline-tag pass (<span>, <font>, <u>,
|
|
55
|
+
* <div>) is opt-in via `fromHtml` so we don't eat literal angle-bracketed text in plaintext
|
|
56
|
+
* messages.
|
|
57
|
+
*/
|
|
58
|
+
const stripResidualTags = (str: string, { fromHtml = false }: { fromHtml?: boolean } = {}): string => {
|
|
59
|
+
const cleaned = str
|
|
60
|
+
// 1. Conditional comments: <!--[if mso]>...<![endif]-->.
|
|
61
|
+
.replace(/<!--\s*\[if[^\]]*\][\s\S]*?<!\[endif\]\s*-->/gi, '')
|
|
62
|
+
// 2. Namespaced tags (<o:p>, <v:shape>, <w:WordDocument/>, <m:mathPr>, etc.).
|
|
63
|
+
.replace(/<\/?[a-zA-Z][\w-]*:[^>]*>/g, '');
|
|
64
|
+
|
|
65
|
+
// 3. Stray known-bad inline tags that survive turndown in edge cases — HTML pipeline only.
|
|
66
|
+
return fromHtml ? cleaned.replace(/<\/?(span|font|u|div)\b[^>]*>/gi, '') : cleaned;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const stripWhitespace = (str: string): string => {
|
|
70
|
+
// Invisible/whitespace characters that newsletters use to pad preview text:
|
|
71
|
+
// soft hyphen (U+00AD), combining grapheme joiner (U+034F), zero-width
|
|
72
|
+
// space/non-joiner/joiner (U+200B-U+200D), word joiner (U+2060), and BOM/
|
|
73
|
+
// ZWNBSP (U+FEFF), plus regular space, tab, and NBSP.
|
|
74
|
+
const INVISIBLE = ' \\t\\u00A0\\u00AD\\u034F\\u200B-\\u200D\\u2060\\uFEFF';
|
|
75
|
+
const WHITESPACE = /[ \t\u00A0]*\n[ \t\u00A0]*\n[\s\u00A0]*/g;
|
|
76
|
+
return (
|
|
77
|
+
str
|
|
78
|
+
.trim()
|
|
79
|
+
// Blank out lines that contain only invisible/whitespace characters (newsletter padding).
|
|
80
|
+
.replace(new RegExp(`^[${INVISIBLE}]+$`, 'gm'), '')
|
|
81
|
+
// Convert setext-underline / horizontal-rule lines (3+ `=` or `-`) to a markdown HR.
|
|
82
|
+
.replace(/^[ \t\u00A0]*[=-]{3,}[ \t\u00A0]*$/gm, '---')
|
|
83
|
+
// Replace old-school sign-off dash with horizontal rule.
|
|
84
|
+
.replace(/\\--/g, '---')
|
|
85
|
+
// Blank out lines that contain no letter or digit (e.g., junk separators like `*****`, `,,,,`).
|
|
86
|
+
// Uses Unicode property escapes so non-Latin scripts (Cyrillic, CJK, etc.) are preserved.
|
|
87
|
+
// Empty lines are preserved as paragraph breaks; the `---` HR we just inserted is exempted so it survives.
|
|
88
|
+
.replace(/^(?!---$)[^\p{L}\p{N}\n]*$/gmu, '')
|
|
89
|
+
// Replace multiple newlines with double newlines.
|
|
90
|
+
.replace(WHITESPACE, '\n\n')
|
|
91
|
+
// Trim trailing whitespace \u2014 including the invisible/zero-width chars (soft hyphen, zero-width
|
|
92
|
+
// space/joiners, word joiner, ZWNBSP) that `.trim()` and the visible-whitespace set miss \u2014 from
|
|
93
|
+
// every line.
|
|
94
|
+
.replace(new RegExp(`[${INVISIBLE}]+$`, 'gm'), '')
|
|
95
|
+
// Keep a quoted block contiguous: drop blank lines between consecutive quoted (`>`) lines.
|
|
96
|
+
// Turndown prefixes every blockquote line with `> `, so paragraph breaks within a quote
|
|
97
|
+
// surface as a bare `> ` line that the no-letter pass above blanks; this rejoins them (and
|
|
98
|
+
// also collapses blank-separated quotes in plaintext bodies).
|
|
99
|
+
.replace(/^(>.*)\n\n+(?=>)/gm, '$1\n')
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Normalize arbitrary text (HTML or plaintext) into clean Markdown. HTML input is converted to
|
|
105
|
+
* Markdown; plaintext is passed through. In both cases runs of blank lines are collapsed so the
|
|
106
|
+
* rendered result never shows more than one blank line between paragraphs.
|
|
107
|
+
*/
|
|
108
|
+
// TODO(burdon): Replace legal disclaimers, etc.
|
|
109
|
+
export const normalizeText = (text: string): string => {
|
|
110
|
+
const fromHtml = isHtml(text);
|
|
111
|
+
const converted = fromHtml ? htmlToMarkdown(text) : text;
|
|
112
|
+
return stripWhitespace(stripResidualTags(converted, { fromHtml }));
|
|
113
|
+
};
|