@effected/markdown 0.18.0 → 0.20.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/Frontmatter.js +1 -2
- package/FrontmatterResolver.js +1 -2
- package/FrontmatterSource.js +1 -2
- package/JsonFrontmatter.js +1 -2
- package/Markdown.js +25 -14
- package/MarkdownDiagnostic.js +1 -2
- package/MarkdownDocument.js +5 -39
- package/MarkdownEdit.js +1 -2
- package/MarkdownFormat.js +1 -2
- package/MarkdownNode.js +1 -2
- package/MarkdownTransform.js +166 -0
- package/MarkdownVisitor.js +1 -2
- package/Mdast.js +50 -2
- package/TomlFrontmatter.js +1 -2
- package/YamlFrontmatter.js +1 -2
- package/index.d.ts +310 -39
- package/index.js +2 -1
- package/internal/blockParser.js +1 -2
- package/internal/blockRegistry.js +1 -2
- package/internal/blockTypes.js +1 -2
- package/internal/blocks/atxHeading.js +1 -2
- package/internal/blocks/blockquote.js +1 -2
- package/internal/blocks/code.js +1 -2
- package/internal/blocks/document.js +1 -2
- package/internal/blocks/fencedCode.js +1 -2
- package/internal/blocks/footnoteDefinition.js +1 -2
- package/internal/blocks/frontmatter.js +1 -2
- package/internal/blocks/htmlBlock.js +1 -2
- package/internal/blocks/indentedCode.js +1 -2
- package/internal/blocks/linkReferenceDefinition.js +1 -2
- package/internal/blocks/list.js +1 -2
- package/internal/blocks/paragraph.js +1 -2
- package/internal/blocks/setextHeading.js +1 -2
- package/internal/blocks/table.js +1 -2
- package/internal/blocks/taskListItem.js +1 -2
- package/internal/blocks/thematicBreak.js +1 -2
- package/internal/carriers.js +1 -2
- package/internal/entities.js +1 -2
- package/internal/entityMap.js +1 -2
- package/internal/htmlTags.js +1 -2
- package/internal/inlineNode.js +1 -2
- package/internal/inlineParser.js +1 -2
- package/internal/inlineRegistry.js +1 -2
- package/internal/inlines/autolink.js +1 -2
- package/internal/inlines/autolinkLiteral.js +1 -2
- package/internal/inlines/codeSpan.js +1 -2
- package/internal/inlines/emphasis.js +1 -2
- package/internal/inlines/entity.js +1 -2
- package/internal/inlines/escape.js +1 -2
- package/internal/inlines/footnoteReference.js +1 -2
- package/internal/inlines/lineBreak.js +1 -2
- package/internal/inlines/link.js +1 -2
- package/internal/inlines/rawHtml.js +1 -2
- package/internal/inlines/strikethrough.js +1 -2
- package/internal/inlines/text.js +1 -2
- package/internal/lineIndex.js +1 -2
- package/internal/patterns.js +1 -2
- package/internal/phrasing.js +1 -2
- package/internal/preprocess.js +1 -2
- package/internal/rawInline.js +1 -2
- package/internal/references.js +1 -2
- package/internal/sectionBounds.js +43 -0
- package/internal/segments.js +1 -2
- package/internal/stringify.js +8 -11
- package/internal/unescape.js +1 -2
- package/package.json +4 -4
package/internal/preprocess.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/preprocess.ts
|
|
2
2
|
/** The tab stop width CommonMark fixes for indentation arithmetic. */
|
|
3
3
|
const TAB_STOP = 4;
|
|
4
4
|
/**
|
|
@@ -54,5 +54,4 @@ const peekCode = (line, position) => position >= 0 && position < line.length ? l
|
|
|
54
54
|
*/
|
|
55
55
|
const columnsToNextTabStop = (column) => 4 - column % 4;
|
|
56
56
|
|
|
57
|
-
//#endregion
|
|
58
57
|
export { columnsToNextTabStop, isSpaceOrTab, peekCode, preprocessLines, replaceNul };
|
package/internal/rawInline.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseInlines } from "./inlineParser.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/rawInline.ts
|
|
4
4
|
const reWhitespace = /\s/;
|
|
5
5
|
const reCmarkSpace = /[ \t\n\r]/;
|
|
6
6
|
/**
|
|
@@ -55,5 +55,4 @@ const prepareInline = (block, position, refmap, dialect = "commonmark", footnote
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
//#endregion
|
|
59
58
|
export { prepareInline, trimWithSegments };
|
package/internal/references.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { unescapeString } from "./unescape.js";
|
|
2
2
|
import { stickyOf } from "./patterns.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/internal/references.ts
|
|
5
5
|
const ESCAPABLE = "[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]";
|
|
6
6
|
const ESCAPED_CHAR = `\\\\${ESCAPABLE}`;
|
|
7
7
|
const reLinkTitle = new RegExp(`^(?:"(${ESCAPED_CHAR}|\\\\[^\\\\]|[^\\\\"\\x00])*"|'(${ESCAPED_CHAR}|\\\\[^\\\\]|[^\\\\'\\x00])*'|\\((${ESCAPED_CHAR}|\\\\[^\\\\]|[^\\\\()\\x00])*\\))`);
|
|
@@ -175,5 +175,4 @@ const parseReference = (text) => {
|
|
|
175
175
|
};
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
//#endregion
|
|
179
178
|
export { ReferenceScanner, normalizeLabelText, normalizeReference, parseReference };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/internal/sectionBounds.ts
|
|
2
|
+
/**
|
|
3
|
+
* Every root-level heading of `children`, in document order, paired with the
|
|
4
|
+
* child index its section ends at.
|
|
5
|
+
*/
|
|
6
|
+
const rootHeadingBounds = (children) => {
|
|
7
|
+
const headings = [];
|
|
8
|
+
for (let index = 0; index < children.length; index += 1) {
|
|
9
|
+
const block = children[index];
|
|
10
|
+
if (block !== void 0 && block.type === "heading") headings.push({
|
|
11
|
+
index,
|
|
12
|
+
node: block
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const nextByDepth = [
|
|
16
|
+
void 0,
|
|
17
|
+
void 0,
|
|
18
|
+
void 0,
|
|
19
|
+
void 0,
|
|
20
|
+
void 0,
|
|
21
|
+
void 0,
|
|
22
|
+
void 0
|
|
23
|
+
];
|
|
24
|
+
const bounds = new Array(headings.length);
|
|
25
|
+
for (let index = headings.length - 1; index >= 0; index -= 1) {
|
|
26
|
+
const current = headings[index];
|
|
27
|
+
if (current === void 0) continue;
|
|
28
|
+
let boundary;
|
|
29
|
+
for (let depth = 1; depth <= current.node.depth; depth += 1) {
|
|
30
|
+
const candidate = nextByDepth[depth];
|
|
31
|
+
if (candidate !== void 0 && (boundary === void 0 || candidate < boundary)) boundary = candidate;
|
|
32
|
+
}
|
|
33
|
+
bounds[index] = {
|
|
34
|
+
heading: current.node,
|
|
35
|
+
index: current.index,
|
|
36
|
+
end: boundary === void 0 ? children.length : headings[boundary]?.index ?? children.length
|
|
37
|
+
};
|
|
38
|
+
nextByDepth[current.node.depth] = index;
|
|
39
|
+
}
|
|
40
|
+
return bounds;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { rootHeadingBounds };
|
package/internal/segments.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/segments.ts
|
|
2
2
|
/**
|
|
3
3
|
* The absolute source offset of `textIndex` within a segmented content run.
|
|
4
4
|
*
|
|
@@ -32,5 +32,4 @@ const sliceWithSegments = (segments, from, to) => {
|
|
|
32
32
|
return sliced;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
export { sliceWithSegments, sourceOffsetAt };
|
package/internal/stringify.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ENTITY } from "./unescape.js";
|
|
2
2
|
import { GuardExceeded } from "./carriers.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/internal/stringify.ts
|
|
5
5
|
const FLOW_CONTEXT = {
|
|
6
6
|
singleLine: false,
|
|
7
7
|
inTable: false,
|
|
@@ -824,21 +824,18 @@ const serializeBlocks = (children, state, tight = false) => {
|
|
|
824
824
|
return out;
|
|
825
825
|
};
|
|
826
826
|
/**
|
|
827
|
-
* Serialize a
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
* `MAX_NESTING_DEPTH`; the facade materializes the typed error. Output is
|
|
831
|
-
* empty for an empty root and ends with exactly one newline otherwise.
|
|
827
|
+
* Serialize a root-level block list — the one path behind both a whole
|
|
828
|
+
* `Root` and a lone flow node (`[node]`), so the two cannot diverge. Builds
|
|
829
|
+
* no wrapper node, so nothing here can fail a schema constructor.
|
|
832
830
|
*/
|
|
833
|
-
const
|
|
831
|
+
const stringifyBlocks = (children) => {
|
|
834
832
|
const state = {
|
|
835
833
|
depth: 0,
|
|
836
834
|
jsxDepth: 0,
|
|
837
|
-
mdx: treeContainsMdx(
|
|
835
|
+
mdx: children.some((child) => treeContainsMdx(child))
|
|
838
836
|
};
|
|
839
|
-
const body = serializeBlocks(
|
|
837
|
+
const body = serializeBlocks(children, state);
|
|
840
838
|
return body === "" ? "" : `${body}\n`;
|
|
841
839
|
};
|
|
842
840
|
|
|
843
|
-
|
|
844
|
-
export { stringifyTree };
|
|
841
|
+
export { stringifyBlocks };
|
package/internal/unescape.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decodeEntity } from "./entities.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/unescape.ts
|
|
4
4
|
/** The punctuation set a backslash may escape, per the spec. */
|
|
5
5
|
const ESCAPABLE = "[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]";
|
|
6
6
|
/** One entity, in any of the three spec forms. */
|
|
@@ -14,5 +14,4 @@ const unescapeChar = (source) => {
|
|
|
14
14
|
/** Replace every backslash escape and character reference with its literal. */
|
|
15
15
|
const unescapeString = (source) => reBackslashOrAmp.test(source) ? source.replace(reEntityOrEscapedChar, unescapeChar) : source;
|
|
16
16
|
|
|
17
|
-
//#endregion
|
|
18
17
|
export { ENTITY, ESCAPABLE, unescapeString };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "CommonMark and GFM markdown parse, edit and transform schemas for Effect",
|
|
6
6
|
"keywords": [
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"./package.json": "./package.json"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@effected/jsonc": "^0.
|
|
43
|
-
"@effected/toml": "^0.
|
|
44
|
-
"@effected/yaml": "^0.
|
|
42
|
+
"@effected/jsonc": "^0.19.0",
|
|
43
|
+
"@effected/toml": "^0.15.0",
|
|
44
|
+
"@effected/yaml": "^0.23.0",
|
|
45
45
|
"effect": "^4.0.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|