spec-up-t 1.1.31 → 1.1.33
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 +1 -1
- package/assets/compiled/head.css +2 -2
- package/assets/css/collapse-meta-info.css +2 -2
- package/assets/css/index.css +4 -6
- package/assets/js/collapse-meta-info.js +4 -4
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/fix-markdown-files.js +8 -2
- package/src/prepare-tref.js +21 -28
- package/templates/template.html +1 -0
package/assets/compiled/body.js
CHANGED
|
@@ -134,7 +134,7 @@ function tokenInput(){let t=document.createElement("button");t.classList.add("bu
|
|
|
134
134
|
function pdfDownload(){fetch("index.pdf",{method:"HEAD"}).then(e=>{if(e.ok){let e=document.createElement("a");e.classList.add("button-pdf-download"),e.classList.add("btn"),e.target="_blank",e.rel="noopener noreferrer",e.href="index.pdf",e.title="Download this page as a PDF",e.innerHTML="PDF",document.querySelector("#container-search-h7vc6omi2hr2880").appendChild(e)}else console.log("PDF file does not exist. No PDF download button will be added.")}).catch(e=>{console.error("Error checking PDF file:",e)})}document.addEventListener("DOMContentLoaded",(function(){pdfDownload()}));
|
|
135
135
|
function helpButtons(){const t=document.createElement("a");t.textContent="?",t.classList.add("help-button","btn"),t.title="Click to see the explanation of the buttons at the documentation website, in a new tab.",t.target="_blank",t.rel="noopener noreferrer",t.href="https://trustoverip.github.io/spec-up-t-website/docs/user-interface-overview/specification#explanation-of-the-buttons-in-the-specification",function(t){document.querySelectorAll("#content dl dt").forEach(e=>{e.appendChild(t.cloneNode(!0))})}(t)}document.addEventListener("DOMContentLoaded",helpButtons);
|
|
136
136
|
function collapseDefinitions(){const t=document.querySelectorAll("#content dl.terms-and-definitions-list > dd"),e=document.querySelectorAll("#content dl.terms-and-definitions-list > dt"),n=document.querySelectorAll(".collapse-all-defs-button");e.forEach(t=>{const e=document.createElement("button");e.classList.add("collapse-all-defs-button","btn"),e.innerHTML="▲",e.setAttribute("id","toggleButton"),t.appendChild(e)}),document.addEventListener("click",e=>{e.target.classList.contains("collapse-all-defs-button")&&(!function(){const e=t[0].classList.contains("hidden");t.forEach(t=>{t.classList.toggle("hidden",!e),t.classList.toggle("visible",e)}),n.forEach(t=>{t.innerHTML=e?"▲":"▼",t.title=e?"Collapse all definitions":"Expand all definitions"})}(),e.target.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"}),setTimeout(()=>{window.scrollBy({top:-100,behavior:"smooth"})},500))})}document.addEventListener("DOMContentLoaded",(function(){collapseDefinitions()}));
|
|
137
|
-
function createToggleButton(t){const e=document.createElement("button");e.classList.add("meta-info-toggle-button","btn"),e.textContent="
|
|
137
|
+
function createToggleButton(t){const e=document.createElement("button");e.classList.add("meta-info-toggle-button","btn"),e.textContent="ℹ️",e.title="Meta info",e.addEventListener("click",(function(){t.classList.toggle("collapsed"),t.classList.contains("collapsed"),this.textContent="ℹ️"}));let n=t.previousElementSibling;for(;n&&"DT"!==n.tagName;)n=n.previousElementSibling;n?n.appendChild(e):t.insertBefore(e,t.firstChild)}document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll("dl > dd:has(table)").forEach((function(t){const e=document.createElement("div");for(e.classList.add("meta-info-content-wrapper");t.firstChild&&t.firstChild!==t.querySelector(".meta-info-toggle-button");)e.appendChild(t.firstChild);t.querySelector(".meta-info-toggle-button")||createToggleButton(t),t.appendChild(e),t.classList.add("collapsed")}))}));
|
|
138
138
|
/**
|
|
139
139
|
* @file This file adds an href attribute to the snapshot link on the page via client side JS DOM manipulation.
|
|
140
140
|
* @author Kor Dwarshuis
|
package/assets/compiled/head.css
CHANGED
|
@@ -8,7 +8,7 @@ code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-fami
|
|
|
8
8
|
#back-to-top-a1zncgtqfpzsig8{position:fixed;bottom:20px;text-decoration:none;left:calc(100% - 1.8em);width:1.5em;height:1.5em;margin:0;padding:0;background-color:#1e6eae;color:#222;border-radius:50px;text-align:center;font-size:30px;color:#fff;box-shadow:0 0 1.3px rgba(0,0,0,.07),0 0 3.6px rgba(0,0,0,.1),0 0 8.7px rgba(0,0,0,.13),0 0 29px rgba(0,0,0,.2);cursor:pointer;border:none;display:none;align-items:center;justify-content:center}
|
|
9
9
|
@-webkit-keyframes notyf-fadeinup{0%{opacity:0;transform:translateY(25%)}to{opacity:1;transform:translateY(0)}}@keyframes notyf-fadeinup{0%{opacity:0;transform:translateY(25%)}to{opacity:1;transform:translateY(0)}}@-webkit-keyframes notyf-fadeinleft{0%{opacity:0;transform:translateX(25%)}to{opacity:1;transform:translateX(0)}}@keyframes notyf-fadeinleft{0%{opacity:0;transform:translateX(25%)}to{opacity:1;transform:translateX(0)}}@-webkit-keyframes notyf-fadeoutright{0%{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(25%)}}@keyframes notyf-fadeoutright{0%{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(25%)}}@-webkit-keyframes notyf-fadeoutdown{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(25%)}}@keyframes notyf-fadeoutdown{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(25%)}}@-webkit-keyframes ripple{0%{transform:scale(0) translateY(-45%) translateX(13%)}to{transform:scale(1) translateY(-45%) translateX(13%)}}@keyframes ripple{0%{transform:scale(0) translateY(-45%) translateX(13%)}to{transform:scale(1) translateY(-45%) translateX(13%)}}.notyf{position:fixed;top:0;left:0;height:100%;width:100%;color:#fff;z-index:9999;display:flex;flex-direction:column;align-items:flex-end;justify-content:flex-end;pointer-events:none;box-sizing:border-box;padding:20px}.notyf__icon--error,.notyf__icon--success{height:21px;width:21px;background:#fff;border-radius:50%;display:block;margin:0 auto;position:relative}.notyf__icon--error:after,.notyf__icon--error:before{content:"";background:currentColor;display:block;position:absolute;width:3px;border-radius:3px;left:9px;height:12px;top:5px}.notyf__icon--error:after{transform:rotate(-45deg)}.notyf__icon--error:before{transform:rotate(45deg)}.notyf__icon--success:after,.notyf__icon--success:before{content:"";background:currentColor;display:block;position:absolute;width:3px;border-radius:3px}.notyf__icon--success:after{height:6px;transform:rotate(-45deg);top:9px;left:6px}.notyf__icon--success:before{height:11px;transform:rotate(45deg);top:5px;left:10px}.notyf__toast{display:block;overflow:hidden;pointer-events:auto;-webkit-animation:notyf-fadeinup .3s ease-in forwards;animation:notyf-fadeinup .3s ease-in forwards;box-shadow:0 3px 7px 0 rgba(0,0,0,.25);position:relative;padding:0 15px;border-radius:2px;max-width:300px;transform:translateY(25%);box-sizing:border-box;flex-shrink:0}.notyf__toast--disappear{transform:translateY(0);-webkit-animation:notyf-fadeoutdown .3s forwards;animation:notyf-fadeoutdown .3s forwards;-webkit-animation-delay:.25s;animation-delay:.25s}.notyf__toast--disappear .notyf__icon,.notyf__toast--disappear .notyf__message{-webkit-animation:notyf-fadeoutdown .3s forwards;animation:notyf-fadeoutdown .3s forwards;opacity:1;transform:translateY(0)}.notyf__toast--disappear .notyf__dismiss{-webkit-animation:notyf-fadeoutright .3s forwards;animation:notyf-fadeoutright .3s forwards;opacity:1;transform:translateX(0)}.notyf__toast--disappear .notyf__message{-webkit-animation-delay:.05s;animation-delay:.05s}.notyf__toast--upper{margin-bottom:20px}.notyf__toast--lower{margin-top:20px}.notyf__toast--dismissible .notyf__wrapper{padding-right:30px}.notyf__ripple{height:400px;width:400px;position:absolute;transform-origin:bottom right;right:0;top:0;border-radius:50%;transform:scale(0) translateY(-51%) translateX(13%);z-index:5;-webkit-animation:ripple .4s ease-out forwards;animation:ripple .4s ease-out forwards}.notyf__wrapper{display:flex;align-items:center;padding-top:17px;padding-bottom:17px;padding-right:15px;border-radius:3px;position:relative;z-index:10}.notyf__icon{width:22px;text-align:center;font-size:1.3em;opacity:0;-webkit-animation:notyf-fadeinup .3s forwards;animation:notyf-fadeinup .3s forwards;-webkit-animation-delay:.3s;animation-delay:.3s;margin-right:13px}.notyf__dismiss{position:absolute;top:0;right:0;height:100%;width:26px;margin-right:-15px;-webkit-animation:notyf-fadeinleft .3s forwards;animation:notyf-fadeinleft .3s forwards;-webkit-animation-delay:.35s;animation-delay:.35s;opacity:0}.notyf__dismiss-btn{background-color:rgba(0,0,0,.25);border:none;cursor:pointer;transition:opacity .2s ease,background-color .2s ease;outline:0;opacity:.35;height:100%;width:100%}.notyf__dismiss-btn:after,.notyf__dismiss-btn:before{content:"";background:#fff;height:12px;width:2px;border-radius:3px;position:absolute;left:calc(50% - 1px);top:calc(50% - 5px)}.notyf__dismiss-btn:after{transform:rotate(-45deg)}.notyf__dismiss-btn:before{transform:rotate(45deg)}.notyf__dismiss-btn:hover{opacity:.7;background-color:rgba(0,0,0,.15)}.notyf__dismiss-btn:active{opacity:.8}.notyf__message{vertical-align:middle;position:relative;opacity:0;-webkit-animation:notyf-fadeinup .3s forwards;animation:notyf-fadeinup .3s forwards;-webkit-animation-delay:.25s;animation-delay:.25s;line-height:1.5em}@media only screen and (max-width:480px){.notyf{padding:0}.notyf__ripple{height:600px;width:600px;-webkit-animation-duration:.5s;animation-duration:.5s}.notyf__toast{max-width:none;border-radius:0;box-shadow:0 -2px 7px 0 rgba(0,0,0,.13);width:100%}.notyf__dismiss{width:56px}}
|
|
10
10
|
#content dl dd.hidden{display:none}#content dl dd.visible{display:block}.collapse-all-defs-button{float:right}
|
|
11
|
-
|
|
11
|
+
dl>dd:has(table)>.meta-info-content-wrapper{max-height:100px;transition:max-height .3s ease-out}dl>dd:has(table).collapsed>.meta-info-content-wrapper{padding-top:0;padding-bottom:0;overflow:hidden;transition:max-height .3s ease-out;max-height:0}
|
|
12
12
|
.modal-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.5);display:flex;justify-content:center;align-items:center;z-index:1000}.modal{background-color:#fff;padding:2rem 20px 20px;border-radius:8px;max-width:80%;max-height:80%;overflow-y:auto;position:relative;box-shadow:0 2px 10px rgba(0,0,0,.1)}.modal-close{position:absolute;top:0;right:5px;background-color:transparent;border:none;font-size:2rem;line-height:1;cursor:pointer}
|
|
13
13
|
.alphabet-index-container{margin-bottom:1em}.alphabet-index-container,.number-of-terms{font-size:.8em;text-align:center;width:100%}.alphabet-index-container a{background-color:#f5f5f5;border:1px solid #e0e0e0;border-radius:50%;color:#333;display:inline-block;font-size:.9rem;height:20px;line-height:20px;margin:2px;text-align:center;text-decoration:none;width:20px}
|
|
14
14
|
.button-pdf-download{padding-left:.1em;padding-right:.1em;border:none;background:red;color:#fff;box-shadow:2.8px 2.8px 2.2px rgba(0,0,0,.02),6.7px 6.7px 5.3px rgba(0,0,0,.028),12.5px 12.5px 10px rgba(0,0,0,.035),22.3px 22.3px 17.9px rgba(0,0,0,.042),41.8px 41.8px 33.4px rgba(0,0,0,.05),100px 100px 80px rgba(0,0,0,.07)}
|
|
@@ -24,4 +24,4 @@ h2,h3,h4,h5,h6{margin-top:1.5em!important}.toc-anchor{font-size:.875em;color:inh
|
|
|
24
24
|
article a[href^="https://"]:not(.btn)::after,article a[href^=http]:not(.btn)::after{content:'';width:12px;height:12px;margin-left:4px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z'/%3E%3Cpath fill-rule='evenodd' d='M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z'/%3E%3C/svg%3E");background-position:center;background-repeat:no-repeat;background-size:contain;display:inline-block}
|
|
25
25
|
#repo_issues>header{background:#eee;border-bottom:1px solid #ddd}#repo_issues>header span:first-of-type{font-weight:700;padding-top:.1em}#repo_issues>header .repo-issue-toggle{margin-left:auto;color:inherit;font-weight:700;text-decoration:none}#repo_issue_list{list-style:none;margin:0;padding:0 1.25em 1.25em;font-size:.85em;overflow:auto;-ms-overflow-style:none;scrollbar-width:none}#repo_issue_list::-webkit-scrollbar{display:none}#repo_issue_list:empty:before{content:"No issues found";display:block;text-align:center;font-size:1.1em;color:#aaa;margin:1em 0 0}.repo-issue detail-box{display:flex;flex-direction:column;padding:1em 0;border-bottom:1px solid #ddd}.repo-issue detail-box>section{order:1}.repo-issue detail-box>section:empty+.repo-issue-title [detail-box-toggle]{display:none}.repo-issue-title{display:flex;align-items:center}.repo-issue-link{flex:1;margin:0 0 0 .5em}.repo-issue-number{height:1em;margin:0 .4em 0 0;padding:.3em .25em 0;border-radius:3px;font-weight:700;background:#eee;border:1px solid #ddd;text-align:center;line-height:1em}.repo-issue-number:before{content:"#";font-weight:400;margin:0 .1em 0 0}.repo-issue [detail-box-toggle]{margin:0 0 0 1em;opacity:.35;transition:opacity .4s}.repo-issue [detail-box-toggle]:hover,.repo-issue detail-box[open] [detail-box-toggle]{opacity:1}
|
|
26
26
|
.adjust-font-size #decreaseBtn{background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" xmlns:xlink="http://www.w3.org/1999/xlink"><text x="50%" y="50%" font-family="Times New Roman" font-size="50" fill="black" dominant-baseline="middle" text-anchor="middle">A</text></svg>') no-repeat center}.adjust-font-size #increaseBtn{background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" xmlns:xlink="http://www.w3.org/1999/xlink"><text x="50%" y="50%" font-family="Times New Roman" font-size="80" fill="black" dominant-baseline="middle" text-anchor="middle">A</text></svg>') no-repeat center}
|
|
27
|
-
:target{scroll-margin-top:calc(50vh)}body:not([hashscroll]) :target{animation:highlight-target 3.5s .25s ease}body:not([hashscroll]) dt:has(:target){animation:highlight-target-parent-dt 3.5s .25s ease}svg[icon]{width:1.25em;height:1.25em;vertical-align:text-top}@keyframes highlight-target{50%{background-color:#ff0}}@keyframes highlight-target-parent-dt{50%{background-color:#ff0;border:1px solid #00c8ff}}#svg{display:none}main *{
|
|
27
|
+
:target{scroll-margin-top:calc(50vh)}body:not([hashscroll]) :target{animation:highlight-target 3.5s .25s ease}body:not([hashscroll]) dt:has(:target){animation:highlight-target-parent-dt 3.5s .25s ease}svg[icon]{width:1.25em;height:1.25em;vertical-align:text-top}@keyframes highlight-target{50%{background-color:#ff0}}@keyframes highlight-target-parent-dt{50%{background-color:#ff0;border:1px solid #00c8ff}}#svg{display:none}main *{overflow-wrap:anywhere;word-break:normal}dd td img{max-width:30px}.notice{margin:1em 0;padding:.5em .9em .55em .65em;border-left:.5em solid}.notice p{margin:.4em 0 0}.note{background:#e9fbe9;border-color:#52e052}.note .notice-link{display:block;color:#178217}.issue{background:#e9f0fb;border-color:#527fe0}.issue .notice-link:before{display:block;color:#1e4cae}.warning{background:#fbe9e9;border-color:#e05252}.warning .notice-link{display:block;color:#ae1e1e}.example{color:#cebe00;background:#1a1e23;border-left:.5em solid}.example .notice-link{display:block;color:inherit;font-size:1.1em;font-family:Heebo,san-serif}.example pre[class*=language-]{padding:0;border-radius:0}.todo{background:#fbe4ff;border-color:#9700e2}.todo .notice-link{display:block;color:#6d00a2}
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
Description: Make the meta-info tables collapsible
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
dl>dd:has(table)>.meta-info-content-wrapper {
|
|
8
8
|
max-height: 100px;
|
|
9
9
|
transition: max-height 0.3s ease-out;
|
|
10
10
|
/* This should be higher than the tallest content */
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
dl>dd:has(table).collapsed>.meta-info-content-wrapper {
|
|
14
14
|
padding-top: 0;
|
|
15
15
|
padding-bottom: 0;
|
|
16
16
|
|
package/assets/css/index.css
CHANGED
|
@@ -35,13 +35,11 @@ svg[icon] {
|
|
|
35
35
|
display: none;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
main * {
|
|
40
|
-
|
|
41
|
-
/* Breaks at any
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/* Breaks only at allowed break points, more browser support */
|
|
39
|
+
overflow-wrap: anywhere;
|
|
40
|
+
/* Breaks long URLs at any point without distorting column width */
|
|
41
|
+
word-break: normal;
|
|
42
|
+
/* Breaks words at logical places according to the language */
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
dd td img {
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
function createToggleButton(element) {
|
|
10
10
|
const toggleButton = document.createElement('button');
|
|
11
11
|
toggleButton.classList.add('meta-info-toggle-button', 'btn');
|
|
12
|
-
toggleButton.textContent = '
|
|
12
|
+
toggleButton.textContent = 'ℹ️';
|
|
13
13
|
toggleButton.title = 'Meta info';
|
|
14
14
|
|
|
15
15
|
// Add event listener to the button
|
|
16
16
|
toggleButton.addEventListener('click', function () {
|
|
17
17
|
element.classList.toggle('collapsed');
|
|
18
18
|
if (element.classList.contains('collapsed')) {
|
|
19
|
-
this.textContent = '
|
|
19
|
+
this.textContent = 'ℹ️';
|
|
20
20
|
} else {
|
|
21
|
-
this.textContent = '
|
|
21
|
+
this.textContent = 'ℹ️';
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -37,7 +37,7 @@ function createToggleButton(element) {
|
|
|
37
37
|
|
|
38
38
|
// Find all elements with class 'collapsible' and make them collapsible
|
|
39
39
|
document.addEventListener('DOMContentLoaded', function () {
|
|
40
|
-
const collapsibles = document.querySelectorAll('
|
|
40
|
+
const collapsibles = document.querySelectorAll('dl > dd:has(table)');
|
|
41
41
|
|
|
42
42
|
collapsibles.forEach(function (element) {
|
|
43
43
|
// Wrap content (excluding button) in a div for easy toggling
|
package/index.js
CHANGED
|
@@ -267,7 +267,7 @@ module.exports = async function (options = {}) {
|
|
|
267
267
|
const termsIndex = (spec.markdown_paths || ['spec.md']).indexOf('terms-and-definitions-intro.md');
|
|
268
268
|
if (termsIndex !== -1) {
|
|
269
269
|
// Append the HTML string to the content of terms-and-definitions-intro.md. This string is used to create a div that is used to insert an alphabet index, and a div that is used as the starting point of the terminology index. The newlines are essential for the correct rendering of the markdown.
|
|
270
|
-
docs[termsIndex] += '\n\n<div id="terminology-section-
|
|
270
|
+
docs[termsIndex] += '\n\n<div id="terminology-section-start-h7vc6omi2hr2880"></div>\n\n';
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
let doc = docs.join("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-up-t",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.33",
|
|
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": {
|
|
@@ -53,9 +53,15 @@ function fixMarkdownFiles(directory) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// Prepend `~ ` to lines that do not start with `[[def
|
|
56
|
+
// Prepend `~ ` to lines that do not start with `[[def:`, `[[tref:`, are not blank, do not already start with `~ `, and are not HTML comments
|
|
57
57
|
for (let i = 0; i < newLines.length; i++) {
|
|
58
|
-
if (
|
|
58
|
+
if (
|
|
59
|
+
!newLines[i].startsWith('[[def:') &&
|
|
60
|
+
!newLines[i].startsWith('[[tref:') &&
|
|
61
|
+
newLines[i].trim() !== '' &&
|
|
62
|
+
!newLines[i].startsWith('~ ') &&
|
|
63
|
+
!newLines[i].trim().startsWith('<!--')
|
|
64
|
+
) {
|
|
59
65
|
newLines[i] = `~ ${newLines[i]}`;
|
|
60
66
|
modified = true;
|
|
61
67
|
}
|
package/src/prepare-tref.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file prepare-tref.js
|
|
3
|
-
* @description This
|
|
4
|
-
*
|
|
3
|
+
* @description This module provides functionality to process markdown files in a directory recursively,
|
|
4
|
+
* searching for specific `[[tref:]]` references, and replacing them with detailed information
|
|
5
|
+
* fetched from a local JSON file (`xtrefs-data.json`). The information includes metadata such as
|
|
6
|
+
* owner, repository, commit hash, and content. If no matching reference is found, a placeholder
|
|
7
|
+
* message is written to the file.
|
|
8
|
+
*
|
|
9
|
+
* The module includes:
|
|
10
|
+
* - A helper function `getLocalXTrefContent` to retrieve reference data from the JSON file.
|
|
11
|
+
* - A main function `prepareTref` to process directories and markdown files, replacing tref references.
|
|
12
|
+
*
|
|
13
|
+
* This is useful for dynamically enriching markdown documentation with external reference details.
|
|
14
|
+
*
|
|
15
|
+
* @requires fs - Node.js file system module for reading and writing files.
|
|
16
|
+
* @requires path - Node.js path module for handling file paths.
|
|
17
|
+
* @requires dedent - A utility for removing indentation from multi-line strings.
|
|
5
18
|
*
|
|
6
19
|
* @module prepareTref
|
|
7
|
-
* @requires fs
|
|
8
|
-
* @requires path
|
|
9
20
|
*/
|
|
10
21
|
|
|
11
22
|
const fs = require('fs');
|
|
@@ -54,8 +65,7 @@ function prepareTref(directory) {
|
|
|
54
65
|
|
|
55
66
|
// Split the content into lines
|
|
56
67
|
let lines = data.split('\n');
|
|
57
|
-
|
|
58
|
-
// Handle specific functionality for `[[tref:` lines
|
|
68
|
+
|
|
59
69
|
for (let i = 0; i < lines.length; i++) {
|
|
60
70
|
if (lines[i].startsWith('[[tref:')) {
|
|
61
71
|
|
|
@@ -74,34 +84,19 @@ function prepareTref(directory) {
|
|
|
74
84
|
const match = lines[i].match(tref);
|
|
75
85
|
if (match) {
|
|
76
86
|
const result = match[1].split(',').map(term => term.trim());
|
|
77
|
-
localXTrefContent = getLocalXTrefContent(result[0], result[1]);
|
|
78
|
-
/*
|
|
79
|
-
|
|
80
|
-
Remove the `[[def: ...]]:` lines from the content.
|
|
81
|
-
|
|
82
|
-
\[\[def: matches the literal [[def:
|
|
83
|
-
|
|
84
|
-
.*? lazily matches any character(including commas) until the next part of the regex.
|
|
85
|
-
|
|
86
|
-
\]\]: matches the literal ]]:.
|
|
87
|
-
|
|
88
|
-
The g flag ensures that all occurrences in the string are replaced.
|
|
89
|
-
*/
|
|
90
|
-
// const defPart = /\[\[def: .*?\]\]:/g;
|
|
91
|
-
const defPart = /\[\[def: ([^,]+),.*?\]\]/g;
|
|
87
|
+
const localXTrefContent = getLocalXTrefContent(result[0], result[1]);
|
|
92
88
|
|
|
89
|
+
const defPart = /\[\[def: ([^,]+),.*?\]\]/g;
|
|
93
90
|
localXTrefContent.content = localXTrefContent.content.replace(defPart, '');
|
|
94
91
|
|
|
95
92
|
const readyForWrite = dedent`
|
|
96
93
|
${match[0]}
|
|
97
|
-
<!-- This is a copy of the saved remote text. Remove it if you like. It is automatically (re)generated -->
|
|
98
|
-
<dd>
|
|
99
94
|
| Property | Value |
|
|
100
95
|
| -------- | ----- |
|
|
101
96
|
| Owner |  ${localXTrefContent.owner} |
|
|
102
97
|
| Repo | [${localXTrefContent.repo}](${localXTrefContent.repoUrl}) |
|
|
103
98
|
| Commit hash | ${localXTrefContent.commitHash} |
|
|
104
|
-
|
|
99
|
+
|
|
105
100
|
${localXTrefContent.content}
|
|
106
101
|
`;
|
|
107
102
|
|
|
@@ -110,8 +105,7 @@ ${localXTrefContent.content}
|
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
107
|
} catch (err) {
|
|
113
|
-
fs.writeFileSync(itemPath, match[0] + '\n\n' + '
|
|
114
|
-
// console.error(`❌ Error reading or writing file ${item.name}: ${err}`);
|
|
108
|
+
fs.writeFileSync(itemPath, match[0] + '\n\n' + '\n\nNothing found, so nothing to show.', 'utf8');
|
|
115
109
|
}
|
|
116
110
|
}
|
|
117
111
|
});
|
|
@@ -120,10 +114,9 @@ ${localXTrefContent.content}
|
|
|
120
114
|
}
|
|
121
115
|
}
|
|
122
116
|
|
|
123
|
-
// Start processing from the given directory
|
|
124
117
|
processDirectory(directory);
|
|
125
118
|
}
|
|
126
119
|
|
|
127
120
|
module.exports = {
|
|
128
121
|
prepareTref
|
|
129
|
-
};
|
|
122
|
+
};
|