@podlite/schema 0.0.67 → 0.0.68

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.
Files changed (55) hide show
  1. package/CHANGELOG.podlite +32 -0
  2. package/esm/ast-helpers.d.ts +25 -1
  3. package/esm/ast-helpers.js +101 -2
  4. package/esm/ast-helpers.js.map +1 -1
  5. package/esm/attribute-names.d.ts +5 -0
  6. package/esm/attribute-names.js +36 -0
  7. package/esm/attribute-names.js.map +1 -0
  8. package/esm/exportAny.js +2 -2
  9. package/esm/exportAny.js.map +1 -1
  10. package/esm/exportHtml.js +50 -17
  11. package/esm/exportHtml.js.map +1 -1
  12. package/esm/exportMarkdown.js +28 -16
  13. package/esm/exportMarkdown.js.map +1 -1
  14. package/esm/folded-sections.d.ts +1 -0
  15. package/esm/folded-sections.js +80 -0
  16. package/esm/folded-sections.js.map +1 -0
  17. package/esm/grammarfc.js +6099 -15834
  18. package/esm/grammarfc.js.map +1 -1
  19. package/esm/helpers/corePlugins.js +9 -3
  20. package/esm/helpers/corePlugins.js.map +1 -1
  21. package/esm/helpers/html-attr.d.ts +1 -0
  22. package/esm/helpers/html-attr.js +6 -0
  23. package/esm/helpers/html-attr.js.map +1 -0
  24. package/esm/index.d.ts +4 -1
  25. package/esm/index.js +4 -1
  26. package/esm/index.js.map +1 -1
  27. package/esm/pluggableParser.d.ts +1 -1
  28. package/esm/pluggableParser.js +4 -1
  29. package/esm/pluggableParser.js.map +1 -1
  30. package/esm/types.d.ts +27 -16
  31. package/esm/version.d.ts +1 -1
  32. package/esm/version.js +1 -1
  33. package/lib/ast-helpers.d.ts +25 -1
  34. package/lib/ast-helpers.js +106 -3
  35. package/lib/attribute-names.d.ts +5 -0
  36. package/lib/attribute-names.js +41 -0
  37. package/lib/exportAny.js +1 -1
  38. package/lib/exportHtml.js +52 -19
  39. package/lib/exportMarkdown.js +27 -15
  40. package/lib/folded-sections.d.ts +1 -0
  41. package/lib/folded-sections.js +84 -0
  42. package/lib/grammarfc.js +6099 -15834
  43. package/lib/helpers/corePlugins.js +9 -3
  44. package/lib/helpers/html-attr.d.ts +1 -0
  45. package/lib/helpers/html-attr.js +10 -0
  46. package/lib/index.d.ts +4 -1
  47. package/lib/index.js +7 -1
  48. package/lib/pluggableParser.d.ts +1 -1
  49. package/lib/pluggableParser.js +5 -1
  50. package/lib/types.d.ts +27 -16
  51. package/lib/version.d.ts +1 -1
  52. package/lib/version.js +1 -1
  53. package/package.json +1 -1
  54. package/schema/AstTree.json +588 -436
  55. package/schema/PodliteDocument.json +588 -436
@@ -1,12 +1,18 @@
1
1
  import { content } from '..';
