@podlite/schema 0.0.63 → 0.0.64

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 (53) hide show
  1. package/CHANGELOG.podlite +18 -0
  2. package/esm/exportHtml.js +24 -6
  3. package/esm/exportHtml.js.map +1 -1
  4. package/esm/exportMarkdown.js +12 -6
  5. package/esm/exportMarkdown.js.map +1 -1
  6. package/esm/grammarfc.js +1668 -475
  7. package/esm/grammarfc.js.map +1 -1
  8. package/esm/helpers/config.d.ts +1 -0
  9. package/esm/helpers/config.js +8 -0
  10. package/esm/helpers/config.js.map +1 -1
  11. package/esm/helpers/configPropagation.d.ts +1 -1
  12. package/esm/helpers/configPropagation.js +2 -1
  13. package/esm/helpers/configPropagation.js.map +1 -1
  14. package/esm/helpers/link-config.d.ts +8 -0
  15. package/esm/helpers/link-config.js +23 -0
  16. package/esm/helpers/link-config.js.map +1 -0
  17. package/esm/helpers/makeInterator.js +23 -0
  18. package/esm/helpers/makeInterator.js.map +1 -1
  19. package/esm/index.d.ts +6 -2
  20. package/esm/index.js +10 -2
  21. package/esm/index.js.map +1 -1
  22. package/esm/plugin-data-table.js +5 -1
  23. package/esm/plugin-data-table.js.map +1 -1
  24. package/esm/plugin-formatting-codes.js +8 -4
  25. package/esm/plugin-formatting-codes.js.map +1 -1
  26. package/esm/plugin-tables.d.ts +1 -1
  27. package/esm/plugin-tables.js +12 -5
  28. package/esm/plugin-tables.js.map +1 -1
  29. package/esm/types.d.ts +2 -0
  30. package/esm/version.d.ts +1 -1
  31. package/esm/version.js +1 -1
  32. package/lib/exportHtml.js +57 -6
  33. package/lib/exportMarkdown.js +45 -6
  34. package/lib/grammarfc.js +1668 -475
  35. package/lib/helpers/config.d.ts +1 -0
  36. package/lib/helpers/config.js +10 -1
  37. package/lib/helpers/configPropagation.d.ts +1 -1
  38. package/lib/helpers/configPropagation.js +2 -1
  39. package/lib/helpers/link-config.d.ts +8 -0
  40. package/lib/helpers/link-config.js +27 -0
  41. package/lib/helpers/makeInterator.js +23 -0
  42. package/lib/index.d.ts +6 -2
  43. package/lib/index.js +13 -3
  44. package/lib/plugin-data-table.js +5 -1
  45. package/lib/plugin-formatting-codes.js +8 -4
  46. package/lib/plugin-tables.d.ts +1 -1
  47. package/lib/plugin-tables.js +12 -5
  48. package/lib/types.d.ts +2 -0
  49. package/lib/version.d.ts +1 -1
  50. package/lib/version.js +1 -1
  51. package/package.json +1 -1
  52. package/schema/AstTree.json +12 -0
  53. package/schema/PodliteDocument.json +12 -0
package/lib/exportHtml.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -6,12 +39,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
39
  const exportAny_1 = __importDefault(require("./exportAny"));
7
40
  const handlers_1 = require("./helpers/handlers");
8
41
  const makeTransformer_1 = require("./helpers/makeTransformer");
9
- const config_1 = __importDefault(require("./helpers/config"));
42
+ const config_1 = __importStar(require("./helpers/config"));
10
43
  const image_base_1 = require("./image-base");
11
44
  const writerHtml_1 = __importDefault(require("./writerHtml"));
12
45
  const plugin_clean_location_1 = __importDefault(require("./plugin-clean-location"));
13
46
  const ast_helpers_1 = require("./ast-helpers");
47
+ const link_config_1 = require("./helpers/link-config");
14
48
  const entities_1 = require("entities");
49
+ const quoteValue = (value) => value.replace(/"/g, '&quot;');
50
+ const linkConfigAttrs = config => {
51
+ const { newContext, title, lang, download } = (0, link_config_1.readLinkConfig)(config);
52
+ const attrs = [];
53
+ if (newContext)
54
+ attrs.push(' target="_blank"');
55
+ if (title !== undefined)
56
+ attrs.push(` title="${quoteValue(title)}"`);
57
+ if (lang !== undefined)
58
+ attrs.push(` hreflang="${quoteValue(lang)}"`);
59
+ if (download === true)
60
+ attrs.push(' download');
61
+ else if (typeof download === 'string')
62
+ attrs.push(` download="${quoteValue(download)}"`);
63
+ return attrs.join('');
64
+ };
15
65
  const openTag = (tag, node, ctx, attrs = '') => {
16
66
  const id = (0, ast_helpers_1.getExplicitNodeId)(node, ctx);
17
67
  return `<${tag}${id ? ` id="${id}"` : ''}${attrs}>`;
@@ -29,11 +79,12 @@ const rules = {
29
79
  // Formatting codes
30
80
  'A<>': (writer, processor) => (node, ctx, interator) => {
31
81
  //get replacement text
32
- if (!(ctx.alias && ctx.alias.hasOwnProperty(node.content))) {
33
- writer.write(`A<${node.content}>`);
82
+ const term = (0, handlers_1.collectText)(node.content).trim();
83
+ if (!(ctx.alias && ctx.alias.hasOwnProperty(term))) {
84
+ writer.write(`A<${term}>`);
34
85
  }
35
86
  else {
36
- const src = ctx.alias[node.content].join('\n');
87
+ const src = ctx.alias[term].join('\n');
37
88
  const tree_1 = processor(src);
38
89
  // now clean locations
39
90
  const tree = (0, plugin_clean_location_1.default)()(tree_1);
@@ -99,14 +150,14 @@ const rules = {
99
150
  if (meta === null) {
100
151
  meta = node.content;
101
152
  }
102
- return (0, handlers_1.wrapContent)(`<a href="${(0, ast_helpers_1.sameDocTarget)(meta, ctx)}">`, `</a>`);
153
+ return (0, handlers_1.wrapContent)(`<a href="${(0, ast_helpers_1.sameDocTarget)(meta, ctx)}"${linkConfigAttrs((0, config_1.codeConfigWithDefaults)(node, ctx))}>`, `</a>`);
103
154
  }),
104
155
  'W<>': (0, handlers_1.setFn)((node, ctx) => {
105
156
  let { meta } = node;
106
157
  if (meta === null) {
107
158
  meta = node.content;
108
159
  }
109
- return (0, handlers_1.wrapContent)(`<a href="${(0, ast_helpers_1.sameDocTarget)(meta, ctx)}" class="backlink">`, `</a>`);
160
+ return (0, handlers_1.wrapContent)(`<a href="${(0, ast_helpers_1.sameDocTarget)(meta, ctx)}"${linkConfigAttrs((0, config_1.codeConfigWithDefaults)(node, ctx))} class="backlink">`, `</a>`);
110
161
  }),
111
162
  /**
112
163
  * CSS rules for footnotes
@@ -1,18 +1,56 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  const exportAny_1 = __importDefault(require("./exportAny"));
7
40
  const handlers_1 = require("./helpers/handlers");
8
- const config_1 = __importDefault(require("./helpers/config"));
41
+ const config_1 = __importStar(require("./helpers/config"));
9
42
  const image_base_1 = require("./image-base");
10
43
  const writerMarkdown_1 = __importDefault(require("./writerMarkdown"));
11
44
  const plugin_clean_location_1 = __importDefault(require("./plugin-clean-location"));
12
45
  const ast_helpers_1 = require("./ast-helpers");
46
+ const link_config_1 = require("./helpers/link-config");
13
47
  // A markdown reader builds the anchor out of the heading itself, by its own rules,
14
48
  // so a link written here has to match what that reader will produce.
15
49
  const markdownAnchors = ctx => ctx && (ctx.__markdownAnchors ||= (0, ast_helpers_1.restyleAnchors)(ctx.__anchors, ast_helpers_1.markdownStyle));
50
+ const linkTitle = config => {
51
+ const { title } = (0, link_config_1.readLinkConfig)(config);
52
+ return title === undefined ? '' : ` "${title.replace(/"/g, '\\"')}"`;
53
+ };
16
54
  const rules = {
17
55
  ':text': (writer, processor) => (node, ctx, interator) => {
18
56
  if (node.value) {
@@ -24,11 +62,12 @@ const rules = {
24
62
  },
25
63
  // Formatting codes
26
64
  'A<>': (writer, processor) => (node, ctx, interator) => {
27
- if (!(ctx.alias && ctx.alias.hasOwnProperty(node.content))) {
28
- writer.writeRaw(`A<${node.content}>`);
65
+ const term = (0, handlers_1.collectText)(node.content).trim();
66
+ if (!(ctx.alias && ctx.alias.hasOwnProperty(term))) {
67
+ writer.writeRaw(`A<${term}>`);
29
68
  }
30
69
  else {
31
- const src = ctx.alias[node.content].join('\n');
70
+ const src = ctx.alias[term].join('\n');
32
71
  const tree_1 = processor(src);
33
72
  const tree = (0, plugin_clean_location_1.default)()(tree_1);
34
73
  if (tree[0].type === 'para') {
@@ -68,14 +107,14 @@ const rules = {
68
107
  if (meta === null) {
69
108
  meta = node.content;
70
109
  }
71
- return (0, handlers_1.wrapContent)(`[`, `](${(0, ast_helpers_1.sameDocTarget)(meta, ctx, markdownAnchors(ctx))})`);
110
+ return (0, handlers_1.wrapContent)(`[`, `](${(0, ast_helpers_1.sameDocTarget)(meta, ctx, markdownAnchors(ctx))}${linkTitle((0, config_1.codeConfigWithDefaults)(node, ctx))})`);
72
111
  }),
73
112
  'W<>': (0, handlers_1.setFn)((node, ctx) => {
74
113
  let { meta } = node;
75
114
  if (meta === null) {
76
115
  meta = node.content;
77
116
  }
78
- return (0, handlers_1.wrapContent)(`[`, `](${(0, ast_helpers_1.sameDocTarget)(meta, ctx, markdownAnchors(ctx))})`);
117
+ return (0, handlers_1.wrapContent)(`[`, `](${(0, ast_helpers_1.sameDocTarget)(meta, ctx, markdownAnchors(ctx))}${linkTitle((0, config_1.codeConfigWithDefaults)(node, ctx))})`);
79
118
  }),
80
119
  'N<>': (writer, processor) => {
81
120
  writer.addListener('end', () => {