@podlite/schema 0.0.51 → 0.0.52

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 (95) hide show
  1. package/CHANGELOG.podlite +18 -0
  2. package/LICENSE +1 -1
  3. package/esm/ast-helpers.js.map +1 -1
  4. package/esm/ast-inerator.js.map +1 -1
  5. package/esm/blocks-helpers.js.map +1 -1
  6. package/esm/exportAny.d.ts +2 -2
  7. package/esm/exportAny.js.map +1 -1
  8. package/esm/exportHtml.d.ts +1 -1
  9. package/esm/exportHtml.js +16 -0
  10. package/esm/exportHtml.js.map +1 -1
  11. package/esm/exportMarkdown.d.ts +1 -1
  12. package/esm/exportMarkdown.js +2 -2
  13. package/esm/exportMarkdown.js.map +1 -1
  14. package/esm/grammar.js +1133 -562
  15. package/esm/grammar.js.map +1 -1
  16. package/esm/grammarfc.js +1300 -1065
  17. package/esm/grammarfc.js.map +1 -1
  18. package/esm/helpers/config.d.ts +1 -1
  19. package/esm/helpers/config.js.map +1 -1
  20. package/esm/helpers/configPropagation.d.ts +2 -2
  21. package/esm/helpers/configPropagation.js.map +1 -1
  22. package/esm/helpers/corePlugins.js.map +1 -1
  23. package/esm/helpers/handlers.js.map +1 -1
  24. package/esm/helpers/headingNumbering.d.ts +2 -2
  25. package/esm/helpers/headingNumbering.js.map +1 -1
  26. package/esm/helpers/ids.js.map +1 -1
  27. package/esm/helpers/itemNumbering.d.ts +2 -2
  28. package/esm/helpers/itemNumbering.js.map +1 -1
  29. package/esm/helpers/makeInterator.js.map +1 -1
  30. package/esm/helpers/makeQuery.d.ts +2 -2
  31. package/esm/helpers/makeQuery.js.map +1 -1
  32. package/esm/helpers/makeTransformer.js.map +1 -1
  33. package/esm/helpers/parseAttributes.js.map +1 -1
  34. package/esm/helpers/plugins.js.map +1 -1
  35. package/esm/image-base.js.map +1 -1
  36. package/esm/index.d.ts +7 -6
  37. package/esm/index.js +3 -0
  38. package/esm/index.js.map +1 -1
  39. package/esm/pluggableParser.js.map +1 -1
  40. package/esm/plugin-clean-location.js.map +1 -1
  41. package/esm/plugin-data-table.js.map +1 -1
  42. package/esm/plugin-defn-fill-term.js.map +1 -1
  43. package/esm/plugin-group-defn.js +1 -1
  44. package/esm/plugin-group-defn.js.map +1 -1
  45. package/esm/plugin-group-items.js.map +1 -1
  46. package/esm/plugin-heading.js.map +1 -1
  47. package/esm/plugin-items.js.map +1 -1
  48. package/esm/plugin-set.d.ts +2 -0
  49. package/esm/plugin-set.js +54 -0
  50. package/esm/plugin-set.js.map +1 -0
  51. package/esm/plugin-tables.js +5 -2
  52. package/esm/plugin-tables.js.map +1 -1
  53. package/esm/plugin-vmargin.js.map +1 -1
  54. package/esm/query-helpers.d.ts +2 -2
  55. package/esm/query-helpers.js.map +1 -1
  56. package/esm/selectors.d.ts +6 -6
  57. package/esm/selectors.js.map +1 -1
  58. package/esm/types.d.ts +9 -8
  59. package/esm/version.d.ts +1 -1
  60. package/esm/version.js +1 -1
  61. package/esm/writer.d.ts +0 -1
  62. package/esm/writer.js.map +1 -1
  63. package/lib/ast-inerator.js +2 -2
  64. package/lib/exportAny.d.ts +2 -2
  65. package/lib/exportHtml.d.ts +1 -1
  66. package/lib/exportHtml.js +16 -0
  67. package/lib/exportMarkdown.d.ts +1 -1
  68. package/lib/exportMarkdown.js +2 -2
  69. package/lib/grammar.js +1133 -562
  70. package/lib/grammarfc.js +1300 -1065
  71. package/lib/helpers/config.d.ts +1 -1
  72. package/lib/helpers/configPropagation.d.ts +2 -2
  73. package/lib/helpers/headingNumbering.d.ts +2 -2
  74. package/lib/helpers/itemNumbering.d.ts +2 -2
  75. package/lib/helpers/makeQuery.d.ts +2 -2
  76. package/lib/helpers/makeQuery.js +2 -2
  77. package/lib/helpers/makeTransformer.js +3 -3
  78. package/lib/helpers/parseAttributes.js +23 -10
  79. package/lib/index.d.ts +7 -6
  80. package/lib/index.js +35 -17
  81. package/lib/plugin-formatting-codes.js +22 -8
  82. package/lib/plugin-group-defn.js +1 -1
  83. package/lib/plugin-set.d.ts +2 -0
  84. package/lib/plugin-set.js +56 -0
  85. package/lib/plugin-tables.js +12 -10
  86. package/lib/query-helpers.d.ts +2 -2
  87. package/lib/selectors.d.ts +6 -6
  88. package/lib/types.d.ts +9 -8
  89. package/lib/version.d.ts +1 -1
  90. package/lib/version.js +1 -1
  91. package/lib/writer.d.ts +0 -1
  92. package/lib/writer.js +22 -8
  93. package/package.json +7 -3
  94. package/schema/AstTree.json +200 -382
  95. package/schema/PodliteDocument.json +200 -382
@@ -1,4 +1,4 @@
1
- export declare type Context = {
1
+ export type Context = {
2
2
  config?: any;
3
3
  };
4
4
  export interface Attr {
@@ -1,3 +1,3 @@
1
- import { PodNode } from '../types';
2
- export declare const propagateConfigDefaults: <T extends PodNode>(ast: T) => T;
1
+ import { PodNode, PodliteDocument } from '../types';
2
+ export declare const propagateConfigDefaults: <T extends PodliteDocument | PodNode>(ast: T) => T;
3
3
  export default propagateConfigDefaults;
@@ -1,3 +1,3 @@
1
- import { PodNode } from '../types';
2
- export declare const attachHeadingNumberPrefix: <T extends PodNode>(ast: T) => T;
1
+ import { PodNode, PodliteDocument } from '../types';
2
+ export declare const attachHeadingNumberPrefix: <T extends PodliteDocument | PodNode>(ast: T) => T;
3
3
  export default attachHeadingNumberPrefix;
@@ -1,3 +1,3 @@
1
- import { PodNode } from '../types';
2
- export declare const promoteOrderedLists: <T extends PodNode>(ast: T) => T;
1
+ import { PodNode, PodliteDocument } from '../types';
2
+ export declare const promoteOrderedLists: <T extends PodliteDocument | PodNode>(ast: T) => T;
3
3
  export default promoteOrderedLists;
@@ -14,10 +14,10 @@ sample | type | name
14
14
  export interface RuleHandler<T = any> {
15
15
  (writer: Writer, processor: any): (node: T, ctx: any, interator: any) => void;
16
16
  }
17
- export declare type RuleObject = {
17
+ export type RuleObject = {
18
18
  [name: string]: RuleHandler;
19
19
  };
20
- export declare type Filter = {
20
+ export type Filter = {
21
21
  name: string;
22
22
  type?: string;
23
23
  } | {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeRulesArray = exports.makeRule = exports.is = exports.makePlug = void 0;
3
+ exports.makeRulesArray = exports.makeRule = exports.makePlug = void 0;
4
+ exports.is = is;
4
5
  const getQuery = function (k) {
5
6
  if (k === '*:*' || k === '*') {
6
7
  return {};
@@ -71,7 +72,6 @@ function is(query, node) {
71
72
  }
72
73
  return true;
73
74
  }
74
- exports.is = is;
75
75
  const makeRule = (query, fn) => {
76
76
  rule.rule = query;
77
77
  rule.isFor = isFor;
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeTransformer = exports.isSemanticBlock = exports.isNamedBlock = void 0;
3
+ exports.makeTransformer = void 0;
4
+ exports.isNamedBlock = isNamedBlock;
5
+ exports.isSemanticBlock = isSemanticBlock;
4
6
  const makeQuery_1 = require("./makeQuery");
5
7
  // the following names: MyBlock, myBlock are use for extending pod6
6
8
  function isNamedBlock(name) {
7
9
  return name && name !== name.toLowerCase() && name !== name.toUpperCase();
8
10
  }
9
- exports.isNamedBlock = isNamedBlock;
10
11
  // skip warnings for semantic blocks
11
12
  function isSemanticBlock(node) {
12
13
  const name = node.name || '';
13
14
  const isTypeBlock = (node.type || '') === 'block';
14
15
  return isTypeBlock && name === name.toUpperCase();
15
16
  }
16
- exports.isSemanticBlock = isSemanticBlock;
17
17
  function flattenDeep(arr) {
18
18
  return arr.reduce((acc, val) => (Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val)), []);
19
19
  }
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
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
+ })();
21
35
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.parseAttributes = void 0;
36
+ exports.parseAttributes = parseAttributes;
23
37
  const parser = __importStar(require("../grammar"));
24
38
  function parseAttributes(src) {
25
39
  if (!src || !src.trim())
@@ -31,5 +45,4 @@ function parseAttributes(src) {
31
45
  return [];
32
46
  }
33
47
  }
34
- exports.parseAttributes = parseAttributes;
35
48
  //# sourceMappingURL=parseAttributes.js.map
package/lib/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { pluginCleanLocation } from './plugin-clean-location';
16
16
  export { toAnyRules } from './helpers/plugins';
17
17
  export { podlitePluggable, Podlite, PodliteExport, cleanIds, frozenIds } from './pluggableParser';
18
18
  export declare function toAst(): {};
19
- export declare type SchemaValidationError = ErrorObject<string, Record<string, any>>;
19
+ export type SchemaValidationError = ErrorObject<string, Record<string, any>>;
20
20
  export declare function getTextContentFromNode(node: PodNode): string;
21
21
  export declare function getPodContentFromNode(node: PodNode): string;
22
22
  export declare function validatePodliteAst(data: unknown): SchemaValidationError[];
@@ -61,22 +61,23 @@ export interface nVerbatim {
61
61
  margin: string;
62
62
  text: string;
63
63
  }
64
- export declare type Node = nBlock | nCode | nText | nPara | nVerbatim;
65
- export declare type AST = Array<Node>;
66
- export declare type ParserPlugin = (opt: parseOpt) => (param: AST) => AST;
67
- export declare type parseOpt = {
64
+ export type Node = nBlock | nCode | nText | nPara | nVerbatim;
65
+ export type AST = Array<Node>;
66
+ export type ParserPlugin = (opt: parseOpt) => (param: AST) => AST;
67
+ export type parseOpt = {
68
68
  skipChain?: number;
69
69
  podMode?: number;
70
70
  mode?: 'pod' | 'md';
71
71
  };
72
72
  declare function makeTree(): {
73
73
  (): void;
74
- use: (plugin: ParserPlugin) => any;
74
+ use: (plugin: ParserPlugin) => /*elided*/ any;
75
75
  parse: (src: string, opt?: parseOpt) => AST;
76
76
  };
77
77
  export { makeTree as toTree };
78
78
  declare const parse: Function;
79
79
  export { parse as parse };
80
+ export { parse as parseFormattingCodes } from './grammarfc';
80
81
  export { default as toHtml } from './exportHtml';
81
82
  export { default as toMarkdown } from './exportMarkdown';
82
83
  export { default as Writer } from './writer';
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
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
+ })();
21
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
37
  };
@@ -25,7 +39,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
40
  };
27
41
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.version = exports.applyImageBase = exports.runSelector = exports.parseSelector = exports.Writer = exports.toMarkdown = exports.toHtml = exports.parse = exports.toTree = exports.isValidateError = exports.validateAst = exports.validateAstTree = exports.validatePodliteAst = exports.getPodContentFromNode = exports.getTextContentFromNode = exports.toAst = exports.frozenIds = exports.cleanIds = exports.podlitePluggable = exports.toAnyRules = exports.pluginCleanLocation = exports.parseAttributes = exports.makeAttrs = exports.toAny = exports.isSemanticBlock = exports.isNamedBlock = exports.makeTransformer = exports.makeInterator = void 0;
42
+ exports.version = exports.applyImageBase = exports.runSelector = exports.parseSelector = exports.Writer = exports.toMarkdown = exports.toHtml = exports.parseFormattingCodes = exports.parse = exports.frozenIds = exports.cleanIds = exports.podlitePluggable = exports.toAnyRules = exports.pluginCleanLocation = exports.parseAttributes = exports.makeAttrs = exports.toAny = exports.isSemanticBlock = exports.isNamedBlock = exports.makeTransformer = exports.makeInterator = void 0;
43
+ exports.toAst = toAst;
44
+ exports.getTextContentFromNode = getTextContentFromNode;
45
+ exports.getPodContentFromNode = getPodContentFromNode;
46
+ exports.validatePodliteAst = validatePodliteAst;
47
+ exports.validateAstTree = validateAstTree;
48
+ exports.validateAst = validateAst;
49
+ exports.isValidateError = isValidateError;
50
+ exports.toTree = makeTree;
29
51
  const ajv_1 = __importDefault(require("ajv"));
30
52
  const pointer = __importStar(require("json-pointer"));
31
53
  const jsonShemes = __importStar(require("../schema"));
@@ -63,12 +85,12 @@ const plugin_heading_1 = __importDefault(require("./plugin-heading"));
63
85
  const plugin_group_defn_1 = __importDefault(require("./plugin-group-defn"));
64
86
  const plugin_group_items_1 = __importDefault(require("./plugin-group-items"));
65
87
  const plugin_defn_fill_term_1 = __importDefault(require("./plugin-defn-fill-term"));
88
+ const plugin_set_1 = __importDefault(require("./plugin-set"));
66
89
  const plugin_tables_1 = __importDefault(require("./plugin-tables"));
67
90
  const plugin_data_table_1 = __importDefault(require("./plugin-data-table"));
68
91
  function toAst() {
69
92
  return {};
70
93
  }
71
- exports.toAst = toAst;
72
94
  const ajv = new ajv_1.default({ strict: true, allowUnionTypes: true });
73
95
  function getTextContentFromNode(node) {
74
96
  let text = '';
@@ -84,7 +106,6 @@ function getTextContentFromNode(node) {
84
106
  const res = transformer(node, {});
85
107
  return text;
86
108
  }
87
- exports.getTextContentFromNode = getTextContentFromNode;
88
109
  function getPodContentFromNode(node) {
89
110
  let text = '';
90
111
  const rules = {
@@ -108,15 +129,12 @@ function getPodContentFromNode(node) {
108
129
  const res = transformer(node, {});
109
130
  return text;
110
131
  }
111
- exports.getPodContentFromNode = getPodContentFromNode;
112
132
  function validatePodliteAst(data) {
113
133
  return validateAst(data, 'PodliteDocument');
114
134
  }
115
- exports.validatePodliteAst = validatePodliteAst;
116
135
  function validateAstTree(data) {
117
136
  return validateAst(data, 'AstTree');
118
137
  }
119
- exports.validateAstTree = validateAstTree;
120
138
  function validateAst(data, Name = 'AstTree') {
121
139
  const AstTreeSchema = jsonShemes[Name];
122
140
  if (!AstTreeSchema) {
@@ -128,7 +146,6 @@ function validateAst(data, Name = 'AstTree') {
128
146
  }
129
147
  return validate.errors || [];
130
148
  }
131
- exports.validateAst = validateAst;
132
149
  function isValidateError(result, src) {
133
150
  if (result.length > 0) {
134
151
  // get most erorred dataPath
@@ -143,12 +160,12 @@ function isValidateError(result, src) {
143
160
  }
144
161
  return undefined;
145
162
  }
146
- exports.isValidateError = isValidateError;
147
163
  function makeTree() {
148
164
  var plugins = [];
149
165
  chain.use = use;
150
166
  chain.parse = parse;
151
167
  chain.use(plugin_vmargin_1.default);
168
+ chain.use(plugin_set_1.default);
152
169
  chain.use(plugin_items_1.default);
153
170
  chain.use(plugin_heading_1.default);
154
171
  chain.use(plugin_defn_fill_term_1.default);
@@ -184,9 +201,10 @@ function makeTree() {
184
201
  return tree;
185
202
  }
186
203
  }
187
- exports.toTree = makeTree;
188
204
  const parse = makeTree().parse;
189
205
  exports.parse = parse;
206
+ var grammarfc_1 = require("./grammarfc");
207
+ Object.defineProperty(exports, "parseFormattingCodes", { enumerable: true, get: function () { return grammarfc_1.parse; } });
190
208
  var exportHtml_1 = require("./exportHtml");
191
209
  Object.defineProperty(exports, "toHtml", { enumerable: true, get: function () { return __importDefault(exportHtml_1).default; } });
192
210
  var exportMarkdown_1 = require("./exportMarkdown");
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
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
+ })();
21
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
37
  };
@@ -46,7 +46,7 @@ exports.default = () => tree => {
46
46
  return {
47
47
  type: 'list',
48
48
  list,
49
- level: 1,
49
+ level: 1, // defn always have level 1
50
50
  content: [...item],
51
51
  };
52
52
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => (tree: any) => any;
2
+ export default _default;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Directives and =comment blocks pass =set attributes through to the next
4
+ // real block instead of consuming them.
5
+ const isTransparent = (node) => {
6
+ if (!node || typeof node !== 'object')
7
+ return false;
8
+ if (node.type === 'set' || node.type === 'config' || node.type === 'alias' || node.type === 'blankline')
9
+ return true;
10
+ if (node.type === 'block' && (node.name === 'comment' || node.name === 'boundary' || node.name === 'include'))
11
+ return true;
12
+ return false;
13
+ };
14
+ const isBlock = (node) => node && typeof node === 'object' && node.type === 'block';
15
+ // Each content array is its own lexical scope: pending attributes never leak
16
+ // into or out of a nested block.
17
+ const applyInScope = (content) => {
18
+ let pending = [];
19
+ const out = [];
20
+ for (const node of content) {
21
+ if (node && typeof node === 'object' && node.type === 'set' && Array.isArray(node.config)) {
22
+ for (const item of node.config) {
23
+ if (!item || !item.name)
24
+ continue;
25
+ pending = pending.filter(p => p.name !== item.name);
26
+ pending.push(item);
27
+ }
28
+ continue;
29
+ }
30
+ let next = node;
31
+ if (isBlock(node) && Array.isArray(node.content)) {
32
+ next = { ...node, content: applyInScope(node.content) };
33
+ }
34
+ if (pending.length && isBlock(next) && !isTransparent(next)) {
35
+ const own = new Set((next.config || []).map((c) => c && c.name));
36
+ const additions = pending.filter(c => !own.has(c.name));
37
+ if (additions.length)
38
+ next = { ...next, config: [...(next.config || []), ...additions] };
39
+ pending = [];
40
+ }
41
+ out.push(next);
42
+ }
43
+ if (pending.length) {
44
+ console.warn(`[set] =set directive has no target block in scope: ${pending.map(c => c.name).join(', ')}`);
45
+ }
46
+ return out;
47
+ };
48
+ exports.default = () => (tree) => {
49
+ if (Array.isArray(tree))
50
+ return applyInScope(tree);
51
+ if (tree && typeof tree === 'object' && Array.isArray(tree.content)) {
52
+ return { ...tree, content: applyInScope(tree.content) };
53
+ }
54
+ return tree;
55
+ };
56
+ //# sourceMappingURL=plugin-set.js.map
@@ -3,7 +3,13 @@ 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.normalizeCellCounts = exports.csvToTableContent = exports.extractDataText = exports.findDataBlockByKey = exports.parseMimeType = exports.parseTsv = exports.parseCsv = void 0;
6
+ exports.parseCsv = parseCsv;
7
+ exports.parseTsv = parseTsv;
8
+ exports.parseMimeType = parseMimeType;
9
+ exports.findDataBlockByKey = findDataBlockByKey;
10
+ exports.extractDataText = extractDataText;
11
+ exports.csvToTableContent = csvToTableContent;
12
+ exports.normalizeCellCounts = normalizeCellCounts;
7
13
  /**
8
14
  * Plugin for fill term's for defn. From S26:
9
15
  * The first non-blank line of content is treated as a term being defined,
@@ -74,7 +80,6 @@ function parseCsv(text) {
74
80
  // Drop rows that are entirely blank (empty content after trim).
75
81
  return rows.filter(r => !(r.length === 1 && r[0].trim() === ''));
76
82
  }
77
- exports.parseCsv = parseCsv;
78
83
  // Parse a TSV (tab-separated values) blob. Unlike CSV, TSV has no quoting
79
84
  // mechanism — fields are split strictly on tabs and `"` is a literal
80
85
  // character. Tabs and newlines inside fields are not representable in TSV.
@@ -83,7 +88,6 @@ function parseTsv(text) {
83
88
  const rows = lines.map(line => line.split('\t'));
84
89
  return rows.filter(r => !(r.length === 1 && r[0].trim() === ''));
85
90
  }
86
- exports.parseTsv = parseTsv;
87
91
  // Parse a MIME type value into the bare type and a map of parameters
88
92
  // (RFC 6838 / RFC 7231 §3.1.1.1). Used to recognise the `header` parameter
89
93
  // (RFC 4180 §3) on `:mime-type` of CSV/TSV =data blocks.
@@ -114,7 +118,6 @@ function parseMimeType(raw) {
114
118
  }
115
119
  return { type, params };
116
120
  }
117
- exports.parseMimeType = parseMimeType;
118
121
  // Locate the first `=data` block with a matching `:key` attribute anywhere
119
122
  // in the document tree.
120
123
  function findDataBlockByKey(tree, key) {
@@ -141,14 +144,12 @@ function findDataBlockByKey(tree, key) {
141
144
  walk(tree);
142
145
  return found;
143
146
  }
144
- exports.findDataBlockByKey = findDataBlockByKey;
145
147
  function extractDataText(dataNode) {
146
148
  if (!dataNode || !Array.isArray(dataNode.content))
147
149
  return '';
148
150
  const verbatim = dataNode.content.find(c => c && c.type === 'verbatim');
149
151
  return verbatim && typeof verbatim.value === 'string' ? verbatim.value : '';
150
152
  }
151
- exports.extractDataText = extractDataText;
152
153
  // Detect whether the =table body is a single-line source reference like
153
154
  // `data:key` or `file:path` (spec §1672). Returns the parsed reference or
154
155
  // null if the body is ordinary table content.
@@ -209,7 +210,6 @@ function csvToTableContent(csvRows, hasHeader = false) {
209
210
  return buildRowBlock(cells, hasHeader && i === 0);
210
211
  });
211
212
  }
212
- exports.csvToTableContent = csvToTableContent;
213
213
  // ─── Error recovery (design notes Rules 2-4) ───────────────────────────────
214
214
  // Rule 2 — table-level cell count validation. Pad short rows with empty
215
215
  // cells; truncate long rows. Emit a warning whenever a row is changed.
@@ -272,7 +272,6 @@ function normalizeCellCounts(tableNode, source = 'table') {
272
272
  });
273
273
  return mutated ? { ...tableNode, content: newContent } : tableNode;
274
274
  }
275
- exports.normalizeCellCounts = normalizeCellCounts;
276
275
  // Rule 3 — mixed separator detection (text-mode only). Inspects each line
277
276
  // for visible separators (`|` / `+`) surrounded by whitespace; lines without
278
277
  // any visible separator fall back to whitespace separation. Warns when more
@@ -445,7 +444,7 @@ const isStructured = tableNode => Array.isArray(tableNode.content) &&
445
444
  tableNode.content.some(c => c && c.type === 'block' && (c.name === 'row' || c.name === 'cell'));
446
445
  exports.default = () => tree => {
447
446
  const transformer = (0, makeTransformer_1.default)({
448
- table: node => {
447
+ table: (node, ctx, visiter) => {
449
448
  // CSV/data source reference (spec §1672):
450
449
  // =table data:<key> → resolve =data block with :key<key>
451
450
  // =table file:<path> → defer to host reader (not implemented here)
@@ -484,7 +483,10 @@ exports.default = () => tree => {
484
483
  return wrapImplicitCells(c);
485
484
  return c;
486
485
  });
487
- return normalizeCellCounts({ ...node, content: transformedContent }, 'table');
486
+ // a matched rule replaces the node without descending, so recurse
487
+ // here or tables nested inside cells keep their raw text rows
488
+ const recursed = visiter ? visiter(transformedContent, ctx) : transformedContent;
489
+ return normalizeCellCounts({ ...node, content: recursed }, 'table');
488
490
  }
489
491
  let rows = [];
490
492
  const collectValues = row => {
@@ -1,5 +1,5 @@
1
1
  import { PodNode } from './types';
2
- declare type Query = ((par: Object) => Boolean) | any;
2
+ type Query = ((par: Object) => Boolean) | any;
3
3
  /**
4
4
  * compileQuery - compile a query to a function
5
5
 
@@ -17,7 +17,7 @@ declare type Query = ((par: Object) => Boolean) | any;
17
17
  * @param obj
18
18
  * @returns function that can be used to filter the objects
19
19
  */
20
- export declare const compileQuery: (...obj: Query[]) => (any: any) => any;
20
+ export declare const compileQuery: (...obj: Query[]) => ((any: any) => any);
21
21
  /**
22
22
  * Get nodes by queries
23
23
  * @param tree
@@ -4,31 +4,31 @@ import { PodliteDocument, PodNode } from './index';
4
4
  * (publisher's `publishRecord`, editor preview, etc.) supply richer
5
5
  * objects; only `file` and `node` are read here.
6
6
  */
7
- export declare type SelectorDoc = {
7
+ export type SelectorDoc = {
8
8
  file: string;
9
9
  node: PodNode | PodliteDocument;
10
10
  };
11
- export declare type ValueSpec = {
11
+ export type ValueSpec = {
12
12
  kind: 'angle';
13
13
  value: string;
14
14
  } | {
15
15
  kind: 'contains';
16
16
  value: string;
17
17
  };
18
- export declare type Condition = {
18
+ export type Condition = {
19
19
  modifier?: '!' | '?' | '!?';
20
20
  attrName: string;
21
21
  valueSpec?: ValueSpec;
22
22
  };
23
- export declare type Pattern = {
23
+ export type Pattern = {
24
24
  blockType: string;
25
25
  predicate?: Condition[];
26
26
  };
27
- export declare type ParsedSelector = {
27
+ export type ParsedSelector = {
28
28
  scheme?: string;
29
29
  document?: string;
30
30
  anchor?: string;
31
31
  patterns: Pattern[];
32
32
  };
33
33
  export declare const parseSelector: (selector: string) => ParsedSelector | undefined;
34
- export declare const runSelector: <T extends SelectorDoc>(selector: string, docs: T[]) => PodNode[] | T[];
34
+ export declare const runSelector: <T extends SelectorDoc>(selector: string, docs: T[]) => T[] | PodNode[];
package/lib/types.d.ts CHANGED
@@ -2,12 +2,12 @@ import * as React from 'react';
2
2
  export interface RuleHandler<T = any> {
3
3
  (writer: any, processor: any, tree: PodliteDocument): (node: T, ctx: any, interator: any) => void | AstTree | PodNode;
4
4
  }
5
- declare type createComponentParams = PodNode & {
5
+ type createComponentParams = PodNode & {
6
6
  children: React.ReactNode[];
7
7
  } & {
8
8
  key: string | number;
9
9
  };
10
- export declare type JSXHelper = (src: string | (({}: createComponentParams, children: React.ReactNode[]) => React.ReactNode[] | React.ReactNode), node: PodNode | {}, children: React.ReactNode[], extraProps?: {}, ctx?: {}) => any;
10
+ export type JSXHelper = (src: string | (({}: createComponentParams, children: React.ReactNode[]) => React.ReactNode[] | React.ReactNode), node: PodNode | {}, children: React.ReactNode[], extraProps?: {}, ctx?: {}) => any;
11
11
  export interface Plugin<T = any> {
12
12
  toAst?: RuleHandler<T>;
13
13
  toAstAfter?: RuleHandler<T>;
@@ -266,6 +266,7 @@ export interface ConfigItem {
266
266
  name: string;
267
267
  value: boolean | string | number | Array<string | number | boolean> | ConfigItemKV;
268
268
  type: string;
269
+ isFalse?: boolean;
269
270
  }
270
271
  export interface BlockConfig {
271
272
  name: string;
@@ -362,7 +363,7 @@ export interface TableSeparator {
362
363
  type: 'separator';
363
364
  text: string;
364
365
  }
365
- export declare type BlockAny = BlockNamed;
366
+ export type BlockAny = BlockNamed;
366
367
  export interface BlockNamed extends Omit<Block, 'content'> {
367
368
  name: string;
368
369
  content: [(Verbatim | Para | Code)?] | Array<Image | BlockCaption> | RootBlock;
@@ -385,9 +386,9 @@ export interface BlockFormula extends Omit<BlockNamed, 'content'> {
385
386
  name: 'formula';
386
387
  content: [Verbatim];
387
388
  }
388
- export declare type FormattingCodes = FormattingCodeA | FormattingCodeC | FormattingCodeB | FormattingCodeD | FormattingCodeE | FormattingCodeF | FormattingCodeI | FormattingCodeL | FormattingCodeN | FormattingCodeX | FormattingCodeZ | FormattingCodeV | FormattingCodeS | FormattingCodeAny;
389
- export declare 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;
390
- export declare type Node = PodNode;
391
- export declare type AstTree = Array<PodNode>;
392
- export declare type PodliteDocument = RootBlock;
389
+ export type FormattingCodes = FormattingCodeA | FormattingCodeC | FormattingCodeB | FormattingCodeD | FormattingCodeE | FormattingCodeF | FormattingCodeI | FormattingCodeL | FormattingCodeN | FormattingCodeX | FormattingCodeZ | FormattingCodeV | FormattingCodeS | FormattingCodeAny;
390
+ 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;
391
+ export type Node = PodNode;
392
+ export type AstTree = Array<PodNode>;
393
+ export type PodliteDocument = RootBlock;
393
394
  export {};
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.0.51";
1
+ export declare const version = "0.0.52";
package/lib/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // generated by scripts/inject-version.mjs — do not edit by hand
5
- exports.version = '0.0.51';
5
+ exports.version = '0.0.52';
6
6
  //# sourceMappingURL=version.js.map
package/lib/writer.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Default writer
3
3
  */
4
- /// <reference types="node" />
5
4
  import * as Events from 'events';
6
5
  declare class Writer extends Events.EventEmitter {
7
6
  INDEXTERMS: any[];