2
+ import { writtenValue } from '../ast-helpers';
3
+ import { quoteAttribute } from './html-attr';
2
4
  export const core = {
3
5
  ':image': {
4
6
  toHtml: writer => node => {
5
7
  if (typeof node !== 'string' && 'type' in node && node.type === 'image') {
6
8
  writer.writeRaw(`<img`);
7
- writer.writeRaw(` src="${node.src}"`);
8
- if (node.alt) {
9
- writer.writeRaw(` alt="${node.alt}"`);
9
+ writer.writeRaw(` src="${quoteAttribute(String(node.src ?? ''))}"`);
10
+ // html reads a missing alt as "this image is part of the content" and an
11
+ // empty one as "decorative", so an alternative text the author never wrote
12
+ // is left out
13
+ const alt = writtenValue(node.alt);
14
+ if (alt !== undefined) {
15
+ writer.writeRaw(` alt="${quoteAttribute(alt)}"`);
10
16
  }
11
17
  writer.writeRaw(`/>`);
12
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"corePlugins.js","sourceRoot":"","sources":["../../src/helpers/corePlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAE5B,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;YACvB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,O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,KAAK,SAAS,EAAE,CAAC;oBACtB,MAAM,CAAC,QAAQ,CAAC,SAAS,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBAClD,CAAC;gBACD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;QACH,CAAC;KACF;IACD,KAAK,EAAE;QACL,MAAM,EAAE,OAAO;KAChB;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,OAAO;KAChB;CACF,CAAA;AACD,eAAe,IAAI,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const quoteAttribute: (value: string) => string;
@@ -0,0 +1,6 @@
1
+ // The value of an attribute written inside double quotes. The ampersand goes
2
+ // first: escaping it after the quote would rewrite the `&quot;` this produced. A
3
+ // value arrives as document text, so every `&` in it is a literal one the
4
+ // browser must not read as a character reference.
5
+ export const quoteAttribute = (value) => value.replace(/&/g, '&amp;').replace(/"/g, '&quot;');
6
+ //# sourceMappingURL=html-attr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-attr.js","sourceRoot":"","sources":["../../src/helpers/html-attr.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,iFAAiF;AACjF,0EAA0E;AAC1E,kDAAkD;AAClD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA"}
package/esm/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { PodliteDocument } from './types';
4
4
  export { AstTree } from './types';
5
5
  export * from './types';
6
6
  export * from './block-names';
7
+ export * from './attribute-names';
7
8
  export * from './blocks-helpers';
8
9
  export * from './query-helpers';
9
10
  export * from './ast-helpers';
@@ -14,10 +15,11 @@ export { toAny } from './exportAny';
14
15
  export { makeAttrs, codeConfigWithDefaults } from './helpers/config';
15
16
  export { parseAttributes } from './helpers/parseAttributes';
16
17
  export { readLinkConfig } from './helpers/link-config';
18
+ export { quoteAttribute } from './helpers/html-attr';
17
19
  export type { LinkConfig } from './helpers/link-config';
18
20
  export { pluginCleanLocation } from './plugin-clean-location';
19
21
  export { toAnyRules } from './helpers/plugins';
20
- export { podlitePluggable, Podlite, PodliteExport, cleanIds, frozenIds } from './pluggableParser';
22
+ export { podlitePluggable, Podlite, PodliteExport, cleanIds, frozenIds, headingId } from './pluggableParser';
21
23
  export declare function toAst(): {};
22
24
  export type SchemaValidationError = ErrorObject<string, Record<string, any>>;
23
25
  export declare function getTextContentFromNode(node: PodNode): string;
@@ -89,6 +91,7 @@ export { default as toMarkdown } from './exportMarkdown';
89
91
  export { default as Writer } from './writer';
90
92
  export { parseSelector, runSelector, filePathMatches } from './selectors';
91
93
  export { markGuarded, isCovered } from './guard';
94
+ export { applyFoldedSections } from './folded-sections';
92
95
  export type { SelectorDoc, ParsedSelector } from './selectors';
93
96
  export { applyImageBase } from './image-base';
94
97
  export { version } from './version';
package/esm/index.js CHANGED
@@ -5,6 +5,7 @@ import * as jsonShemes from '../schema';
5
5
  import { makeInterator } from './ast-inerator';
6
6
  export * from './types';
7
7
  export * from './block-names';
8
+ export * from './attribute-names';
8
9
  export * from './blocks-helpers';
9
10
  export * from './query-helpers';
10
11
  export * from './ast-helpers';
@@ -15,9 +16,10 @@ export { toAny } from './exportAny';
15
16
  export { makeAttrs, codeConfigWithDefaults } from './helpers/config';
16
17
  export { parseAttributes } from './helpers/parseAttributes';
17
18
  export { readLinkConfig } from './helpers/link-config';
19
+ export { quoteAttribute } from './helpers/html-attr';
18
20
  export { pluginCleanLocation } from './plugin-clean-location';
19
21
  export { toAnyRules } from './helpers/plugins';
20
- export { podlitePluggable, cleanIds, frozenIds } from './pluggableParser';
22
+ export { podlitePluggable, cleanIds, frozenIds, headingId } from './pluggableParser';
21
23
  import * as parser from './grammar';
22
24
  import { parse as parseFcodes } from './grammarfc';
23
25
  import { parseAttributes } from './helpers/parseAttributes';
@@ -158,6 +160,7 @@ export { default as toMarkdown } from './exportMarkdown';
158
160
  export { default as Writer } from './writer';
159
161
  export { parseSelector, runSelector, filePathMatches } from './selectors';
160
162
  export { markGuarded, isCovered } from './guard';
163
+ export { applyFoldedSections } from './folded-sections';
161
164
  export { applyImageBase } from './image-base';
162
165
  export { version } from './version';
163
166
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAoC,MAAM,KAAK,CAAA;AACtD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,KAAK,UAAU,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,gBAAgB,EAA0B,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAEjG,O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M,EAAE,CAAA;AAC7B,MAAM,KAAK,GAAa,QAAQ,EAAE,CAAC,KAAK,CAAA;AACxC,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,CAAA;AACzB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,UAAkC,EAAE,EAAE,EAAE,CACzF,WAAW,CAAC,IAAI,EAAE,EAAE,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACzE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Plugins, PodliteDocument, parseOpt } from '.';
2
- export { cleanIds, frozenIds } from './helpers/ids';
2
+ export { cleanIds, frozenIds, headingId } from './helpers/ids';
3
3
  export interface podlitePluggableOpt {
4
4
  plugins?: Plugins;
5
5
  }
@@ -6,7 +6,8 @@ import { propagateConfigDefaults } from './helpers/configPropagation';
6
6
  import { attachHeadingNumberPrefix } from './helpers/headingNumbering';
7
7
  import { promoteOrderedLists } from './helpers/itemNumbering';
8
8
  import { markGuarded } from './guard';
9
- export { cleanIds, frozenIds } from './helpers/ids';
9
+ import { applyFoldedSections } from './folded-sections';
10
+ export { cleanIds, frozenIds, headingId } from './helpers/ids';
10
11
  export const podlitePluggable = ({ plugins = {} } = {}) => {
11
12
  let instance = function () { };
12
13
  let _plugins = [];
@@ -72,6 +73,7 @@ export const podlitePluggable = ({ plugins = {} } = {}) => {
72
73
  promoteOrderedLists(resultAfter.interator);
73
74
  attachHeadingNumberPrefix(resultAfter.interator);
74
75
  markGuarded(resultAfter.interator);
76
+ resultAfter.interator = applyFoldedSections(resultAfter.interator);
75
77
  }
76
78
  return resultAfter;
77
79
  }
@@ -80,6 +82,7 @@ export const podlitePluggable = ({ plugins = {} } = {}) => {
80
82
  promoteOrderedLists(result.interator);
81
83
  attachHeadingNumberPrefix(result.interator);
82
84
  markGuarded(result.interator);
85
+ result.interator = applyFoldedSections(result.interator);
83
86
  }
84
87
  return result;
85
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pluggableParser.js","sourceRoot":"","sources":["../src/pluggableParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,WAAW,EAAY,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,CAAA;AACtG,OAAO,UAAU,MAAM,kBAAkB,CAAA;AACzC,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,IAAI,MAAM,uBAAuB,CAAA;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AA0BnD,MAAM,CAAC,MAAM,gBAAgB,GAA8C,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IACnG,IAAI,QAAQ,GAAY,cAAa,CAAC,CAAA;IACtC,IAAI,QAAQ,GAAc,EAAE,CAAA;IAE5B,QAAQ,CAAC,GAAG,GAAG,CAAC,GAAY,EAAE,EAAE;QAC9B,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Q,CAAC,UAAU,EAAE,CAAC,CAAA;QACjE,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC,CAAA;IAED,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAC,EAAE;QAC1B,MAAM,iBAAiB,GAAG,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;QACzE,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC7D,CAAC,CAAA;IAED,QAAQ,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAA;IAEpC,oBAAoB;IACpB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAClB,wBAAwB;IACxB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA"}
package/esm/types.d.ts CHANGED
@@ -100,11 +100,16 @@ export interface Image {
100
100
  alt?: string;
101
101
  link?: string;
102
102
  }
103
+ export interface ParaBuilt {
104
+ type: 'para';
105
+ content: Array<Node | FormattingCodes>;
106
+ }
103
107
  export interface Toc {
104
108
  type: 'toc';
105
109
  title?: string;
106
110
  folded?: boolean;
107
111
  foldedLevels?: Record<number, boolean>;
112
+ location?: Location;
108
113
  content: TocList;
109
114
  }
110
115
  export interface TocList {
@@ -114,8 +119,8 @@ export interface TocList {
114
119
  }
115
120
  export interface TocItem {
116
121
  type: 'toc-item';
117
- node: PodNode;
118
- content: Array<Node>;
122
+ node: PodNode | ParaBuilt;
123
+ content: Array<Node | ParaBuilt>;
119
124
  }
120
125
  export interface BlockImage extends Omit<Block, 'content'> {
121
126
  name: 'image';
@@ -152,7 +157,7 @@ export interface FormattingCodeB {
152
157
  export interface FormattingCodeC {
153
158
  type: 'fcode';
154
159
  name: 'C';
155
- content?: Array<FormattingCodes | string>;
160
+ content?: Array<Node>;
156
161
  }
157
162
  export interface FormattingCodeE {
158
163
  type: 'fcode';
@@ -179,23 +184,23 @@ export interface FormattingCodeF {
179
184
  export interface FormattingCodeN {
180
185
  type: 'fcode';
181
186
  name: 'N';
182
- content?: Array<FormattingCodes | string>;
187
+ content?: Array<Node>;
183
188
  }
184
189
  export interface FormattingCodeX {
185
190
  type: 'fcode';
186
191
  name: 'X';
187
192
  entry: Array<string> | null;
188
- content?: Array<FormattingCodes | string>;
193
+ content?: Array<Node>;
189
194
  }
190
195
  export interface FormattingCodeZ {
191
196
  type: 'fcode';
192
197
  name: 'Z';
193
- content?: string;
198
+ content?: string | Text;
194
199
  }
195
200
  export interface FormattingCodeV {
196
201
  type: 'fcode';
197
202
  name: 'V';
198
- content?: string;
203
+ content?: string | Text;
199
204
  }
200
205
  export interface FormattingCodeS {
201
206
  type: 'fcode';
@@ -211,7 +216,7 @@ export interface FormattingCodeD {
211
216
  type: 'fcode';
212
217
  name: 'D';
213
218
  synonyms: Array<string>;
214
- content: string;
219
+ content: Array<Node>;
215
220
  }
216
221
  export interface FormattingCodeL {
217
222
  type: 'fcode';
@@ -225,18 +230,18 @@ export interface FormattingCodeW {
225
230
  name: 'W';
226
231
  meta: string | null;
227
232
  config?: ConfigItem[];
228
- content: string | Text | [Text];
233
+ content: Array<Node>;
229
234
  }
230
235
  export interface FormattingCodeI {
231
236
  type: 'fcode';
232
237
  name: 'I';
233
- meta: string;
234
- content: string | Text;
238
+ meta?: string;
239
+ content: Array<Node>;
235
240
  }
236
241
  export interface FormattingCodeAny {
237
242
  type: 'fcode';
238
243
  name: string;
239
- content?: Array<FormattingCodes | string>;
244
+ content?: Array<Node>;
240
245
  }
241
246
  export interface Ambient {
242
247
  type: 'ambient';
@@ -260,6 +265,12 @@ export interface Para {
260
265
  location: Location;
261
266
  content: Array<Node | FormattingCodes>;
262
267
  }
268
+ export interface ParaTerm {
269
+ type: 'para';
270
+ name: 'term';
271
+ text: string;
272
+ content: Array<Node | FormattingCodes>;
273
+ }
263
274
  export interface Code {
264
275
  type: 'code';
265
276
  text: string;
@@ -273,8 +284,8 @@ export interface BlankLine {
273
284
  export interface List {
274
285
  type: 'list';
275
286
  level: string | number;
276
- content: Array<BlockItem | BlankLine | List>;
277
- list: 'itemized';
287
+ content: Array<BlockItem | BlockDefn | BlankLine | List>;
288
+ list: 'itemized' | 'task' | 'variable';
278
289
  }
279
290
  export interface ConfigItemKV {
280
291
  [key: string]: string | number | boolean;
@@ -387,7 +398,7 @@ export interface TableSeparator {
387
398
  export type BlockAny = BlockNamed;
388
399
  export interface BlockNamed extends Omit<Block, 'content'> {
389
400
  name: string;
390
- content: [(Verbatim | Para | Code)?] | Array<Image | BlockCaption> | RootBlock;
401
+ content: Array<Node> | RootBlock;
391
402
  }
392
403
  export interface BlockDiagram extends Omit<BlockNamed, 'content'> {
393
404
  name: 'Diagram';
@@ -408,7 +419,7 @@ export interface BlockFormula extends Omit<BlockNamed, 'content'> {
408
419
  content: [Verbatim];
409
420
  }
410
421
  export type FormattingCodes = FormattingCodeA | FormattingCodeC | FormattingCodeB | FormattingCodeD | FormattingCodeE | FormattingCodeF | FormattingCodeI | FormattingCodeL | FormattingCodeW | FormattingCodeN | FormattingCodeX | FormattingCodeZ | FormattingCodeV | FormattingCodeS | FormattingCodeAny;
411
- export type PodNode = Ambient | BlockPod | BlockData | BlockFormula | BlockCode | BlankLine | BlockNested | BlockMarkdown | BlockOutput | BlockInput | BlockInclude | BlockPara | BlockHead | BlockComment | BlockDefn | string | Para | Text | Code | BlockNamed | BlockAny | Verbatim | BlockTable | List | BlockConfig | BlockItem | Alias | BlockToc | BlockPicture | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
422
+ export type PodNode = Ambient | BlockPod | BlockData | BlockFormula | BlockCode | BlankLine | BlockNested | BlockMarkdown | BlockOutput | BlockInput | BlockInclude | BlockPara | BlockHead | BlockComment | BlockDefn | string | Para | ParaTerm | ParaBuilt | Text | Code | BlockNamed | BlockAny | Verbatim | BlockTable | List | BlockConfig | BlockItem | Alias | BlockToc | BlockPicture | BlockImage | Image | RootBlock | Separator | BlockCaption | FormattingCodes | Toc;
412
423
  export type Node = PodNode;
413
424
  export type AstTree = Array<PodNode>;
414
425
  export type PodliteDocument = RootBlock;
package/esm/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.0.67";
1
+ export declare const version = "0.0.68";
package/esm/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // generated by scripts/inject-version.mjs — do not edit by hand
2
- export const version = '0.0.67';
2
+ export const version = '0.0.68';
3
3
  //# sourceMappingURL=version.js.map
@@ -17,7 +17,31 @@ export declare const indexAnchors: (tree: unknown, style?: AnchorStyle) => Ancho
17
17
  export declare const restyleAnchors: (index: AnchorIndex | undefined, style: AnchorStyle) => AnchorIndex | undefined;
18
18
  export declare const findAnchor: (target: string, index?: AnchorIndex) => string | undefined;
19
19
  export declare const resolveFragment: (target: string, index?: AnchorIndex) => string;
20
- export declare const sameDocTarget: <T>(target: T, ctx: any, index?: AnchorIndex | undefined) => T | string;
20
+ export declare const sameDocTarget: <T>(target: T, ctx: any, index?: AnchorIndex | undefined) => T | string | undefined;
21
+ export declare const linkTarget: (node: {
22
+ meta?: unknown;
23
+ content?: unknown;
24
+ }) => string | undefined;
25
+ export declare const writtenValue: (value: unknown) => string | undefined;
26
+ export type LinkBinding = {
27
+ found: true;
28
+ document: 'self';
29
+ key: string;
30
+ via: 'heading' | 'explicit-id';
31
+ ambiguous: boolean;
32
+ } | {
33
+ found: false;
34
+ why: 'no-target';
35
+ };
36
+ export type BindingIndex = {
37
+ byKey: Map<string, {
38
+ node: object;
39
+ via: 'heading' | 'explicit-id';
40
+ }>;
41
+ ambiguous: Set<string>;
42
+ };
43
+ export declare const buildBindingIndex: (tree: unknown, style?: AnchorStyle) => BindingIndex;
44
+ export declare const bindTarget: (target: string, index?: BindingIndex) => LinkBinding;
21
45
  export declare const getSafeNodeId: (node: Node, ctx: any) => string | null;
22
46
  export declare const getExplicitNodeId: (node: any, ctx: any) => string | null;
23
47
  export declare const makeAttrs: (node: any, ctx?: import("./helpers/config").Context) => import("./helpers/config").Attr;
@@ -3,7 +3,8 @@ 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.makeAttrs = exports.getExplicitNodeId = exports.getSafeNodeId = exports.sameDocTarget = exports.resolveFragment = exports.findAnchor = exports.restyleAnchors = exports.indexAnchors = exports.markdownStyle = exports.htmlStyle = exports.toMarkdownFragment = exports.toFragment = exports.getNodeId = void 0;
6
+ exports.makeAttrs = exports.getExplicitNodeId = exports.getSafeNodeId = exports.bindTarget = exports.buildBindingIndex = exports.writtenValue = exports.linkTarget = exports.sameDocTarget = exports.resolveFragment = exports.findAnchor = exports.restyleAnchors = exports.indexAnchors = exports.markdownStyle = exports.htmlStyle = exports.toMarkdownFragment = exports.toFragment = exports.getNodeId = void 0;
7
+ const _1 = require(".");
7
8
  const config_1 = __importDefault(require("./helpers/config"));
8
9
  const getNodeId = (node, ctx) => {
9
10
  const conf = (0, config_1.default)(node, ctx);
@@ -112,14 +113,116 @@ const findAnchor = (target, index) => {
112
113
  exports.findAnchor = findAnchor;
113
114
  const resolveFragment = (target, index) => (0, exports.findAnchor)(target, index) ?? (index?.shape || exports.toFragment)(target);
114
115
  exports.resolveFragment = resolveFragment;
115
- // A link inside the same document points at a heading by name, so it goes through
116
- // the rules that shaped that heading's anchor.
116
+ // Level two: the address, shaped for this format. It is asked for only once level
117
+ // one has said the link points at something. A refusal comes back as undefined, and
118
+ // a link with no address is what the reader gets — not an address to nowhere.
117
119
  const sameDocTarget = (target, ctx, index = ctx?.__anchors) => {
118
120
  if (typeof target !== 'string' || !target.startsWith('#') || target === '#')
119
121
  return target;
122
+ const shape = index?.shape || exports.toFragment;
123
+ const bindings = ctx?.__bindings;
124
+ if (bindings) {
125
+ const bound = (0, exports.bindTarget)(target.slice(1), bindings);
126
+ if (!bound.found)
127
+ return undefined;
128
+ return `#${bound.via === 'heading' ? (0, exports.resolveFragment)(bound.key, index) : shape(bound.key)}`;
129
+ }
120
130
  return `#${(0, exports.resolveFragment)(target.slice(1), index)}`;
121
131
  };
122
132
  exports.sameDocTarget = sameDocTarget;
133
+ // A link written without a bar keeps its target in the content, and by the time a
134
+ // renderer sees it the content is a node array. Only the first node is read; a
135
+ // target spread over several nodes is a separate question.
136
+ const linkTarget = (node) => {
137
+ if (typeof node.meta === 'string')
138
+ return node.meta;
139
+ const content = node.content;
140
+ const first = Array.isArray(content) ? content[0] : content;
141
+ if (typeof first === 'string')
142
+ return first;
143
+ if (first && typeof first === 'object' && 'value' in first) {
144
+ const { value } = first;
145
+ if (typeof value === 'string')
146
+ return value;
147
+ }
148
+ return undefined;
149
+ };
150
+ exports.linkTarget = linkTarget;
151
+ // An attribute written without a value reaches the node as a boolean, which is the
152
+ // reader reporting that nothing was written rather than the author writing it. A
153
+ // number is a value the author did write, and stays.
154
+ const writtenValue = (value) => value == null || typeof value === 'boolean' ? undefined : String(value);
155
+ exports.writtenValue = writtenValue;
156
+ // Both forms the specification describes: a section addressed by its name, and a
157
+ // block the author named with :id. The author's name wins — it was written on
158
+ // purpose, where a section name is derived from prose.
159
+ const buildBindingIndex = (tree, style = exports.htmlStyle) => {
160
+ const byKey = new Map();
161
+ const ambiguous = new Set();
162
+ const anchors = (0, exports.indexAnchors)(tree, style);
163
+ const put = (key, node, via) => {
164
+ const known = byKey.get(key);
165
+ if (known === undefined) {
166
+ byKey.set(key, { node, via });
167
+ return;
168
+ }
169
+ if (known.node === node)
170
+ return;
171
+ // Two nodes claiming one name is an ambiguity whether or not they claim it the
172
+ // same way. An explicit id still wins the address; the flag says the document
173
+ // said the name twice.
174
+ ambiguous.add(key);
175
+ if (via === 'explicit-id' && known.via !== 'explicit-id')
176
+ byKey.set(key, { node, via });
177
+ };
178
+ walkNodes(tree, node => {
179
+ // The raw value the author wrote, and the form the anchor takes: getExplicitNodeId
180
+ // already turns whitespace into a hyphen, so a link written the way the id was
181
+ // written would otherwise miss it.
182
+ const written = (0, config_1.default)(node, {}).exists('id') ? (0, config_1.default)(node, {}).getFirstValue('id') : null;
183
+ const explicit = (0, exports.getExplicitNodeId)(node, {});
184
+ for (const key of [written == null ? null : String(written), explicit]) {
185
+ if (key)
186
+ put(key.normalize('NFC').trim(), node, 'explicit-id');
187
+ }
188
+ if (node.name !== 'head')
189
+ return;
190
+ const name = (0, _1.getTextContentFromNode)(node).normalize('NFC').trim();
191
+ put(name, node, 'heading');
192
+ // A heading answers to its own name and to the form an output would give it: a
193
+ // link copied out of a rendered page carries the shaped name, and the author who
194
+ // pastes it means the same section. Both keys name one node, so this is a second
195
+ // name for the target rather than resolution decided by shaping.
196
+ for (const shaped of [(0, exports.toFragment)(name), (0, exports.toMarkdownFragment)(name)]) {
197
+ if (shaped && shaped !== name)
198
+ put(shaped, node, 'heading');
199
+ }
200
+ // And the anchor actually handed out, which carries the number when a name
201
+ // repeats: a link written against the second «Parameters» asks for Parameters-2,
202
+ // and only the assignment knows that.
203
+ const assigned = anchors.byNode.get(node);
204
+ if (assigned)
205
+ put(assigned, node, 'heading');
206
+ });
207
+ return { byKey, ambiguous };
208
+ };
209
+ exports.buildBindingIndex = buildBindingIndex;
210
+ // Matching is exact: level one has to keep apart everything the tree keeps apart,
211
+ // and folding case would erase that. Measured over the knowledge base — no working
212
+ // link depended on a case-folded match.
213
+ const bindTarget = (target, index) => {
214
+ const key = target.normalize('NFC').trim();
215
+ if (!index)
216
+ return { found: false, why: 'no-target' };
217
+ const hit = index.byKey.get(key);
218
+ if (!hit)
219
+ return { found: false, why: 'no-target' };
220
+ // Two targets of one name is a fact about the document, not a reason to refuse it
221
+ // an address: the first still answers, as it always has, and the ambiguity travels
222
+ // with the answer for whoever reports it.
223
+ return { found: true, document: 'self', key, via: hit.via, ambiguous: index.ambiguous.has(key) };
224
+ };
225
+ exports.bindTarget = bindTarget;
123
226
  const getSafeNodeId = (node, ctx) => {
124
227
  const assigned = ctx?.__anchors?.byNode?.get(node);
125
228
  if (assigned !== undefined)
@@ -0,0 +1,5 @@
1
+ export declare const STANDARD_ATTRIBUTE_NAMES: readonly ["allow", "caption", "checked", "folded", "id", "lang", "nested", "numbered"];
2
+ export declare const BLOCK_ATTRIBUTE_NAMES: readonly ["colspan", "columns", "encoding", "filename", "folded-levels", "header", "key", "masked", "mime-type", "notify", "rename", "rowspan", "src"];
3
+ export declare const ATTRIBUTE_NAMES: readonly ["allow", "caption", "checked", "folded", "id", "lang", "nested", "numbered", "colspan", "columns", "encoding", "filename", "folded-levels", "header", "key", "masked", "mime-type", "notify", "rename", "rowspan", "src"];
4
+ export declare const isStandardAttributeName: (name: string) => boolean;
5
+ export declare const isKnownAttributeName: (name: string) => boolean;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ // Names the specification gives a configuration option. Kept here beside the
3
+ // block names so the parser, the checker and the editor read one list rather
4
+ // than each carrying a copy of what it remembers.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isKnownAttributeName = exports.isStandardAttributeName = exports.ATTRIBUTE_NAMES = exports.BLOCK_ATTRIBUTE_NAMES = exports.STANDARD_ATTRIBUTE_NAMES = void 0;
7
+ // Applied uniformly to any built-in block, from the standard configuration
8
+ // options section of the specification.
9
+ exports.STANDARD_ATTRIBUTE_NAMES = [
10
+ 'allow',
11
+ 'caption',
12
+ 'checked',
13
+ 'folded',
14
+ 'id',
15
+ 'lang',
16
+ 'nested',
17
+ 'numbered',
18
+ ];
19
+ // Named by the specification for a particular block: the sources a block reads,
20
+ // the shape of a table, the cover over content.
21
+ exports.BLOCK_ATTRIBUTE_NAMES = [
22
+ 'colspan',
23
+ 'columns',
24
+ 'encoding',
25
+ 'filename',
26
+ 'folded-levels',
27
+ 'header',
28
+ 'key',
29
+ 'masked',
30
+ 'mime-type',
31
+ 'notify',
32
+ 'rename',
33
+ 'rowspan',
34
+ 'src',
35
+ ];
36
+ exports.ATTRIBUTE_NAMES = [...exports.STANDARD_ATTRIBUTE_NAMES, ...exports.BLOCK_ATTRIBUTE_NAMES];
37
+ const isStandardAttributeName = (name) => exports.STANDARD_ATTRIBUTE_NAMES.includes(name);
38
+ exports.isStandardAttributeName = isStandardAttributeName;
39
+ const isKnownAttributeName = (name) => exports.ATTRIBUTE_NAMES.includes(name);
40
+ exports.isKnownAttributeName = isKnownAttributeName;
41
+ //# sourceMappingURL=attribute-names.js.map
package/lib/exportAny.js CHANGED
@@ -54,7 +54,7 @@ const toAny = (options = {}, plugins = []) => {
54
54
  newFns.reverse();
55
55
  const interator = (0, makeInterator_1.default)(newFns.map(rule => (0, makeQuery_1.makeRule)(rule.rule, rule.fn(writer, processor, tree))).reverse());
56
56
  // Every exporter needs the same anchors: assigned once, before the walk starts.
57
- const context = { __anchors: (0, ast_helpers_1.indexAnchors)(tree), ...(options.context || {}) };
57
+ const context = { __anchors: (0, ast_helpers_1.indexAnchors)(tree), __bindings: (0, ast_helpers_1.buildBindingIndex)(tree), ...(options.context || {}) };
58
58
  writer.startWrite(tree);
59
59
  const result = interator(tree, context);
60
60
  writer.endWrite();