@entropicwarrior/sdoc 0.2.2 → 0.2.4

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.
@@ -265,6 +265,15 @@ Content of Section B.
265
265
  ```
266
266
 
267
267
  Width: \`auto\` (shrink to content), \`NN%\` (percentage), or \`NNpx\` (pixels). Default is 100%. Alignment: \`left\` (default), \`center\`, or \`right\`. All flags compose freely in any order.
268
+
269
+ To include a literal \`|\` in a cell (e.g. for math), escape it with \`\\|\`:
270
+
271
+ ```
272
+ {[table]
273
+ Expression | Value
274
+ \|x\| + \|y\| | 8
275
+ }
276
+ ```
268
277
  }
269
278
 
270
279
  # Inline Formatting @inline-formatting
@@ -307,7 +316,7 @@ Content of Section B.
307
316
 
308
317
  # References @references
309
318
  {
310
- Assign a slug with \`@slug\` on a heading, then reference it anywhere with \`@slug\`:
319
+ Assign a slug with \`@slug\` on a heading, then reference it elsewhere in the same document with \`@slug\`:
311
320
 
312
321
  ```
313
322
  # Setup @setup {
@@ -318,6 +327,14 @@ Content of Section B.
318
327
  Make sure you complete @setup first.
319
328
  }
320
329
  ```
330
+
331
+ References are **document-local only** — \`@slug\` resolves within the current file. To point a reader to a section in another file, use a link with a fragment:
332
+
333
+ ```
334
+ See [Setup](./other-file.sdoc#setup) for details.
335
+ ```
336
+
337
+ Do not write \`@setup\` when the target scope is in a different file — it will be flagged as a broken reference.
321
338
  }
322
339
 
323
340
  # Code Blocks @code-blocks
@@ -462,7 +479,7 @@ Content of Section B.
462
479
  {
463
480
  Backslash escapes special characters: \`\\\\\` \`\\{\` \`\\}\` \`\\@\`
464
481
  \`\\[\` \`\\]\` \`\\(\` \`\\)\` \`\\*\` \`\\~\` \`\\#\` \`\\!\` \`\\\<\`
465
- \`\\\>\` \`\\\$\` \`\\+\` \`\\=\` \`\\-\` \`\\^\` \`\\?\`
482
+ \`\\\>\` \`\\\$\` \`\\+\` \`\\=\` \`\\-\` \`\\^\` \`\\?\` \`\\|\`
466
483
 
467
484
  A line starting with \`\\#\` renders as a literal \`#\` (not a heading). Use \`\\\$\` to prevent a dollar sign from starting math mode.
468
485
  }
@@ -672,6 +689,25 @@ Content of Section B.
672
689
  ```
673
690
  }
674
691
 
692
+ # Cross-Document @slug References @cross-doc-refs
693
+ {
694
+ \`@slug\` references are document-local. Using \`@slug\` to refer to a section in another file produces a broken reference error:
695
+
696
+ **Wrong** — \`@setup\` does not exist in this file:
697
+
698
+ ```
699
+ See `getting-started.sdoc` @setup for installation steps.
700
+ ```
701
+
702
+ **Right** — use a link with a fragment:
703
+
704
+ ```
705
+ See [Setup](./getting-started.sdoc#setup) for installation steps.
706
+ ```
707
+
708
+ The fragment (\`#setup\`) matches the target scope's \`@id\`. Use \`\\@\` if you need a literal \`@\` in text without triggering reference resolution.
709
+ }
710
+
675
711
  # @References Inside Link Labels @refs-in-link-labels
676
712
  {
677
713
  Inline \`@references\` are parsed everywhere, including inside link labels. If you mention a scope ID in a link label, escape the \`@\` to prevent it being treated as a reference to the current document:
@@ -393,6 +393,8 @@ Content of Section B.
393
393
  {
394
394
  {[.]
395
395
  - A reference is `@id` in text (unescaped)
396
+ - References are document-local: `@id` resolves to a scope within the same file only. Cross-document reference syntax may be introduced in a future version but is not part of v0.2
397
+ - To link to a section in another file, use a standard link with a fragment: `[Label](./other-file.sdoc#section-id)`
396
398
  - References link to the scope with that ID
397
399
  - ID uniqueness is strongly recommended; tooling may warn on duplicates
398
400
  - References are parsed inside link labels — use `\@` to include a literal `@` in a link label without triggering a reference
@@ -508,11 +510,11 @@ Content of Section B.
508
510
 
509
511
  # Escaping @escaping
510
512
  {
511
- In normal text (including headings and paragraphs), a backslash escapes: `\\` `\{` `\}` `\@` `\[` `\]` `\(` `\)` `\*` `\~` `\#` `\!` `\<` `\>` `\$` `\+` `\=` `\-` `\^` `\?` and `` \` ``.
513
+ In normal text (including headings and paragraphs), a backslash escapes: `\\` `\{` `\}` `\@` `\[` `\]` `\(` `\)` `\*` `\~` `\#` `\!` `\<` `\>` `\$` `\+` `\=` `\-` `\^` `\?` `\|` and `` \` ``.
512
514
 
513
515
  Escapes are processed before reference detection.
514
516
 
515
- If a line begins with `\#`, it is treated as a normal paragraph line (rendered with a literal `#`). If a line begins with `\>`, it is treated as a normal paragraph line (rendered with a literal `>`). Use `\$` to prevent a dollar sign from starting math mode.
517
+ If a line begins with `\#`, it is treated as a normal paragraph line (rendered with a literal `#`). If a line begins with `\>`, it is treated as a normal paragraph line (rendered with a literal `>`). Use `\$` to prevent a dollar sign from starting math mode. Use `\|` to include a literal pipe character inside a table cell without it being treated as a column delimiter.
516
518
  }
517
519
 
518
520
  # Code Blocks @code-blocks
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@entropicwarrior/sdoc",
3
3
  "displayName": "SDOC",
4
4
  "description": "A plain-text documentation format with explicit brace scoping — deterministic parsing, AI-agent efficiency, and 10-50x token savings vs Markdown.",
5
- "version": "0.2.2",
5
+ "version": "0.2.4",
6
6
  "publisher": "entropicwarrior",
7
7
  "license": "MIT",
8
8
  "repository": {
package/src/sdoc.js CHANGED
@@ -13,7 +13,7 @@ const COMMAND_LIST_NUMBER = "{[#]";
13
13
  const COMMAND_TABLE = "{[table]";
14
14
  const COMMAND_CODE_FENCE = "```";
15
15
 
16
- const ESCAPABLE = new Set(["\\", "{", "}", "@", "[", "]", "(", ")", "*", "`", "#", "!", "~", "<", ">", "$", "+", "=", "-", "^", "?"]);
16
+ const ESCAPABLE = new Set(["\\", "{", "}", "@", "[", "]", "(", ")", "*", "`", "#", "!", "~", "<", ">", "$", "+", "=", "-", "^", "?", "|"]);
17
17
 
18
18
  let _katex = null;
19
19
  let _katexLoaded = false;
@@ -797,7 +797,7 @@ function parseTableBody(cursor, tableStartLine, options) {
797
797
  break;
798
798
  }
799
799
 
800
- const cells = trimmed.split("|").map((cell) => cell.trim());
800
+ const cells = trimmed.split(/(?<!\\)\|/).map((cell) => cell.trim().replace(/\\\|/g, "|"));
801
801
  rows.push(cells);
802
802
  cursor.next();
803
803
  }