@datalackey/update-markdown-toc 1.4.2 → 1.4.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.
package/README.md CHANGED
@@ -31,6 +31,10 @@
31
31
  - [Recursive Folder Traversal (Lenient Mode)](#recursive-folder-traversal-lenient-mode)
32
32
  - [Design Goals and Philosophy](#design-goals-and-philosophy)
33
33
  - [Packaging, Publishing, and Inter-relationship with Other Plugins](#packaging-publishing-and-inter-relationship-with-other-plugins)
34
+ - [Heading Extraction Behavior](#heading-extraction-behavior)
35
+ - [Code fences are excluded](#code-fences-are-excluded)
36
+ - [Only ATX-style headings are included](#only-atx-style-headings-are-included)
37
+ - [Inline code spans are stripped before marker detection](#inline-code-spans-are-stripped-before-marker-detection)
34
38
  - [Known Limitations](#known-limitations)
35
39
  - [Contributing and Releasing](#contributing-and-releasing)
36
40
  <!-- TOC:END -->
@@ -124,7 +128,7 @@ or another method that resolves the local `update-markdown-toc` binary.
124
128
  update-markdown-toc [options] [file]
125
129
 
126
130
  Options:
127
- -c, --check <path-to-file-or-folder> Do not write files; exit non-zero if TOC is stale
131
+ -c, --check Do not write files; exit non-zero if TOC is stale
128
132
  -n, --no-external-link-check Skip external HTTP/HTTPS link validation during --check
129
133
  -l, --link-timeout-ms <ms> Per-request timeout for external link checks (default: 3000)
130
134
  -r, --recursive <path-to-folder> Recursively process all .md files under the given folder
@@ -215,11 +219,9 @@ Your `package.json` might look like this:
215
219
  "clean": "rm -rf dist",
216
220
  "compile": "tsc -p tsconfig.json",
217
221
  "pretest": "npm run compile",
218
- "test": "jest",
222
+ "test": "vitest run",
219
223
  "docs:toc": "update-markdown-toc --recursive docs/",
220
- "bundle": "esbuild src/index.ts --bundle --platform=node --outdir=dist",
221
- "package": "npm run clean && npm run compile && npm run bundle",
222
- "build": "npm run docs:toc && npm run test && npm run package"
224
+ "build": "npm run docs:toc && npm run test && npm run compile"
223
225
  }
224
226
  }
225
227
  ```
@@ -249,7 +251,7 @@ When running with `--check`, the tool performs three tiers of link validation in
249
251
  - external links.
250
252
 
251
253
  For full details on behavior, failure output, and performance considerations
252
- see [Common CLI Behavior — Check Mode](../CLI-BEHAVIOR.md#
254
+ see [Common CLI Behavior — Check Mode](../CLI-BEHAVIOR.md#6-check-mode---check)
253
255
 
254
256
 
255
257
  To skip external link validation:
@@ -305,14 +307,14 @@ In this mode:
305
307
  Recursive mode is designed for gradual adoption across larger repositories, where not every Markdown file may yet contain TOC markers.
306
308
  Unlike single-file mode, recursive mode does **not** treat missing TOC markers as an error. This allows incremental rollout of TOC enforcement.
307
309
 
308
- However, structural or filesystem errors still abort the run immediately. These include:
310
+ However, structural or filesystem errors are always reported and cause a non-zero exit. These include:
309
311
 
310
312
  - unreadable files (e.g., permission errors),
311
313
  - mismatched TOC delimiters,
312
314
  - malformed TOC marker pairs,
313
315
  - files containing TOC markers but no Markdown headings.
314
316
 
315
- When such errors occur, the tool prints an error message and exits non-zero without continuing further traversal.
317
+ When such errors occur, the tool prints an error message for each affected file and continues processing the remaining files. All errors are surfaced in a single pass; the process exits non-zero once traversal is complete.
316
318
 
317
319
  When combined with `--verbose`, skipped files (Markdown files without start/end region markers) are reported explicitly. For example:
318
320
 
@@ -352,6 +354,54 @@ The versioning and release of these packages is governed by a coordinated releas
352
354
  the packages adhere to common design and architectural principles policies
353
355
  that are more completely described [here](../../README.md).
354
356
 
357
+ ## Heading Extraction Behavior
358
+
359
+ ### Code fences are excluded
360
+
361
+ Lines inside fenced code blocks are not treated as headings. A `#` character
362
+ that appears inside a ` ``` ` block is code, not a heading, and will not appear
363
+ in the generated TOC.
364
+
365
+ If a code fence is opened but never closed, everything from the opening fence
366
+ to the end of the document is treated as inside the fence and excluded from
367
+ heading extraction. No error is thrown — the headings that appear before the
368
+ unclosed fence are still included.
369
+
370
+ ### Only ATX-style headings are included
371
+
372
+ Only headings written with leading `#` characters (ATX style) are included in
373
+ the TOC:
374
+
375
+ ```markdown
376
+ ## This is included
377
+ ```
378
+
379
+ Setext-style headings — a paragraph immediately followed by `---` or `===` on
380
+ the next line — are excluded. This avoids accidentally treating a paragraph
381
+ followed by a horizontal rule as a heading, which is a common Markdown pattern:
382
+
383
+ ```markdown
384
+ A note for users.
385
+ ---
386
+ ```
387
+
388
+ The line above is a paragraph + horizontal rule, not a heading, and will not
389
+ appear in the TOC.
390
+
391
+ ### Inline code spans are stripped before marker detection
392
+
393
+ Before checking for `<!-- TOC:START -->` and `<!-- TOC:END -->` markers, the
394
+ document is preprocessed to remove inline code spans. This means a marker
395
+ written inside backticks is treated as literal text and will not trigger marker
396
+ detection:
397
+
398
+ ```markdown
399
+ Use `<!-- TOC:START -->` and `<!-- TOC:END -->` as delimiters.
400
+ ```
401
+
402
+ The above line is documentation about the markers, not the markers themselves.
403
+ Only bare (unquoted) marker strings activate the TOC region.
404
+
355
405
  ## Known Limitations
356
406
 
357
407
  **Fragment link validation with formatted headings**
@@ -364,6 +414,7 @@ In practice this affects only headings with inline code, bold, or italic syntax.
364
414
  Plain-text headings are unaffected. A fix to unify both paths is planned for a
365
415
  future release.
366
416
 
417
+
367
418
  ## Contributing and Releasing
368
419
 
369
420
  For code overview, development setup, build workflow, and release procedures (including how to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalackey/update-markdown-toc",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Auto-generate Table of Contents for a Markdown file (or files, recursively from a top level folder)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "homepage": "https://github.com/datalackey/build-tools/tree/main/javascript/update-markdown-toc",
45
45
  "dependencies": {
46
- "@datalackey/tooling-core": "*",
46
+ "@datalackey/tooling-core": "^1.4.4",
47
47
  "github-slugger": "^2.0.0",
48
48
  "ts-dedent": "^2.2.0"
49
49
  },
@@ -1,2 +0,0 @@
1
- import type { RunConfig } from "@datalackey/tooling-core";
2
- export type TocRunConfig = RunConfig;
@@ -1 +0,0 @@
1
- export {};