@podlite/schema 0.0.37 → 0.0.38
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 +16 -0
- package/README.md +61 -4
- package/esm/blocks-helpers.d.ts +2 -2
- package/esm/blocks-helpers.js +11 -4
- package/esm/blocks-helpers.js.map +1 -1
- package/esm/exportHtml.js +57 -6
- package/esm/exportHtml.js.map +1 -1
- package/esm/exportMarkdown.js +52 -6
- package/esm/exportMarkdown.js.map +1 -1
- package/esm/grammar.js +442 -215
- package/esm/grammar.js.map +1 -1
- package/esm/grammarfc.js +1819 -1459
- package/esm/grammarfc.js.map +1 -1
- package/esm/helpers/config.d.ts +1 -0
- package/esm/helpers/config.js +8 -0
- package/esm/helpers/config.js.map +1 -1
- package/esm/plugin-tables.d.ts +0 -3
- package/esm/plugin-tables.js +37 -8
- package/esm/plugin-tables.js.map +1 -1
- package/esm/types.d.ts +9 -7
- package/lib/blocks-helpers.d.ts +2 -2
- package/lib/blocks-helpers.js +13 -6
- package/lib/exportHtml.js +57 -6
- package/lib/exportMarkdown.js +52 -6
- package/lib/grammar.js +442 -215
- package/lib/grammarfc.js +1819 -1459
- package/lib/helpers/config.d.ts +1 -0
- package/lib/helpers/config.js +8 -0
- package/lib/plugin-tables.d.ts +0 -3
- package/lib/plugin-tables.js +37 -8
- package/lib/types.d.ts +9 -7
- package/package.json +2 -2
- package/schema/AstTree.json +6 -3
- package/schema/PodliteDocument.json +6 -3
package/esm/helpers/config.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare type Context = {
|
|
|
4
4
|
export interface Attr {
|
|
5
5
|
getAllValues: (name: any) => any;
|
|
6
6
|
getFirstValue: (name: any) => any;
|
|
7
|
+
getMapValue: (name: string) => Record<string, string | number | boolean> | undefined;
|
|
7
8
|
asHash: () => {};
|
|
8
9
|
(): {};
|
|
9
10
|
exists(name: string): boolean;
|
package/esm/helpers/config.js
CHANGED
|
@@ -40,6 +40,14 @@ export const makeAttrs = (node, ctx = {}) => {
|
|
|
40
40
|
resfn.getFirstValue = name => {
|
|
41
41
|
return resfn.exists(name) ? resfn.getAllValues(name)[0] : undefined;
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* return first map-typed value (from `:attr{ k=>v, ... }` syntax) or
|
|
45
|
+
* undefined when the attribute is absent or not a map value
|
|
46
|
+
*/
|
|
47
|
+
resfn.getMapValue = name => {
|
|
48
|
+
const first = resfn.getFirstValue(name);
|
|
49
|
+
return first && typeof first === 'object' && !Array.isArray(first) ? first : undefined;
|
|
50
|
+
};
|
|
43
51
|
/**
|
|
44
52
|
* return key: val
|
|
45
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/helpers/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/helpers/config.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAe,EAAE,EAAQ,EAAE;IACzD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9D,wBAAwB;IACxB,IAAI,UAAU,GAAG,EAAE,CAAA;IACnB,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACtD,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACnC;IACD,IAAI,MAAM,GAAG,EAAE,CACd;IAAA,CAAC,GAAG,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QAClC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;YAClC,MAAM,CAA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CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAA;IAE3B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AACD,eAAe,SAAS,CAAA"}
|
package/esm/plugin-tables.d.ts
CHANGED
package/esm/plugin-tables.js
CHANGED
|
@@ -77,9 +77,35 @@ const extractColumnsByTemplate = (text, template) => {
|
|
|
77
77
|
/**
|
|
78
78
|
* Main transforms
|
|
79
79
|
*/
|
|
80
|
+
const wrapImplicitCells = rowNode => {
|
|
81
|
+
if (!Array.isArray(rowNode.content) || rowNode.content.length === 0)
|
|
82
|
+
return rowNode;
|
|
83
|
+
const hasNonCell = rowNode.content.some(c => c && c.type === 'block' && c.name !== 'cell' && c.name !== 'blankline');
|
|
84
|
+
if (!hasNonCell)
|
|
85
|
+
return rowNode;
|
|
86
|
+
const wrapped = rowNode.content.map(c => {
|
|
87
|
+
if (!c || c.type !== 'block')
|
|
88
|
+
return c;
|
|
89
|
+
if (c.name === 'cell' || c.name === 'blankline')
|
|
90
|
+
return c;
|
|
91
|
+
return { type: 'block', name: 'cell', content: [c], margin: c.margin || '' };
|
|
92
|
+
});
|
|
93
|
+
return { ...rowNode, content: wrapped };
|
|
94
|
+
};
|
|
95
|
+
const isStructured = tableNode => Array.isArray(tableNode.content) &&
|
|
96
|
+
tableNode.content.some(c => c && c.type === 'block' && (c.name === 'row' || c.name === 'cell'));
|
|
80
97
|
export default () => tree => {
|
|
81
98
|
const transformer = makeTransformer({
|
|
82
99
|
table: node => {
|
|
100
|
+
// structured mode: transform row children (wrap implicit cells)
|
|
101
|
+
if (isStructured(node)) {
|
|
102
|
+
const transformedContent = (node.content || []).map(c => {
|
|
103
|
+
if (c && c.name === 'row')
|
|
104
|
+
return wrapImplicitCells(c);
|
|
105
|
+
return c;
|
|
106
|
+
});
|
|
107
|
+
return { ...node, content: transformedContent };
|
|
108
|
+
}
|
|
83
109
|
let rows = [];
|
|
84
110
|
const collectValues = row => {
|
|
85
111
|
rows.push(row.value);
|
|
@@ -111,9 +137,12 @@ export default () => tree => {
|
|
|
111
137
|
},
|
|
112
138
|
})(node);
|
|
113
139
|
const columnTemplate = makeMask(lines, separators);
|
|
114
|
-
const makeBlock = (name, content,
|
|
115
|
-
return { ...
|
|
140
|
+
const makeBlock = (name, content, extra = {}) => {
|
|
141
|
+
return { ...extra, name, type: 'block', content: Array.isArray(content) ? content : [content] };
|
|
116
142
|
};
|
|
143
|
+
const makeRow = cells => makeBlock('row', cells);
|
|
144
|
+
const makeHeaderRow = cells => makeBlock('row', cells, { config: [{ name: 'header', value: true, type: 'boolean' }] });
|
|
145
|
+
const makeCell = text => makeBlock('cell', { type: 'text', value: text });
|
|
117
146
|
// make columns
|
|
118
147
|
const res = makeTransformer({
|
|
119
148
|
'row:text': row => {
|
|
@@ -121,16 +150,16 @@ export default () => tree => {
|
|
|
121
150
|
// split each text row into lines
|
|
122
151
|
const textRowsLines = flattenDeep([row.value].map(splitToLines));
|
|
123
152
|
return textRowsLines.map(rowValue => {
|
|
124
|
-
const
|
|
125
|
-
return
|
|
153
|
+
const cols = extractColumnsByTemplate(rowValue, columnTemplate);
|
|
154
|
+
return makeRow(cols.map(makeCell));
|
|
126
155
|
});
|
|
127
156
|
}
|
|
128
|
-
const
|
|
129
|
-
return
|
|
157
|
+
const cols = extractColumnsByTemplate(row.value, columnTemplate);
|
|
158
|
+
return makeRow(cols.map(makeCell));
|
|
130
159
|
},
|
|
131
160
|
'head:text': head => {
|
|
132
|
-
const
|
|
133
|
-
return
|
|
161
|
+
const cols = extractColumnsByTemplate(head.value, columnTemplate);
|
|
162
|
+
return makeHeaderRow(cols.map(makeCell));
|
|
134
163
|
},
|
|
135
164
|
})(node);
|
|
136
165
|
return res;
|
package/esm/plugin-tables.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-tables.js","sourceRoot":"","sources":["../src/plugin-tables.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,eAAe,MAAM,2BAA2B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CAAA;qBACH;oBACD,MAAM,IAAI,GAAG,wBAAwB,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,CAAA;oBAChE,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;gBACpC,CAAC;gBACD,WAAW,EAAE,IAAI,CAAC,EAAE;oBAClB,MAAM,IAAI,GAAG,wBAAwB,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,CAAC,CAAA;oBACjE,OAAO,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;gBAC1C,CAAC;aACF,CAAC,CAAC,IAAI,CAAC,CAAA;YAER,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAC,CAAA;IACF,OAAO,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AAC9B,CAAC,CAAA"}
|
package/esm/types.d.ts
CHANGED
|
@@ -24,7 +24,9 @@ export interface RulesStrict {
|
|
|
24
24
|
'D<>': RuleHandler<FormattingCodeD>;
|
|
25
25
|
'E<>': RuleHandler<FormattingCodeE>;
|
|
26
26
|
'F<>': RuleHandler<FormattingCodeF>;
|
|
27
|
+
'H<>': RuleHandler<FormattingCodeAny>;
|
|
27
28
|
'I<>': RuleHandler<FormattingCodeI>;
|
|
29
|
+
'J<>': RuleHandler<FormattingCodeAny>;
|
|
28
30
|
'K<>': RuleHandler<FormattingCodeAny>;
|
|
29
31
|
'R<>': RuleHandler<FormattingCodeAny>;
|
|
30
32
|
'T<>': RuleHandler<FormattingCodeAny>;
|
|
@@ -35,7 +37,7 @@ export interface RulesStrict {
|
|
|
35
37
|
'L<>': RuleHandler<FormattingCodeL>;
|
|
36
38
|
'U<>': RuleHandler<FormattingCodeAny>;
|
|
37
39
|
'Z<>': RuleHandler<FormattingCodeAny>;
|
|
38
|
-
'
|
|
40
|
+
'O<>': RuleHandler<FormattingCodeAny>;
|
|
39
41
|
pod: RuleHandler<Para>;
|
|
40
42
|
root: RuleHandler<RootBlock>;
|
|
41
43
|
':para': RuleHandler<Para>;
|
|
@@ -68,9 +70,8 @@ export interface RulesStrict {
|
|
|
68
70
|
'table:block': RuleHandler<BlockTable>;
|
|
69
71
|
table: RuleHandler<BlockTable>;
|
|
70
72
|
':separator': RuleHandler<Separator>;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
table_head: RuleHandler<TableHead>;
|
|
73
|
+
row: RuleHandler<TableRow>;
|
|
74
|
+
cell: RuleHandler<TableCell>;
|
|
74
75
|
toc: RuleHandler<BlockToc>;
|
|
75
76
|
':toc': RuleHandler<Toc>;
|
|
76
77
|
':toc-list': RuleHandler<TocList>;
|
|
@@ -100,6 +101,7 @@ export interface Image {
|
|
|
100
101
|
export interface Toc {
|
|
101
102
|
type: 'toc';
|
|
102
103
|
title?: string;
|
|
104
|
+
folded?: boolean;
|
|
103
105
|
foldedLevels?: Record<number, boolean>;
|
|
104
106
|
content: TocList;
|
|
105
107
|
}
|
|
@@ -342,17 +344,17 @@ export interface BlockTable extends Omit<Block, 'content'> {
|
|
|
342
344
|
text?: string;
|
|
343
345
|
}
|
|
344
346
|
export interface TableCell {
|
|
345
|
-
name: '
|
|
347
|
+
name: 'cell';
|
|
346
348
|
type: 'block';
|
|
347
349
|
content: Array<string>;
|
|
348
350
|
}
|
|
349
351
|
export interface TableRow {
|
|
350
|
-
name: '
|
|
352
|
+
name: 'row';
|
|
351
353
|
type: 'block';
|
|
352
354
|
content: Array<TableCell>;
|
|
353
355
|
}
|
|
354
356
|
export interface TableHead {
|
|
355
|
-
name: '
|
|
357
|
+
name: 'row';
|
|
356
358
|
type: 'block';
|
|
357
359
|
content: Array<TableCell>;
|
|
358
360
|
}
|
package/lib/blocks-helpers.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const mkBlankline: () => {
|
|
|
7
7
|
};
|
|
8
8
|
export declare const mkFomattingCode: (attrs: any, content: any) => any;
|
|
9
9
|
export declare const mkFomattingCodeL: (attrs: any, content: any) => FormattingCodeL;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const mkFomattingCodeO: (content: any) => {
|
|
11
11
|
type: string;
|
|
12
12
|
name: string;
|
|
13
13
|
content: any[];
|
|
@@ -17,7 +17,7 @@ export declare const mkVerbatim: (text: any) => {
|
|
|
17
17
|
type: string;
|
|
18
18
|
value: any;
|
|
19
19
|
};
|
|
20
|
-
export declare const mkToc: (content: TocList, title?: string, location?: Location, foldedLevels?: Record<number, boolean
|
|
20
|
+
export declare const mkToc: (content: TocList, title?: string, location?: Location, foldedLevels?: Record<number, boolean>, folded?: boolean) => Toc;
|
|
21
21
|
export declare const mkTocList: (content: Array<TocItem | TocList>, level: number) => TocList;
|
|
22
22
|
export declare const mkTocItem: (content: PodNode) => TocItem;
|
|
23
23
|
export declare const mkCaption: (content: Array<Node>) => BlockCaption;
|
package/lib/blocks-helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mkFormulaBlock = exports.mkItemBlock = exports.mkRootBlock = exports.mkImage = exports.mkCaption = exports.mkTocItem = exports.mkTocList = exports.mkToc = exports.mkVerbatim = exports.mkMarkupCodeF = exports.
|
|
3
|
+
exports.mkFormulaBlock = exports.mkItemBlock = exports.mkRootBlock = exports.mkImage = exports.mkCaption = exports.mkTocItem = exports.mkTocList = exports.mkToc = exports.mkVerbatim = exports.mkMarkupCodeF = exports.mkFomattingCodeO = exports.mkFomattingCodeL = exports.mkFomattingCode = exports.mkBlankline = exports.mkBlock = exports.filterNulls = exports.mkNode = void 0;
|
|
4
4
|
const nanoid_1 = require("nanoid");
|
|
5
5
|
const mkNode = (attr) => {
|
|
6
6
|
return { ...attr };
|
|
@@ -33,10 +33,10 @@ const mkFomattingCodeL = (attrs, content) => {
|
|
|
33
33
|
return (0, exports.mkNode)({ ...attrs, type: 'fcode', name: 'L', content: (0, exports.filterNulls)(content) });
|
|
34
34
|
};
|
|
35
35
|
exports.mkFomattingCodeL = mkFomattingCodeL;
|
|
36
|
-
const
|
|
37
|
-
return (0, exports.mkNode)({ type: 'fcode', name: '
|
|
36
|
+
const mkFomattingCodeO = content => {
|
|
37
|
+
return (0, exports.mkNode)({ type: 'fcode', name: 'O', content: (0, exports.filterNulls)(content) });
|
|
38
38
|
};
|
|
39
|
-
exports.
|
|
39
|
+
exports.mkFomattingCodeO = mkFomattingCodeO;
|
|
40
40
|
const mkMarkupCodeF = (formula) => {
|
|
41
41
|
return (0, exports.mkNode)({ type: 'fcode', name: 'F', content: [{ type: 'text', value: formula }] });
|
|
42
42
|
};
|
|
@@ -46,8 +46,15 @@ const mkVerbatim = text => {
|
|
|
46
46
|
};
|
|
47
47
|
exports.mkVerbatim = mkVerbatim;
|
|
48
48
|
// Table of contents helpers
|
|
49
|
-
const mkToc = (content, title, location, foldedLevels) => {
|
|
50
|
-
return (0, exports.mkNode)({
|
|
49
|
+
const mkToc = (content, title, location, foldedLevels, folded) => {
|
|
50
|
+
return (0, exports.mkNode)({
|
|
51
|
+
type: 'toc',
|
|
52
|
+
title,
|
|
53
|
+
content,
|
|
54
|
+
location,
|
|
55
|
+
...(foldedLevels ? { foldedLevels } : {}),
|
|
56
|
+
...(folded !== undefined ? { folded } : {}),
|
|
57
|
+
});
|
|
51
58
|
};
|
|
52
59
|
exports.mkToc = mkToc;
|
|
53
60
|
const mkTocList = (content, level) => {
|
package/lib/exportHtml.js
CHANGED
|
@@ -59,6 +59,9 @@ const rules = {
|
|
|
59
59
|
'I<>': (0, handlers_1.wrapContent)('<em>', '</em>'),
|
|
60
60
|
'R<>': (0, handlers_1.wrapContent)('<var>', '</var>'),
|
|
61
61
|
'K<>': (0, handlers_1.wrapContent)('<kbd>', '</kbd>'),
|
|
62
|
+
'O<>': (0, handlers_1.wrapContent)('<del>', '</del>'),
|
|
63
|
+
'H<>': (0, handlers_1.wrapContent)('<sup>', '</sup>'),
|
|
64
|
+
'J<>': (0, handlers_1.wrapContent)('<sub>', '</sub>'),
|
|
62
65
|
'L<>': (0, handlers_1.setFn)((node, ctx) => {
|
|
63
66
|
let { meta } = node;
|
|
64
67
|
if (meta === null) {
|
|
@@ -226,15 +229,63 @@ const rules = {
|
|
|
226
229
|
writer.write(conf.getFirstValue('caption'));
|
|
227
230
|
writer.writeRaw('</caption>');
|
|
228
231
|
}
|
|
229
|
-
|
|
232
|
+
const innerCtx = { ...ctx, ...(node.align && { 'table.align': node.align }) };
|
|
233
|
+
const content = node.content || [];
|
|
234
|
+
const isHeaderRow = c => c && c.name === 'row' && Array.isArray(c.config) && c.config.some(a => a.name === 'header' && a.value !== false);
|
|
235
|
+
const hasHeader = content.some(isHeaderRow);
|
|
236
|
+
if (!hasHeader) {
|
|
237
|
+
interator(content, innerCtx);
|
|
238
|
+
writer.writeRaw('</table>');
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const rowNodes = content.filter(c => c && c.name === 'row');
|
|
242
|
+
const nonRowContent = content.filter(c => !c || c.name !== 'row');
|
|
243
|
+
let headerEnd = 0;
|
|
244
|
+
while (headerEnd < rowNodes.length && isHeaderRow(rowNodes[headerEnd]))
|
|
245
|
+
headerEnd++;
|
|
246
|
+
const headerRows = rowNodes.slice(0, headerEnd);
|
|
247
|
+
const bodyRows = rowNodes.slice(headerEnd);
|
|
248
|
+
interator(nonRowContent, innerCtx);
|
|
249
|
+
writer.writeRaw('<thead>');
|
|
250
|
+
interator(headerRows, innerCtx);
|
|
251
|
+
writer.writeRaw('</thead>');
|
|
252
|
+
if (bodyRows.length > 0) {
|
|
253
|
+
writer.writeRaw('<tbody>');
|
|
254
|
+
interator(bodyRows, innerCtx);
|
|
255
|
+
writer.writeRaw('</tbody>');
|
|
256
|
+
}
|
|
230
257
|
writer.writeRaw('</table>');
|
|
231
258
|
}),
|
|
232
259
|
':separator': handlers_1.emptyContent,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
260
|
+
row: (writer, processor) => (node, ctx, interator) => {
|
|
261
|
+
const conf = (0, config_1.default)(node, ctx);
|
|
262
|
+
const isHeader = conf.exists('header') && conf.getFirstValue('header') !== false;
|
|
263
|
+
writer.writeRaw('<tr>');
|
|
264
|
+
interator(node.content, { ...ctx, __row_header: isHeader, cellinRow: 0 });
|
|
265
|
+
writer.writeRaw('</tr>');
|
|
266
|
+
},
|
|
267
|
+
cell: (writer, processor) => (node, ctx, interator) => {
|
|
268
|
+
const tag = ctx.__row_header ? 'th' : 'td';
|
|
269
|
+
const conf = (0, config_1.default)(node, ctx);
|
|
270
|
+
const colspan = conf.exists('colspan') ? conf.getFirstValue('colspan') : null;
|
|
271
|
+
const rowspan = conf.exists('rowspan') ? conf.getFirstValue('rowspan') : null;
|
|
272
|
+
const colAlign = (alignMap => {
|
|
273
|
+
if (!Array.isArray(alignMap))
|
|
274
|
+
return null;
|
|
275
|
+
const num = ctx['cellinRow']++;
|
|
276
|
+
return alignMap[num] || null;
|
|
277
|
+
})(ctx['table.align']);
|
|
278
|
+
let attrs = '';
|
|
279
|
+
if (colspan !== null && Number(colspan) > 1)
|
|
280
|
+
attrs += ` colspan="${colspan}"`;
|
|
281
|
+
if (rowspan !== null && Number(rowspan) > 1)
|
|
282
|
+
attrs += ` rowspan="${rowspan}"`;
|
|
283
|
+
if (colAlign && ['left', 'right', 'center', 'justify'].includes(colAlign))
|
|
284
|
+
attrs += ` style="text-align:${colAlign}"`;
|
|
285
|
+
writer.writeRaw(`<${tag}${attrs}>`);
|
|
286
|
+
interator(node.content, ctx);
|
|
287
|
+
writer.writeRaw(`</${tag}>`);
|
|
288
|
+
},
|
|
238
289
|
// Toc
|
|
239
290
|
':toc': (writer, processor) => (node, ctx, interator) => {
|
|
240
291
|
writer.writeRaw('<div className="toc">');
|
package/lib/exportMarkdown.js
CHANGED
|
@@ -49,6 +49,9 @@ const rules = {
|
|
|
49
49
|
'I<>': (0, handlers_1.wrapContent)('*', '*'),
|
|
50
50
|
'R<>': (0, handlers_1.wrapContent)('*', '*'),
|
|
51
51
|
'K<>': (0, handlers_1.wrapContent)('`', '`'),
|
|
52
|
+
'O<>': (0, handlers_1.wrapContent)('~~', '~~'),
|
|
53
|
+
'H<>': (0, handlers_1.wrapContent)('<sup>', '</sup>'),
|
|
54
|
+
'J<>': (0, handlers_1.wrapContent)('<sub>', '</sub>'),
|
|
52
55
|
'L<>': (0, handlers_1.setFn)((node, ctx) => {
|
|
53
56
|
let { meta } = node;
|
|
54
57
|
if (meta === null) {
|
|
@@ -265,13 +268,57 @@ const rules = {
|
|
|
265
268
|
writer.writeRaw('**\n\n');
|
|
266
269
|
}
|
|
267
270
|
// collect rows data for proper Markdown table rendering
|
|
268
|
-
const rows = (node.content || []).filter(child => child.name === '
|
|
271
|
+
const rows = (node.content || []).filter(child => child.name === 'row');
|
|
269
272
|
if (rows.length === 0)
|
|
270
273
|
return;
|
|
271
|
-
const
|
|
274
|
+
const isRowHeader = row => Array.isArray(row.config) && row.config.some(c => c.name === 'header' && c.value !== false);
|
|
275
|
+
const cellSpan = (cell, name) => {
|
|
276
|
+
if (!Array.isArray(cell.config))
|
|
277
|
+
return 0;
|
|
278
|
+
const entry = cell.config.find(c => c.name === name);
|
|
279
|
+
if (!entry)
|
|
280
|
+
return 0;
|
|
281
|
+
const n = Number(entry.value);
|
|
282
|
+
return Number.isFinite(n) && n > 1 ? n : 0;
|
|
283
|
+
};
|
|
284
|
+
// GFM pipe-tables don't support colspan/rowspan — fall back to inline HTML
|
|
285
|
+
const hasSpans = rows.some(row => (row.content || []).some(c => c.name === 'cell' && (cellSpan(c, 'colspan') || cellSpan(c, 'rowspan'))));
|
|
286
|
+
const hasHeader = isRowHeader(rows[0]);
|
|
287
|
+
if (hasSpans) {
|
|
288
|
+
writer.writeRaw('<table>\n');
|
|
289
|
+
rows.forEach(row => {
|
|
290
|
+
const tag = isRowHeader(row) ? 'th' : 'td';
|
|
291
|
+
writer.writeRaw('<tr>');
|
|
292
|
+
const cells = (row.content || []).filter(c => c.name === 'cell');
|
|
293
|
+
cells.forEach(cell => {
|
|
294
|
+
const colspan = cellSpan(cell, 'colspan');
|
|
295
|
+
const rowspan = cellSpan(cell, 'rowspan');
|
|
296
|
+
let attrs = '';
|
|
297
|
+
if (colspan)
|
|
298
|
+
attrs += ` colspan="${colspan}"`;
|
|
299
|
+
if (rowspan)
|
|
300
|
+
attrs += ` rowspan="${rowspan}"`;
|
|
301
|
+
writer.writeRaw(`<${tag}${attrs}>`);
|
|
302
|
+
if (cell.content) {
|
|
303
|
+
cell.content.forEach(c => {
|
|
304
|
+
if (typeof c === 'string') {
|
|
305
|
+
writer.write(c.trim());
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
interator([c], ctx);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
writer.writeRaw(`</${tag}>`);
|
|
313
|
+
});
|
|
314
|
+
writer.writeRaw('</tr>\n');
|
|
315
|
+
});
|
|
316
|
+
writer.writeRaw('</table>\n');
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
272
319
|
// render each row
|
|
273
320
|
rows.forEach((row, rowIndex) => {
|
|
274
|
-
const cells = (row.content || []).filter(c => c.name === '
|
|
321
|
+
const cells = (row.content || []).filter(c => c.name === 'cell');
|
|
275
322
|
writer.writeRaw('|');
|
|
276
323
|
cells.forEach(cell => {
|
|
277
324
|
writer.writeRaw(' ');
|
|
@@ -308,9 +355,8 @@ const rules = {
|
|
|
308
355
|
writer.writeRaw('\n');
|
|
309
356
|
}),
|
|
310
357
|
':separator': handlers_1.emptyContent,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
table_head: handlers_1.emptyContent,
|
|
358
|
+
row: handlers_1.emptyContent,
|
|
359
|
+
cell: handlers_1.emptyContent,
|
|
314
360
|
// Toc
|
|
315
361
|
':toc': handlers_1.emptyContent,
|
|
316
362
|
':toc-list': handlers_1.emptyContent,
|