hdoc-tools 0.53.0 → 0.54.0

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 (2) hide show
  1. package/hdoc-build.js +17 -3
  2. package/package.json +1 -1
package/hdoc-build.js CHANGED
@@ -97,8 +97,12 @@
97
97
 
98
98
  // Mutable references updated immediately before each md.render() call so
99
99
  // the highlight and frontmatter plugin callbacks can identify the current
100
- // file. Safe because md.render() is synchronous nothing can interleave
101
- // between setting these and reading them back within a single render.
100
+ // file. md.render() is synchronous, so these are safe to READ from within
101
+ // the render itself (e.g. the highlight callback reading currentMdFilePath).
102
+ // They are NOT safe to read back AFTER an await: transform_file runs up to 8
103
+ // concurrently, so a concurrent render can clobber these while we're awaiting.
104
+ // Anything needed past the first await must be snapshotted into a local first
105
+ // (see file_frontmatter in transform_file).
102
106
  let currentMdFilePath = "";
103
107
  let currentFrontmatter = "";
104
108
 
@@ -303,6 +307,16 @@
303
307
  // Render markdown into HTML
304
308
  html_txt = md.render(md_txt);
305
309
 
310
+ // Capture this file's frontmatter into a local NOW, before any await.
311
+ // currentFrontmatter is shared module-level state populated by the mdfm
312
+ // callback during the (synchronous) md.render() above. transform_file runs
313
+ // up to 8-at-a-time (see the chunked Promise.all in run()), so the await
314
+ // below yields the event loop and lets a concurrent transform_file reset
315
+ // and overwrite currentFrontmatter — if we read it back after the await we
316
+ // would parse another file's frontmatter. Snapshot it while it is still
317
+ // guaranteed to be ours.
318
+ const file_frontmatter = currentFrontmatter;
319
+
306
320
  // md.render() synchronously queued any Mermaid diagrams in this file.
307
321
  // Render them to SVG now (memoized/deduped) so the files exist before
308
322
  // PDF generation below reads them, and before validation/zipping.
@@ -318,7 +332,7 @@
318
332
  let fm_contains_reading_time = false;
319
333
  let fm_contains_description = false;
320
334
 
321
- const fm_content = currentFrontmatter.split(/\r?\n/);
335
+ const fm_content = file_frontmatter.split(/\r?\n/);
322
336
  if (fm_content.length >= 0) {
323
337
  for (fm_prop of fm_content) {
324
338
  const fm_id = fm_prop.slice(0, fm_prop.indexOf(":"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.53.0",
3
+ "version": "0.54.0",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {