spec-up-t 1.2.0 → 1.2.2

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/index.js CHANGED
@@ -189,6 +189,14 @@ module.exports = async function (options = {}) {
189
189
  return fs.readFileSync(path, 'utf8');
190
190
  }
191
191
  },
192
+ {
193
+ test: 'spec',
194
+ transform: function (originalMatch, type, name) {
195
+ // Simply return an empty string or special marker that won't be treated as a definition term
196
+ // The actual rendering will be handled by the markdown-it extension
197
+ return `<span class="spec-marker" data-spec="${name}"></span>`;
198
+ }
199
+ },
192
200
  /**
193
201
  * Custom replacer for tref tags that converts them directly to HTML definition term elements.
194
202
  *
@@ -392,70 +400,108 @@ module.exports = async function (options = {}) {
392
400
  return dl.classList && dl.classList.contains('terms-and-definitions-list');
393
401
  });
394
402
 
395
- // First special case - handle transcluded-xref-term dt that comes BEFORE the main dl
396
- const transcludedTermsBeforeMainDl = document.querySelectorAll('dt.transcluded-xref-term');
403
+ // Find any transcluded term dt elements anywhere in the document
404
+ const transcludedTerms = document.querySelectorAll('dt.transcluded-xref-term');
405
+
397
406
  let mainDl = null;
398
407
 
408
+ // If we have an existing dl with the terms-and-definitions-list class, use it
399
409
  if (dlElements.length > 0) {
400
- // Use the first terms-and-definitions-list as our main container
401
- mainDl = dlElements[0];
402
-
403
- // Special handling for transcluded terms that appear BEFORE the main dl
404
- transcludedTermsBeforeMainDl.forEach(dt => {
405
- // Check if this dt is not already inside a dl.terms-and-definitions-list
406
- if (!dt.parentElement.classList.contains('terms-and-definitions-list')) {
407
- // This is a dt outside our main list - move it into the main dl at the beginning
408
- const dtClone = dt.cloneNode(true);
409
- mainDl.insertBefore(dtClone, mainDl.firstChild);
410
- dt.parentNode.removeChild(dt);
410
+ mainDl = dlElements[0]; // Use the first one
411
+ }
412
+ // If we have transcluded terms but no main dl, we need to create one
413
+ else if (transcludedTerms.length > 0) {
414
+ // Create a new dl element with the right class
415
+ mainDl = document.createElement('dl');
416
+ mainDl.className = 'terms-and-definitions-list';
417
+
418
+ // Look for the marker
419
+ const marker = document.getElementById('terminology-section-start-h7vc6omi2hr2880');
420
+
421
+ if (marker) {
422
+ // Insert the new dl right after the marker
423
+ if (marker.nextSibling) {
424
+ marker.parentNode.insertBefore(mainDl, marker.nextSibling);
425
+ } else {
426
+ marker.parentNode.appendChild(mainDl);
411
427
  }
412
- });
428
+ } else {
429
+ // Fallback to the original approach if marker isn't found
430
+ const firstTerm = transcludedTerms[0];
431
+ const insertPoint = firstTerm.parentNode;
432
+ insertPoint.parentNode.insertBefore(mainDl, insertPoint);
433
+ }
434
+ }
413
435
 
414
- // Remove any empty dt elements that may exist
415
- const emptyDts = mainDl.querySelectorAll('dt:empty');
416
- emptyDts.forEach(emptyDt => {
417
- emptyDt.parentNode.removeChild(emptyDt);
418
- });
436
+ // Safety check - if we still don't have a mainDl, exit early to avoid null reference errors
437
+ if (!mainDl) {
438
+ return html; // Return the original HTML without modifications
439
+ }
419
440
 
420
- // Process all subsequent content after the main dl
421
- let currentNode = mainDl.nextSibling;
422
-
423
- // Process all subsequent content
424
- while (currentNode) {
425
- // Save the next node before potentially modifying the DOM
426
- // (This is important because modifying the DOM can invalidate our references)
427
- const nextNode = currentNode.nextSibling;
428
-
429
- // Handle different node types
430
- if (currentNode.nodeType === 1) { // 1 = Element node
431
- if (currentNode.tagName === 'DL') {
432
- // Found another definition list - move all its children to the main dl
433
- // This effectively merges the two lists into one
434
- while (currentNode.firstChild) {
435
- mainDl.appendChild(currentNode.firstChild);
436
- }
441
+ // Now process all transcluded terms and other dt elements
442
+ transcludedTerms.forEach(dt => {
443
+ // Check if this dt is not already inside our main dl
444
+ if (dt.parentElement !== mainDl) {
445
+ // Move it into the main dl
446
+ const dtClone = dt.cloneNode(true);
447
+ mainDl.appendChild(dtClone);
448
+ dt.parentNode.removeChild(dt);
449
+ }
450
+ });
437
451
 
438
- // Remove the now-empty dl element
439
- currentNode.parentNode.removeChild(currentNode);
440
- }
441
- else if (currentNode.tagName === 'DT') {
442
- // Found a standalone dt (like our transcluded tref terms)
443
- // Move it into the main dl to maintain continuity
444
- const dtClone = currentNode.cloneNode(true);
445
- mainDl.appendChild(dtClone);
446
- currentNode.parentNode.removeChild(currentNode);
447
- }
448
- else if (currentNode.tagName === 'P' &&
449
- (!currentNode.textContent || currentNode.textContent.trim() === '')) {
450
- // Remove empty paragraphs - these break the list structure
451
- // Empty <p></p> tags often appear between dl elements
452
- currentNode.parentNode.removeChild(currentNode);
452
+ // First special case - handle transcluded-xref-term dt that comes BEFORE the main dl
453
+ const transcludedTermsBeforeMainDl = document.querySelectorAll('dt.transcluded-xref-term');
454
+
455
+ // Special handling for transcluded terms that appear BEFORE the main dl
456
+ transcludedTermsBeforeMainDl.forEach(dt => {
457
+ // Check if this dt is not already inside our main list
458
+ if (dt.parentElement !== mainDl) {
459
+ // This is a dt outside our main list - move it into the main dl
460
+ const dtClone = dt.cloneNode(true);
461
+ mainDl.appendChild(dtClone);
462
+ dt.parentNode.removeChild(dt);
463
+ }
464
+ });
465
+
466
+ // Remove any empty dt elements that may exist
467
+ const emptyDts = mainDl.querySelectorAll('dt:empty');
468
+ emptyDts.forEach(emptyDt => {
469
+ emptyDt.parentNode.removeChild(emptyDt);
470
+ });
471
+
472
+ // Process all subsequent content after the main dl
473
+ let currentNode = mainDl.nextSibling;
474
+
475
+ // Process all subsequent content
476
+ while (currentNode) {
477
+ // Save the next node before potentially modifying the DOM
478
+ const nextNode = currentNode.nextSibling;
479
+
480
+ // Handle different node types
481
+ if (currentNode.nodeType === 1) { // 1 = Element node
482
+ if (currentNode.tagName === 'DL') {
483
+ // Found another definition list - move all its children to the main dl
484
+ while (currentNode.firstChild) {
485
+ mainDl.appendChild(currentNode.firstChild);
453
486
  }
487
+ // Remove the now-empty dl element
488
+ currentNode.parentNode.removeChild(currentNode);
489
+ }
490
+ else if (currentNode.tagName === 'DT') {
491
+ // Found a standalone dt - move it into the main dl
492
+ const dtClone = currentNode.cloneNode(true);
493
+ mainDl.appendChild(dtClone);
494
+ currentNode.parentNode.removeChild(currentNode);
495
+ }
496
+ else if (currentNode.tagName === 'P' &&
497
+ (!currentNode.textContent || currentNode.textContent.trim() === '')) {
498
+ // Remove empty paragraphs - these break the list structure
499
+ currentNode.parentNode.removeChild(currentNode);
454
500
  }
455
-
456
- // Move to the next node we saved earlier
457
- currentNode = nextNode;
458
501
  }
502
+
503
+ // Move to the next node we saved earlier
504
+ currentNode = nextNode;
459
505
  }
460
506
 
461
507
  // Return the fixed HTML
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Technical specification drafting tool that generates rich specification documents from markdown. Forked from https://github.com/decentralized-identity/spec-up by Daniel Buchner (https://github.com/csuwildcat)",
5
5
  "main": "./index",
6
6
  "repository": {
@@ -16,7 +16,6 @@
16
16
  "assets/css/notyf.css",
17
17
  "assets/css/collapse-definitions.css",
18
18
  "assets/css/create-term-filter.css",
19
- "assets/css/collapse-meta-info.css",
20
19
  "assets/css/modal.css",
21
20
  "assets/css/create-alphabet-index.css",
22
21
  "assets/css/pdf-download.css",
@@ -48,6 +47,7 @@
48
47
  "assets/js/create-alphabet-index.js",
49
48
  "assets/js/search.js",
50
49
  "assets/js/highlightMenuItems.js",
50
+ "assets/js/collapsibleMenu.js",
51
51
  "assets/js/backToTop.js",
52
52
  "assets/js/addAnchorsToTerms.js",
53
53
  "assets/js/copyAnchorToCliboard.js",
@@ -59,11 +59,11 @@
59
59
  "assets/js/collapse-definitions.js",
60
60
  "assets/js/create-term-filter.js",
61
61
  "assets/js/collapse-meta-info.js",
62
+ "assets/js/fix-last-dd.js",
62
63
  "assets/js/add-href-to-snapshot-link.js",
63
64
  "assets/js/adjust-font-size.js",
64
65
  "assets/js/toggle-dense-info.js",
65
66
  "assets/js/close-off-canvas-menu.js",
66
-
67
67
  "assets/js/index.js",
68
68
  "assets/js/horizontal-scroll-hint.js",
69
69
  "assets/js/bootstrap.bundle.min.js"