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/assets/compiled/body.js +7 -5
- package/assets/compiled/head.css +5 -6
- package/assets/css/backToTop.css +1 -0
- package/assets/css/header-navbar.css +1 -1
- package/assets/css/pdf-download.css +27 -12
- package/assets/css/pdf-styles.css +174 -0
- package/assets/css/sidebar-toc.css +109 -2
- package/assets/css/terms-and-definitions.css +65 -47
- package/assets/js/collapse-meta-info.js +5 -1
- package/assets/js/collapsibleMenu.js +133 -0
- package/assets/js/edit-term-buttons.js +19 -4
- package/assets/js/fix-last-dd.js +44 -0
- package/assets/js/highlightMenuItems.js +5 -0
- package/assets/js/insert-trefs.js +2 -1
- package/assets/js/pdf-download.js +18 -5
- package/index.js +100 -54
- package/package.json +1 -1
- package/src/asset-map.json +2 -2
- package/src/create-pdf.js +141 -390
- package/templates/template.html +3 -0
- package/assets/css/collapse-meta-info.css +0 -40
- package/assets/css/terms-and-definitions.1.css +0 -223
- package/assets/js/index.1.js +0 -137
- package/assets/js/insert-xrefs.1.js +0 -372
- package/index.new.js +0 -662
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
|
-
//
|
|
396
|
-
const
|
|
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
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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.
|
|
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": {
|
package/src/asset-map.json
CHANGED
|
@@ -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"
|