@podlite/schema 0.0.57 → 0.0.59
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/CHANGELOG.podlite +19 -0
- package/esm/ast-helpers.d.ts +18 -0
- package/esm/ast-helpers.js +117 -1
- package/esm/ast-helpers.js.map +1 -1
- package/esm/exportAny.js +3 -1
- package/esm/exportAny.js.map +1 -1
- package/esm/exportHtml.js +5 -6
- package/esm/exportHtml.js.map +1 -1
- package/esm/exportMarkdown.js +8 -4
- package/esm/exportMarkdown.js.map +1 -1
- package/esm/grammarfc.js +14204 -5175
- package/esm/grammarfc.js.map +1 -1
- package/esm/helpers/ids.d.ts +1 -0
- package/esm/helpers/ids.js +8 -2
- package/esm/helpers/ids.js.map +1 -1
- package/esm/plugin-tables.js +10 -20
- package/esm/plugin-tables.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/ast-helpers.d.ts +18 -0
- package/lib/ast-helpers.js +125 -2
- package/lib/exportAny.js +3 -1
- package/lib/exportHtml.js +4 -5
- package/lib/exportMarkdown.js +8 -4
- package/lib/grammarfc.js +14204 -5175
- package/lib/helpers/ids.d.ts +1 -0
- package/lib/helpers/ids.js +10 -3
- package/lib/plugin-tables.js +10 -20
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/helpers/ids.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const cleanIds: (src?: {
|
|
|
7
7
|
skipChain: number;
|
|
8
8
|
podMode: number;
|
|
9
9
|
}) => (tree: any) => any;
|
|
10
|
+
export declare const headingId: (text: string) => string;
|
|
10
11
|
export declare const slugifyText: (text: string) => string;
|
|
11
12
|
/**
|
|
12
13
|
* Add set id to 'id' to each blocks
|
package/lib/helpers/ids.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setAllLinksToAnchor = exports.frozenIds = exports.slugifyText = exports.cleanIds = void 0;
|
|
6
|
+
exports.setAllLinksToAnchor = exports.frozenIds = exports.slugifyText = exports.headingId = exports.cleanIds = void 0;
|
|
7
7
|
const __1 = require("..");
|
|
8
8
|
const nanoid_1 = require("nanoid");
|
|
9
9
|
const slugify_1 = __importDefault(require("slugify"));
|
|
@@ -27,7 +27,14 @@ const cleanIds = (src = { skipChain: 0, podMode: 1 }) => tree => {
|
|
|
27
27
|
return transformerBlocks(tree, {});
|
|
28
28
|
};
|
|
29
29
|
exports.cleanIds = cleanIds;
|
|
30
|
-
//
|
|
30
|
+
// A heading carries its own text as the identifier. Shaping it for a particular
|
|
31
|
+
// output — collapsing separators, dropping punctuation, numbering repeats — is the
|
|
32
|
+
// exporter's job (see getSafeNodeId), not the parser's. Slugifying here also
|
|
33
|
+
// transliterated cyrillic, so «Приветствие Мир» became Privetstvie-Mir and the
|
|
34
|
+
// original name could not be recovered.
|
|
35
|
+
const headingId = (text) => text.trim().replace(/\s+/g, ' ');
|
|
36
|
+
exports.headingId = headingId;
|
|
37
|
+
// kept for callers outside the tree layer
|
|
31
38
|
const slugifyText = (text) => {
|
|
32
39
|
return (0, slugify_1.default)(text.trim(), {});
|
|
33
40
|
};
|
|
@@ -76,7 +83,7 @@ const middleware = () => tree => {
|
|
|
76
83
|
return node;
|
|
77
84
|
}
|
|
78
85
|
else if (node.name == 'head') {
|
|
79
|
-
return { ...node, id: (0, exports.
|
|
86
|
+
return { ...node, id: (0, exports.headingId)((0, __1.getTextContentFromNode)(node)) };
|
|
80
87
|
}
|
|
81
88
|
else {
|
|
82
89
|
return { ...node, id: (0, nanoid_1.nanoid)() };
|
package/lib/plugin-tables.js
CHANGED
|
@@ -526,25 +526,18 @@ exports.default = () => tree => {
|
|
|
526
526
|
const makeRow = cells => makeBlock('row', cells);
|
|
527
527
|
const makeHeaderRow = cells => makeBlock('row', cells, { config: [{ name: 'header', value: true, type: 'boolean' }] });
|
|
528
528
|
const makeCell = text => makeBlock('cell', { type: 'text', value: text });
|
|
529
|
-
// Routing:
|
|
530
|
-
//
|
|
531
|
-
//
|
|
532
|
-
//
|
|
533
|
-
// separator, or with both visible kinds (pipe + plus) handled by the
|
|
534
|
-
// shared mask, fall back to the legacy positional template, which
|
|
535
|
-
// preserves continuation-line alignment in multi-line rows and keeps
|
|
536
|
-
// byte-for-byte AST/HTML output stable.
|
|
529
|
+
// Routing: a whitespace-separated row on one line splits by its own
|
|
530
|
+
// gaps — two spaces are enough there, while the positional mask needs
|
|
531
|
+
// three. Rows with a visible separator keep the mask: an edge `|`
|
|
532
|
+
// carries a real empty cell that per-line splitting would drop.
|
|
537
533
|
const columnTemplate = makeMask(lines, separators);
|
|
538
534
|
const seenSeparatorKinds = new Set(lines.map(detectLineSeparator));
|
|
539
|
-
const
|
|
540
|
-
const
|
|
541
|
-
const useMixedSplitting = hasVisible && hasWhitespace;
|
|
535
|
+
const useMixedSplitting = (seenSeparatorKinds.has('pipe') || seenSeparatorKinds.has('plus')) && seenSeparatorKinds.has('whitespace');
|
|
536
|
+
const splitsItself = (line) => useMixedSplitting || detectLineSeparator(line) === 'whitespace';
|
|
542
537
|
const splitToCells = (rowValue) => {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
return rowToCells(rowValue);
|
|
547
|
-
}
|
|
538
|
+
const rowLines = rowValue.split(/\r?\n/).filter(l => l.trim() !== '');
|
|
539
|
+
if (rowLines.length <= 1 && splitsItself(rowValue))
|
|
540
|
+
return rowToCells(rowValue);
|
|
548
541
|
return extractColumnsByTemplate(rowValue, columnTemplate);
|
|
549
542
|
};
|
|
550
543
|
const res = (0, makeTransformer_1.default)({
|
|
@@ -552,10 +545,7 @@ exports.default = () => tree => {
|
|
|
552
545
|
if (textRows.length == 1) {
|
|
553
546
|
// No separator blocks: each line of the only text row becomes its own row
|
|
554
547
|
const textRowsLines = flattenDeep([row.value].map(splitToLines));
|
|
555
|
-
|
|
556
|
-
return textRowsLines.map(line => makeRow(splitLineCells(line).map(makeCell)));
|
|
557
|
-
}
|
|
558
|
-
return textRowsLines.map(line => makeRow(extractColumnsByTemplate(line, columnTemplate).map(makeCell)));
|
|
548
|
+
return textRowsLines.map(line => makeRow((splitsItself(line) ? splitLineCells(line) : extractColumnsByTemplate(line, columnTemplate)).map(makeCell)));
|
|
559
549
|
}
|
|
560
550
|
return makeRow(splitToCells(row.value).map(makeCell));
|
|
561
551
|
},
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.59";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED