@agentshouse/mdmodel 0.1.0-cc9fa0498a7f7 → 0.1.0-ce29d61d6f303

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/API.md CHANGED
@@ -107,19 +107,18 @@ Document of a type it does not name is `unresolved-reference`, and a frontmatter
107
107
  one reaching no member is `referenced-missing-file` naming its `referrers`;
108
108
  `attachment` admits any path, and no body link is a referrer.
109
109
 
110
- Validation returns acceptance or one refusal naming the file, the field or
111
- section, and the violated rule. `parse`, `apply`, and `serialize` operate on a single text
112
- Document; they do not validate collection membership or consume binary bytes.
113
- `apply` sets one typed field, including a list or an object as a whole, replaces
114
- one existing section body or the preamble against that value's prior content,
115
- or rewrites one Markdown link destination. A section need not be declared by
116
- the Document's MD Type to be replaced. A field change does not reformat the rest of the file:
117
- an inline value is replaced where it stands, and a value written after the key's line, an empty
118
- one or a block mapping or list, is written after the key's colon in its place.
119
- A field holds a `FrontmatterValue`: null, a string, a boolean, a finite number, a list
120
- without holes or a plain object of them, holding no cycle. `frontmatterValue(value)` is that test, and
121
- `apply` refuses any other value as `frontmatter-fence`; `equalValue(left, right)` compares
122
- two by value, whatever their key order, as `apply` compares a field with its prior.
110
+ Validation returns acceptance or one refusal naming the file, the field or section, and the violated
111
+ rule. `parse`, `apply`, and `serialize` operate on a single text Document; they do not validate
112
+ collection membership or consume binary bytes. `apply` sets one typed field, including a list or an
113
+ object as a whole, replaces one existing section body or the preamble against that value's prior
114
+ content, or rewrites one Markdown link destination. A section need not be declared by the Document's
115
+ MD Type to be replaced. A field change does not reformat the rest of the file: an inline value is
116
+ replaced where it stands, and a value written after the key's line, an empty one or a block mapping
117
+ or list, is written after the key's colon in its place. A field holds a `FrontmatterValue`: null, a
118
+ string, a boolean, a finite number, a list without holes or a plain object of them, holding no
119
+ cycle. `frontmatterValue(value)` is that test, and `apply` refuses any other value as
120
+ `frontmatter-fence`; `equalValue(left, right)` compares two by value, whatever their key order, as
121
+ `apply` compares a field with its prior.
123
122
 
124
123
  `Document.preamble` is a readonly string containing the exact source after
125
124
  frontmatter and before the first section heading recognized by the existing
@@ -281,23 +280,19 @@ caller's number alone: the model holds no tokenizer, counts nothing else, and
281
280
  refuses no input for being too long. A Document the caller supplies no
282
281
  definition for carries the same `unknown-type` refusal `project` returns.
283
282
 
284
- The division descends one level at a time, and only into the piece that does not
285
- fit: the whole input, a heading node, adjacent sibling nodes packed under one
286
- parent, adjacent blocks inside a node, sentences inside a block, and a bound cut
287
- inside a single sentence. A Span covers whole heading nodes or one contiguous
288
- piece inside a single node, never a partial node beside another. A Span that
289
- continues a node repeats that node's own heading line, projected like any other
290
- text and so carrying an internal link's label rather than its destination, and
291
- never an ancestor's heading, so renaming a heading costs what editing that
292
- heading's own body costs. A heading the budget cannot hold beside any text is
293
- not repeated, a continuation piece that begins with an astral character the
294
- room beside its heading cannot hold is carried without the heading, and a
295
- heading with no body of its own leads its first child node rather than standing
296
- as a Span of nothing but itself. Overlap exists at the
297
- sentence level alone, where each Span after the first repeats its predecessor's
298
- last sentence whenever the budget holds both; when it cannot hold both, the
299
- Span carries its own sentence alone. An untyped input arrives without a
300
- definition and descends the same ladder.
283
+ The division descends one level at a time, and only into the piece that does not fit: the whole
284
+ input, a heading node, adjacent sibling nodes packed under one parent, adjacent blocks inside a
285
+ node, sentences inside a block, and a bound cut inside a single sentence. A Span covers whole
286
+ heading nodes or one contiguous piece inside a single node, never a partial node beside another. A
287
+ Span that continues a node repeats that node's own heading line, projected like any other text and
288
+ so carrying an internal link's label rather than its destination, and never an ancestor's heading,
289
+ so renaming a heading costs what editing that heading's own body costs. A heading the budget cannot
290
+ hold beside any text is not repeated, a continuation piece that begins with an astral character the
291
+ room beside its heading cannot hold is carried without the heading, and a heading with no body of
292
+ its own leads its first child node rather than standing as a Span of nothing but itself. Overlap
293
+ exists at the sentence level alone, where each Span after the first repeats its predecessor's last
294
+ sentence whenever the budget holds both; when it cannot hold both, the Span carries its own sentence
295
+ alone. An untyped input arrives without a definition and descends the same ladder.
301
296
 
302
297
  Division is total: every authored character of the input belongs to at least one
303
298
  Span, and an input carrying no authored text divides into no Span at all. A
@@ -1 +1 @@
1
- {"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAnC,YAAqB,MAAM,EAAE,MAAM,EAGlC;CACF;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG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,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG3E;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GACd;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqB9F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAgBjE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEzD"}
package/dist/yaml.js CHANGED
@@ -84,6 +84,30 @@ export function interpretPlain(text) {
84
84
  return Number(text);
85
85
  return text;
86
86
  }
87
+ const ESCAPES = {
88
+ b: '\b',
89
+ f: '\f',
90
+ n: '\n',
91
+ r: '\r',
92
+ t: '\t',
93
+ '"': '"',
94
+ '/': '/',
95
+ '\\': '\\',
96
+ };
97
+ function parseEscape(c) {
98
+ c.i += 1;
99
+ const escaped = peek(c);
100
+ const held = ESCAPES[escaped];
101
+ if (held !== undefined) {
102
+ c.i += 1;
103
+ return held;
104
+ }
105
+ const hex = c.text.slice(c.i + 1, c.i + 5);
106
+ if (escaped !== 'u' || c.i + 5 > c.end || !/^[0-9A-Fa-f]{4}$/.test(hex))
107
+ throw new YamlError(c.i);
108
+ c.i += 5;
109
+ return String.fromCharCode(Number.parseInt(hex, 16));
110
+ }
87
111
  function parseQuoted(c) {
88
112
  const quote = peek(c);
89
113
  const start = c.i;
@@ -91,31 +115,19 @@ function parseQuoted(c) {
91
115
  let out = '';
92
116
  while (c.i < c.end) {
93
117
  const ch = peek(c);
118
+ if (quote === "'" && ch === "'" && c.i + 1 < c.end && c.text[c.i + 1] === "'") {
119
+ out += "'";
120
+ c.i += 2;
121
+ continue;
122
+ }
94
123
  if (ch === quote) {
95
124
  c.i += 1;
96
125
  return scalar(out, start, c.i);
97
126
  }
98
127
  if (ch === '\n' || ch === '\r')
99
128
  throw new YamlError(c.i);
100
- if (quote === "'" && ch === "'" && c.text[c.i + 1] === "'") {
101
- out += "'";
102
- c.i += 2;
103
- continue;
104
- }
105
129
  if (quote === '"' && ch === '\\') {
106
- c.i += 1;
107
- const escaped = peek(c);
108
- if (escaped === 'n')
109
- out += '\n';
110
- else if (escaped === 't')
111
- out += '\t';
112
- else if (escaped === '"')
113
- out += '"';
114
- else if (escaped === '\\')
115
- out += '\\';
116
- else
117
- throw new YamlError(c.i);
118
- c.i += 1;
130
+ out += parseEscape(c);
119
131
  continue;
120
132
  }
121
133
  out += ch;
@@ -136,6 +136,6 @@ Library is accepted too, so `unresolved-link` never names it and
136
136
  ## YAML subset
137
137
 
138
138
  Frontmatter and a schema text are each a mapping in a closed YAML subset: block and flow mappings,
139
- block and flow sequences, a block sequence item that opens a mapping, plain and quoted scalars, `true`, `false`, `null`,
139
+ block and flow sequences, a block sequence item that opens a mapping, plain and quoted scalars (a single-quoted scalar doubles its apostrophe, a double-quoted one takes JSON's escapes), `true`, `false`, `null`,
140
140
  and decimal numbers. It does not take YAML 1.1 boolean or timestamp aliases,
141
141
  octal numbers, anchors, tags, or block scalars. A mapping carries each key once.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdmodel",
3
- "version": "0.1.0-cc9fa0498a7f7",
3
+ "version": "0.1.0-ce29d61d6f303",
4
4
  "description": "MD Type language, parser, validator, structured change application, Markdown syntax profile, and conformance fixtures",
5
5
  "license": "MIT",
6
6
  "type": "module",