@podlite/schema 0.0.76 → 0.0.78
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 +8 -0
- package/esm/codes/read.d.ts +1 -2
- package/esm/codes/read.js +0 -5
- package/esm/codes/read.js.map +1 -1
- package/esm/codes/scan.d.ts +0 -1
- package/esm/codes/scan.js +5 -13
- package/esm/codes/scan.js.map +1 -1
- package/esm/exportHtml.js +7 -1
- package/esm/exportHtml.js.map +1 -1
- package/esm/exportMarkdown.js +7 -1
- package/esm/exportMarkdown.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/plugin-formatting-codes.js +28 -1
- package/esm/plugin-formatting-codes.js.map +1 -1
- package/esm/types.d.ts +5 -4
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/codes/read.d.ts +1 -2
- package/lib/codes/read.js +0 -5
- package/lib/codes/scan.d.ts +0 -1
- package/lib/codes/scan.js +5 -13
- package/lib/exportHtml.js +7 -1
- package/lib/exportMarkdown.js +7 -1
- package/lib/index.js +1 -1
- package/lib/plugin-formatting-codes.js +28 -1
- package/lib/types.d.ts +5 -4
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/schema/AstTree.json +89 -36
- package/schema/PodliteDocument.json +89 -36
|
@@ -5,6 +5,7 @@ import { isNamedBlock } from './helpers/makeTransformer.js';
|
|
|
5
5
|
import makeAttrs from './helpers/config.js';
|
|
6
6
|
import { parseAttributes } from './helpers/parseAttributes.js';
|
|
7
7
|
import { blockNameOf } from './helpers/blockName.js';
|
|
8
|
+
import { mkCaption } from './blocks-helpers.js';
|
|
8
9
|
// `=config C<> :allow<I>` names a markup code, not a block: the trailing angles
|
|
9
10
|
// are the marker, and what it declares belongs to the code they name
|
|
10
11
|
const codeConfigOwner = (name) => typeof name === 'string' && /^[A-Z]<>$/.test(name) ? name[0] : null;
|
|
@@ -32,12 +33,36 @@ const allowOf = (node) => {
|
|
|
32
33
|
const conf = makeAttrs(node, {});
|
|
33
34
|
return conf.exists('allow') ? conf.getAllValues('allow') : undefined;
|
|
34
35
|
};
|
|
36
|
+
// The text between codes as text nodes, all the way in, so a guard mark has a
|
|
37
|
+
// node to land on. V and E keep their content as written.
|
|
38
|
+
const asTextNodes = (nodes) => nodes.map(child => typeof child === 'string'
|
|
39
|
+
? { type: 'text', value: child }
|
|
40
|
+
: child && typeof child === 'object' && Array.isArray(child.content) && child.name !== 'V' && child.name !== 'E'
|
|
41
|
+
? { ...child, content: asTextNodes(child.content) }
|
|
42
|
+
: child);
|
|
43
|
+
// A caption =set gives is read for markup codes, with the codes this place
|
|
44
|
+
// allows; one written on the block is text. The value stays a string, since
|
|
45
|
+
// selectors and =set itself match on it. A caption with no code gets nothing.
|
|
46
|
+
const withSetCaption = (n, allowedIn) => {
|
|
47
|
+
if (!n || n.caption || !Array.isArray(n.config))
|
|
48
|
+
return n;
|
|
49
|
+
const item = n.config.find(c => c && c.name === 'caption');
|
|
50
|
+
if (!item || item.from !== 'set')
|
|
51
|
+
return n;
|
|
52
|
+
const value = Array.isArray(item.value) ? item.value[0] : item.value;
|
|
53
|
+
if (typeof value !== 'string')
|
|
54
|
+
return n;
|
|
55
|
+
const content = readCodes(value, { allowedIn, parseAttributes, issues: [] });
|
|
56
|
+
if (!content.some(c => c && typeof c === 'object' && c.type === 'fcode'))
|
|
57
|
+
return n;
|
|
58
|
+
return { ...n, caption: mkCaption(asTextNodes(content)) };
|
|
59
|
+
};
|
|
35
60
|
const middle = opt => tree => {
|
|
36
61
|
// the codes of one piece of text; a warning keeps the block it came from and its
|
|
37
62
|
// place in the text, and the parser turns that into a place in the source
|
|
38
63
|
const read = (text, allowed, allowedIn, block, inline = false) => {
|
|
39
64
|
const issues = [];
|
|
40
|
-
const content = readCodes(text, { allowed, allowedIn, parseAttributes,
|
|
65
|
+
const content = readCodes(text, { allowed, allowedIn, parseAttributes, issues });
|
|
41
66
|
const location = block && block.location;
|
|
42
67
|
const fragment = { text, inline };
|
|
43
68
|
if (inline && block && block.location)
|
|
@@ -80,6 +105,8 @@ const middle = opt => tree => {
|
|
|
80
105
|
':block': (n, ctx, visiter) => {
|
|
81
106
|
// a block is a lexical scope: a code configured inside it stays inside
|
|
82
107
|
const allowedIn = { ...(ctx.allowedIn || {}) };
|
|
108
|
+
// before any block is let through unread: a picture's caption is not its body
|
|
109
|
+
n = withSetCaption(n, allowedIn);
|
|
83
110
|
// only =pod may have childs blocks
|
|
84
111
|
if ('name' in n && n.name === 'pod')
|
|
85
112
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-formatting-codes.js","sourceRoot":"","sources":["../src/plugin-formatting-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,eAAe,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin-formatting-codes.js","sourceRoot":"","sources":["../src/plugin-formatting-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,eAAe,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,C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AE,GAAG,CAAC,KAAK,IAAI,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAC5F,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE,OAAO;gBAChB,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;oBACvB,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;oBACjC,OAAO,IAAI,CAAA;gBACb,CAAC;gBACD,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,GAAG,GAAG,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC;aACrG,CAAC,CAAA;YACF,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAA;QACzD,CAAC;KACF,CAAC,CAAA;IACF,8EAA8E;IAC9E,OAAO,iBAAiB,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAC/E,CAAC,CAAA;AACD,eAAe,MAAM,CAAA"}
|
package/esm/types.d.ts
CHANGED
|
@@ -126,17 +126,17 @@ export interface TocItem {
|
|
|
126
126
|
}
|
|
127
127
|
export interface BlockImage extends Omit<Block, 'content'> {
|
|
128
128
|
name: 'image';
|
|
129
|
-
caption?:
|
|
129
|
+
caption?: BlockCaption;
|
|
130
130
|
link?: string;
|
|
131
131
|
content: [Image, BlockCaption?];
|
|
132
132
|
}
|
|
133
133
|
export interface BlockPicture extends Omit<Block, 'content'> {
|
|
134
134
|
name: 'picture';
|
|
135
|
-
caption?:
|
|
135
|
+
caption?: BlockCaption;
|
|
136
136
|
link?: string;
|
|
137
137
|
content: [Image, BlockCaption?];
|
|
138
138
|
}
|
|
139
|
-
export interface BlockCaption extends Omit<Block, 'content' | 'location' | 'margin' | 'config' | 'id'> {
|
|
139
|
+
export interface BlockCaption extends Omit<Block, 'content' | 'location' | 'margin' | 'config' | 'id' | 'caption'> {
|
|
140
140
|
name: 'caption';
|
|
141
141
|
content: Array<Node>;
|
|
142
142
|
}
|
|
@@ -147,7 +147,7 @@ export interface RootBlock extends Omit<Block, 'location'> {
|
|
|
147
147
|
}
|
|
148
148
|
export interface ParseDiagnostic {
|
|
149
149
|
severity: 'warning';
|
|
150
|
-
code: 'value-unreadable' | 'directive-unreadable' | 'table-row-cells' | 'table-cell-outside-row' | 'table-mixed-separators' | 'table-source-unreadable' | 'table-source-empty' | 'table-source-deferred' | 'markup-code-unclosed' | 'markup-code-longer-run' | 'markup-code-foreign-closer' | 'markup-code-reserved' | 'markup-code-unsupported' | 'markup-code-unreadable'
|
|
150
|
+
code: 'value-unreadable' | 'directive-unreadable' | 'table-row-cells' | 'table-cell-outside-row' | 'table-mixed-separators' | 'table-source-unreadable' | 'table-source-empty' | 'table-source-deferred' | 'markup-code-unclosed' | 'markup-code-longer-run' | 'markup-code-foreign-closer' | 'markup-code-reserved' | 'markup-code-unsupported' | 'markup-code-unreadable';
|
|
151
151
|
message: string;
|
|
152
152
|
location: Location;
|
|
153
153
|
}
|
|
@@ -362,6 +362,7 @@ export interface Block {
|
|
|
362
362
|
id?: string;
|
|
363
363
|
guarded?: boolean;
|
|
364
364
|
set?: ConfigItem[];
|
|
365
|
+
caption?: BlockCaption;
|
|
365
366
|
}
|
|
366
367
|
export interface BlockPod extends Block {
|
|
367
368
|
name: 'pod';
|
package/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.78";
|
package/esm/version.js
CHANGED
package/lib/codes/read.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type CodeIssueKind = 'markup-code-unclosed' | 'markup-code-longer-run' | 'markup-code-foreign-closer' | 'markup-code-reserved' | 'markup-code-unsupported' | 'markup-code-unreadable'
|
|
1
|
+
export type CodeIssueKind = 'markup-code-unclosed' | 'markup-code-longer-run' | 'markup-code-foreign-closer' | 'markup-code-reserved' | 'markup-code-unsupported' | 'markup-code-unreadable';
|
|
2
2
|
export interface CodeIssue {
|
|
3
3
|
code: CodeIssueKind;
|
|
4
4
|
message: string;
|
|
@@ -11,7 +11,6 @@ export interface ReadOptions {
|
|
|
11
11
|
[code: string]: string[];
|
|
12
12
|
};
|
|
13
13
|
parseAttributes?: (text: string) => unknown;
|
|
14
|
-
entityInCode?: boolean;
|
|
15
14
|
issues?: CodeIssue[];
|
|
16
15
|
}
|
|
17
16
|
type Content = Array<string | {
|
package/lib/codes/read.js
CHANGED
|
@@ -28,7 +28,6 @@ const readCodes = (text, options = {}) => {
|
|
|
28
28
|
const scope = {
|
|
29
29
|
allowed: options.allowed,
|
|
30
30
|
allowedIn: options.allowedIn,
|
|
31
|
-
entityInCode: options.entityInCode,
|
|
32
31
|
};
|
|
33
32
|
const { codes, issues } = (0, scan_1.scanCodes)(text, scope);
|
|
34
33
|
const report = (code, message, start, end) => options.issues?.push({ code, message, start, end });
|
|
@@ -159,10 +158,6 @@ const readCodes = (text, options = {}) => {
|
|
|
159
158
|
},
|
|
160
159
|
];
|
|
161
160
|
}
|
|
162
|
-
if (name === 'C' && !(options.allowedIn?.C || []).includes('E'))
|
|
163
|
-
for (const child of code.children)
|
|
164
|
-
if (child.name === 'E')
|
|
165
|
-
report('markup-code-entity-in-code', 'E<> inside C<> reads as an entity only in this release; to keep it, write =config C<> :allow<E>', child.start, child.end);
|
|
166
161
|
return [{ content: children(), type: 'fcode', name }];
|
|
167
162
|
}
|
|
168
163
|
};
|
package/lib/codes/scan.d.ts
CHANGED
package/lib/codes/scan.js
CHANGED
|
@@ -32,23 +32,19 @@ const scanCodes = (text, scope = {}) => {
|
|
|
32
32
|
runEnd[i] = i + 1 < n && text[i + 1] === text[i] ? runEnd[i + 1] : i + 1;
|
|
33
33
|
const runFrom = (i) => runEnd[i] - i;
|
|
34
34
|
const fragmentAllows = (name) => !scope.allowed?.length || scope.allowed.includes(name);
|
|
35
|
-
const codeAllows = (outer, name
|
|
35
|
+
const codeAllows = (outer, name) => {
|
|
36
36
|
if (outer === null || !VERBATIM_CODES.includes(outer))
|
|
37
37
|
return true;
|
|
38
|
-
// the transition reads what the earlier reader read: E<…> with angles, not E«…»,
|
|
39
|
-
// and not inside a literal pair of the code, as in C<G<E<32>>>
|
|
40
|
-
if (outer === 'C' && name === 'E' && scope.entityInCode && bracket === '<' && depth === 0)
|
|
41
|
-
return true;
|
|
42
38
|
return (scope.allowedIn?.[outer] || []).includes(name);
|
|
43
39
|
};
|
|
44
|
-
const openerAt = (i, outer
|
|
40
|
+
const openerAt = (i, outer) => {
|
|
45
41
|
const name = text[i];
|
|
46
42
|
if (!isLetter(name) || i + 1 >= n)
|
|
47
43
|
return null;
|
|
48
44
|
const next = text[i + 1];
|
|
49
45
|
if (next !== '<' && next !== '«')
|
|
50
46
|
return null;
|
|
51
|
-
if (!fragmentAllows(name) || !codeAllows(outer, name
|
|
47
|
+
if (!fragmentAllows(name) || !codeAllows(outer, name))
|
|
52
48
|
return null;
|
|
53
49
|
return { name, bracket: next, length: next === '«' ? 1 : runFrom(i + 1) };
|
|
54
50
|
};
|
|
@@ -60,7 +56,6 @@ const scanCodes = (text, scope = {}) => {
|
|
|
60
56
|
start,
|
|
61
57
|
bodyStart,
|
|
62
58
|
depth: 0,
|
|
63
|
-
angles: 0,
|
|
64
59
|
at: bodyStart,
|
|
65
60
|
own: [],
|
|
66
61
|
passed: [],
|
|
@@ -144,7 +139,7 @@ const scanCodes = (text, scope = {}) => {
|
|
|
144
139
|
let i = frame.at;
|
|
145
140
|
while (i < n) {
|
|
146
141
|
const c = text[i];
|
|
147
|
-
const opener = openerAt(i, frame.name
|
|
142
|
+
const opener = openerAt(i, frame.name);
|
|
148
143
|
if (opener) {
|
|
149
144
|
const child = memo.get(i);
|
|
150
145
|
if (!child || !child.done) {
|
|
@@ -166,8 +161,6 @@ const scanCodes = (text, scope = {}) => {
|
|
|
166
161
|
frame.depth++;
|
|
167
162
|
else
|
|
168
163
|
frame.own.push({ at: i, char: '<', length: m });
|
|
169
|
-
if (frame.bracket === '«')
|
|
170
|
-
frame.angles += m;
|
|
171
164
|
i += m;
|
|
172
165
|
continue;
|
|
173
166
|
}
|
|
@@ -190,7 +183,6 @@ const scanCodes = (text, scope = {}) => {
|
|
|
190
183
|
}
|
|
191
184
|
else {
|
|
192
185
|
frame.own.push({ at: i, char: '>', length: m });
|
|
193
|
-
frame.angles = Math.max(0, frame.angles - m);
|
|
194
186
|
}
|
|
195
187
|
i += m;
|
|
196
188
|
continue;
|
|
@@ -237,7 +229,7 @@ const scanCodes = (text, scope = {}) => {
|
|
|
237
229
|
stack.pop();
|
|
238
230
|
continue;
|
|
239
231
|
}
|
|
240
|
-
const child = makeFrame(need, openerAt(need, frame.name
|
|
232
|
+
const child = makeFrame(need, openerAt(need, frame.name));
|
|
241
233
|
memo.set(need, child);
|
|
242
234
|
stack.push(child);
|
|
243
235
|
}
|
package/lib/exportHtml.js
CHANGED
|
@@ -450,7 +450,13 @@ const rules = {
|
|
|
450
450
|
'table:block': (0, handlers_1.handleNested)((writer, processor) => (node, ctx, interator) => {
|
|
451
451
|
const conf = (0, config_1.default)(node, ctx);
|
|
452
452
|
writer.writeRaw(openTag('table', node, ctx));
|
|
453
|
-
|
|
453
|
+
// a caption =set gave holds its codes; one written on the table is text
|
|
454
|
+
if (node.caption) {
|
|
455
|
+
writer.writeRaw('<caption>');
|
|
456
|
+
interator(node.caption.content, ctx);
|
|
457
|
+
writer.writeRaw('</caption>');
|
|
458
|
+
}
|
|
459
|
+
else if (conf.exists('caption')) {
|
|
454
460
|
writer.writeRaw('<caption>');
|
|
455
461
|
writer.write(covered(node, ctx, String(conf.getFirstValue('caption'))));
|
|
456
462
|
writer.writeRaw('</caption>');
|
package/lib/exportMarkdown.js
CHANGED
|
@@ -467,7 +467,13 @@ const rules = {
|
|
|
467
467
|
// table section
|
|
468
468
|
'table:block': (0, handlers_1.handleNested)((writer, processor) => (node, ctx, interator) => {
|
|
469
469
|
const conf = (0, config_1.default)(node, ctx);
|
|
470
|
-
|
|
470
|
+
// a caption with codes of its own stands as a paragraph: bold around it would
|
|
471
|
+
// hide the bold inside and break on an emphasis that touches a word
|
|
472
|
+
if (node.caption) {
|
|
473
|
+
interator(node.caption.content, ctx);
|
|
474
|
+
writer.writeRaw('\n\n');
|
|
475
|
+
}
|
|
476
|
+
else if (conf.exists('caption')) {
|
|
471
477
|
writer.writeRaw('**');
|
|
472
478
|
writer.write(covered(node, ctx, String(conf.getFirstValue('caption'))));
|
|
473
479
|
writer.writeRaw('**\n\n');
|
package/lib/index.js
CHANGED
|
@@ -239,7 +239,7 @@ function makeTree() {
|
|
|
239
239
|
}
|
|
240
240
|
const parse = makeTree().parse;
|
|
241
241
|
exports.parse = parse;
|
|
242
|
-
const parseFormattingCodes = (text, options = {}) => (0, read_1.readCodes)(text, { parseAttributes: parseAttributes_2.parseAttributes,
|
|
242
|
+
const parseFormattingCodes = (text, options = {}) => (0, read_1.readCodes)(text, { parseAttributes: parseAttributes_2.parseAttributes, ...options });
|
|
243
243
|
exports.parseFormattingCodes = parseFormattingCodes;
|
|
244
244
|
var exportHtml_1 = require("./exportHtml");
|
|
245
245
|
Object.defineProperty(exports, "toHtml", { enumerable: true, get: function () { return __importDefault(exportHtml_1).default; } });
|
|
@@ -10,6 +10,7 @@ const makeTransformer_2 = require("./helpers/makeTransformer");
|
|
|
10
10
|
const config_1 = __importDefault(require("./helpers/config"));
|
|
11
11
|
const parseAttributes_1 = require("./helpers/parseAttributes");
|
|
12
12
|
const blockName_1 = require("./helpers/blockName");
|
|
13
|
+
const blocks_helpers_1 = require("./blocks-helpers");
|
|
13
14
|
// `=config C<> :allow<I>` names a markup code, not a block: the trailing angles
|
|
14
15
|
// are the marker, and what it declares belongs to the code they name
|
|
15
16
|
const codeConfigOwner = (name) => typeof name === 'string' && /^[A-Z]<>$/.test(name) ? name[0] : null;
|
|
@@ -37,12 +38,36 @@ const allowOf = (node) => {
|
|
|
37
38
|
const conf = (0, config_1.default)(node, {});
|
|
38
39
|
return conf.exists('allow') ? conf.getAllValues('allow') : undefined;
|
|
39
40
|
};
|
|
41
|
+
// The text between codes as text nodes, all the way in, so a guard mark has a
|
|
42
|
+
// node to land on. V and E keep their content as written.
|
|
43
|
+
const asTextNodes = (nodes) => nodes.map(child => typeof child === 'string'
|
|
44
|
+
? { type: 'text', value: child }
|
|
45
|
+
: child && typeof child === 'object' && Array.isArray(child.content) && child.name !== 'V' && child.name !== 'E'
|
|
46
|
+
? { ...child, content: asTextNodes(child.content) }
|
|
47
|
+
: child);
|
|
48
|
+
// A caption =set gives is read for markup codes, with the codes this place
|
|
49
|
+
// allows; one written on the block is text. The value stays a string, since
|
|
50
|
+
// selectors and =set itself match on it. A caption with no code gets nothing.
|
|
51
|
+
const withSetCaption = (n, allowedIn) => {
|
|
52
|
+
if (!n || n.caption || !Array.isArray(n.config))
|
|
53
|
+
return n;
|
|
54
|
+
const item = n.config.find(c => c && c.name === 'caption');
|
|
55
|
+
if (!item || item.from !== 'set')
|
|
56
|
+
return n;
|
|
57
|
+
const value = Array.isArray(item.value) ? item.value[0] : item.value;
|
|
58
|
+
if (typeof value !== 'string')
|
|
59
|
+
return n;
|
|
60
|
+
const content = (0, read_1.readCodes)(value, { allowedIn, parseAttributes: parseAttributes_1.parseAttributes, issues: [] });
|
|
61
|
+
if (!content.some(c => c && typeof c === 'object' && c.type === 'fcode'))
|
|
62
|
+
return n;
|
|
63
|
+
return { ...n, caption: (0, blocks_helpers_1.mkCaption)(asTextNodes(content)) };
|
|
64
|
+
};
|
|
40
65
|
const middle = opt => tree => {
|
|
41
66
|
// the codes of one piece of text; a warning keeps the block it came from and its
|
|
42
67
|
// place in the text, and the parser turns that into a place in the source
|
|
43
68
|
const read = (text, allowed, allowedIn, block, inline = false) => {
|
|
44
69
|
const issues = [];
|
|
45
|
-
const content = (0, read_1.readCodes)(text, { allowed, allowedIn, parseAttributes: parseAttributes_1.parseAttributes,
|
|
70
|
+
const content = (0, read_1.readCodes)(text, { allowed, allowedIn, parseAttributes: parseAttributes_1.parseAttributes, issues });
|
|
46
71
|
const location = block && block.location;
|
|
47
72
|
const fragment = { text, inline };
|
|
48
73
|
if (inline && block && block.location)
|
|
@@ -85,6 +110,8 @@ const middle = opt => tree => {
|
|
|
85
110
|
':block': (n, ctx, visiter) => {
|
|
86
111
|
// a block is a lexical scope: a code configured inside it stays inside
|
|
87
112
|
const allowedIn = { ...(ctx.allowedIn || {}) };
|
|
113
|
+
// before any block is let through unread: a picture's caption is not its body
|
|
114
|
+
n = withSetCaption(n, allowedIn);
|
|
88
115
|
// only =pod may have childs blocks
|
|
89
116
|
if ('name' in n && n.name === 'pod')
|
|
90
117
|
return {
|
package/lib/types.d.ts
CHANGED
|
@@ -126,17 +126,17 @@ export interface TocItem {
|
|
|
126
126
|
}
|
|
127
127
|
export interface BlockImage extends Omit<Block, 'content'> {
|
|
128
128
|
name: 'image';
|
|
129
|
-
caption?:
|
|
129
|
+
caption?: BlockCaption;
|
|
130
130
|
link?: string;
|
|
131
131
|
content: [Image, BlockCaption?];
|
|
132
132
|
}
|
|
133
133
|
export interface BlockPicture extends Omit<Block, 'content'> {
|
|
134
134
|
name: 'picture';
|
|
135
|
-
caption?:
|
|
135
|
+
caption?: BlockCaption;
|
|
136
136
|
link?: string;
|
|
137
137
|
content: [Image, BlockCaption?];
|
|
138
138
|
}
|
|
139
|
-
export interface BlockCaption extends Omit<Block, 'content' | 'location' | 'margin' | 'config' | 'id'> {
|
|
139
|
+
export interface BlockCaption extends Omit<Block, 'content' | 'location' | 'margin' | 'config' | 'id' | 'caption'> {
|
|
140
140
|
name: 'caption';
|
|
141
141
|
content: Array<Node>;
|
|
142
142
|
}
|
|
@@ -147,7 +147,7 @@ export interface RootBlock extends Omit<Block, 'location'> {
|
|
|
147
147
|
}
|
|
148
148
|
export interface ParseDiagnostic {
|
|
149
149
|
severity: 'warning';
|
|
150
|
-
code: 'value-unreadable' | 'directive-unreadable' | 'table-row-cells' | 'table-cell-outside-row' | 'table-mixed-separators' | 'table-source-unreadable' | 'table-source-empty' | 'table-source-deferred' | 'markup-code-unclosed' | 'markup-code-longer-run' | 'markup-code-foreign-closer' | 'markup-code-reserved' | 'markup-code-unsupported' | 'markup-code-unreadable'
|
|
150
|
+
code: 'value-unreadable' | 'directive-unreadable' | 'table-row-cells' | 'table-cell-outside-row' | 'table-mixed-separators' | 'table-source-unreadable' | 'table-source-empty' | 'table-source-deferred' | 'markup-code-unclosed' | 'markup-code-longer-run' | 'markup-code-foreign-closer' | 'markup-code-reserved' | 'markup-code-unsupported' | 'markup-code-unreadable';
|
|
151
151
|
message: string;
|
|
152
152
|
location: Location;
|
|
153
153
|
}
|
|
@@ -362,6 +362,7 @@ export interface Block {
|
|
|
362
362
|
id?: string;
|
|
363
363
|
guarded?: boolean;
|
|
364
364
|
set?: ConfigItem[];
|
|
365
|
+
caption?: BlockCaption;
|
|
365
366
|
}
|
|
366
367
|
export interface BlockPod extends Block {
|
|
367
368
|
name: 'pod';
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.78";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED