spec-up-t 1.0.75 → 1.0.77
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 +1 -1
- package/assets/css/index.css +10 -7
- package/assets/js/collapse-definitions.js +3 -2
- package/index.js +93 -58
- package/package.json +1 -1
- package/src/create-term-index.js +1 -1
- package/src/fix-markdown-files.js +2 -2
- package/src/get-xrefs-data.js +35 -13
- package/src/insert-term-index.js +10 -5
- package/index.spec-up.js +0 -366
- package/src/prepare-tref.js +0 -7
package/assets/compiled/body.js
CHANGED
|
@@ -126,7 +126,7 @@ function tokenInput(){let t=document.createElement("button");t.classList.add("bu
|
|
|
126
126
|
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()}));
|
|
127
127
|
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://blockchainbird.github.io/spec-up-t-website/docs/general/specification#explanation-buttons",function(t){document.querySelectorAll("#content dl dt").forEach(e=>{e.appendChild(t.cloneNode(!0))})}(t)}document.addEventListener("DOMContentLoaded",helpButtons);
|
|
128
128
|
function createAlphabetIndex(){const e=document.getElementById("alphabet-index-h7vc6omi2hr2880"),t=document.querySelector(".terms-and-definitions-list").querySelectorAll("dt"),n={};t.forEach(e=>{const t=e.querySelector("span");if(t&&t.id){const e=t.id,o=e.charAt(e.indexOf("term:")+5).toUpperCase();n[o]||(n[o]=t.id)}});const o=document.createElement("div");o.className="alphabet-index";const r=document.createElement("p");r.className="number-of-terms",r.textContent=`– There are ${t.length} terms –`;const c=e.parentNode;c.insertBefore(r,e.nextSibling),c.insertBefore(o,r.nextSibling),Object.keys(n).sort().forEach(e=>{const t=document.createElement("a");t.href="#"+n[e],t.textContent=e,o.appendChild(t)})}document.addEventListener("DOMContentLoaded",(function(){createAlphabetIndex()}));
|
|
129
|
-
function collapseDefinitions(){const t=document.querySelectorAll("#content dl dd"),e=document.querySelectorAll(".
|
|
129
|
+
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()}));
|
|
130
130
|
/**
|
|
131
131
|
* @file This file adds an href attribute to the snapshot link on the page via client side JS DOM manipulation.
|
|
132
132
|
* @author Kor Dwarshuis
|
package/assets/compiled/head.css
CHANGED
|
@@ -11,4 +11,4 @@ code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-fami
|
|
|
11
11
|
.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}
|
|
12
12
|
.alphabet-index{display:flex;flex-wrap:wrap;justify-content:center;margin:1em auto;padding:0;width:100%}.alphabet-index a{background-color:#f5f5f5;border:1px solid #e0e0e0;border-radius:50%;color:#333;display:block;font-size:1rem;height:33.33px;line-height:33.33px;margin:3.33px;text-align:center;text-decoration:none;width:33.33px}.number-of-terms{text-align:center}
|
|
13
13
|
.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)}
|
|
14
|
-
:root{--base-theme-color:207,71%;--themed-element-bk:hsl(var(--base-theme-color), 40%);--themed-element-text:#fff;--themed-element-border:1px solid hsl(var(--base-theme-color), 26%);--themed-heading-text:hsl(var(--base-theme-color), 30%);--no-color:255,255,255;--faint-color:245,245,245;--dim-color:225,225,225;--low-color:200,200,200;--mid-color:100,100,100;--high-color:50,50,50;--full-color:0,0,0;--active-color:#3aaaff;--visited-color:rgb(188, 129, 255);--green-status:rgb(0, 123, 9);--light-green-status:rgb(0, 194, 13);--page-bk:rgb(var(--no-color));--page-text:rgb(var(--full-color));--page-text-hover:rgb(var(--full-color));--element-bk:rgb(var(--no-color));--element-bk-hover:rgba(var(--low-color), 0.5);--element-bk-transparent:rgba(var(--dim-color), 0.92);--element-border:rgba(var(--high-color), 0.4);--element-border-focus:rgb(var(--full-color), 0.75);--element-border-radius:3px;--element-shadow-low:0 1px 3px 0px rgba(0,0,0, 0.25);--element-shadow-mid:0 1px 3px 0px rgba(0,0,0, 0.35);--element-shadow-high:0 1px 5px 0px rgba(0,0,0, 0.45);--code-bk:#1a1e23;--input-bk:rgba(var(--dim-color), 0.6);--input-border:rgba(var(--high-color), 0.4);--header-height:48px;--header-bk:rgba(var(--low-color), 0.985);--header-text:rgb(var(--full-color));--header-border:rgba(var(--full-color), 0.1);--header-border-inverse:rgba(var(--no-color), 0.3);--text-shadow:0 1px 2px rgba(0,0,0,0.8);--svg-size:2vw;--font-size:14px}:target{scroll-margin:calc(var(--header-height)/ .75) 0 0}body:not([hashscroll]) :target{animation:highlight 1.5s .25s ease}body{margin:0;padding:0;font-family:Heebo,san-serif;line-height:1.5em;widows:2;orphans:2;word-wrap:break-word;overflow-wrap:break-word;color:#000;word-spacing:1px;counter-reset:h2 toc1}h1{font-size:2em;font-weight:700;line-height:1.2em}h2{margin:1.5em 0 1em}blockquote{position:relative;padding:0;margin:1.75em .75em;color:rgb(var(--mid-color));background:rgb(var(--faint-color))}blockquote:after,blockquote:before{content:"“";position:absolute;top:.065em;left:.065em;font-size:3em;height:.34em;line-height:100%;color:rgb(var(--low-color))}blockquote:after{content:"”";top:auto;left:auto;bottom:.065em;right:.065em;text-align:center}blockquote>p{padding:.6em 1.8em .5em 1.8em}strong strong{font-size:.9em;color:#b30032;font-weight:400;text-transform:uppercase}main article>ol,main article>ul{padding:0 0 0 2em}main article h1,main article h2,main article h3,main article h4,main article h5,main article h6{color:var(--themed-heading-text)}main article h2,main article h3,main article h4{display:flex;font-weight:500}main article h2{counter-reset:h3 h4}main article h3{counter-reset:h4}main article h2:after{counter-increment:h2;content:counter(h2) ".";padding:0 .4em 0 .2em;order:-1}main article h3:after{counter-increment:h3;content:counter(h2) "." counter(h3);padding:0 .45em 0 .2em;order:-1}main article h4:after{counter-increment:h4;content:counter(h2) "." counter(h3) "." counter(h4);padding:0 .5em 0 .2em;order:-1}h1 .toc-anchor{display:none}.toc-anchor{margin:-.1em 0 0;font-size:.875em;color:inherit;text-decoration:none;opacity:.35;order:-1;transition:opacity .3s ease}.toc-anchor:hover{opacity:1}pre{overflow:auto}code{padding:.085em .3em .1em;font-size:1.075em;color:#c7001c;vertical-align:middle;background:#f0f0f0;border-radius:4px}pre code{background:unset;padding:unset;border-radius:unset}h1 code,h2 code,h3 code,h4 code,h5 code,h6 code{font-size:1.25em;margin:-.11em .3em 0 0;border-radius:3px}ol,ul{margin:0;padding:0 0 0 1.2em}dl{margin:0;padding:0}dt{font-weight:700;margin:0;background-color:#f0f0f0;border:1px solid #ccc;padding:10px;border-radius:5px 5px 0 0}dd{margin:0;background-color:#f9f9f9;border:1px solid #ccc;border-top:none;padding:.5em 2em;border-bottom:none}dd p{margin:0}dd+dd{border-bottom:none}dd+dt{margin-top:2em}dd.last-dd{border-radius:0 0 5px 5px;border-bottom:1px solid #ccc}main{box-sizing:border-box;float:right;width:75%;min-width:calc(100% - 325px);max-width:calc(100% - 275px);padding:.5em 2em 1.5em 2em;background:#fff;box-shadow:0 0 5px -1px rgba(0,0,0,.3)}table{display:block;width:-webkit-fill-available;width:fit-content;max-width:100%;margin:1.5em 0 1.75em;border-spacing:0;border-collapse:collapse;overflow-x:auto;word-wrap:normal;overflow-wrap:normal;hyphens:manual}thead tr th{color:var(--themed-element-text);background:var(--themed-element-bk);border:var(--themed-element-border);text-shadow:0 1px 1px rgba(0,0,0,.5)}tr{border-top:1px solid #ccc;background-color:#fff;margin:0;padding:0}tr:nth-child(2n){background-color:#f0f0f0}tr th{font-weight:400;border:1px solid #ccc;text-align:left;margin:0;padding:6px 13px}td,th{padding:9px 13px;border:1px solid #d8d8d8}tr td{border:1px solid #ccc;text-align:left;margin:0;padding:.55em .75em .55em}tr td :first-child,tr th :first-child{margin-top:0}tr td :last-child,tr th :last-child{margin-bottom:0}table pre[class*=language-]{border:none;border-radius:0}table pre[class*=language-]:before{display:none}svg[icon]{width:1.25em;height:1.25em;vertical-align:text-top;pointer-events:none}article p>img{max-width:100%;margin:0 auto}article li{margin-top:.4em}slide-panel>:not(header):not(footer){flex:1}:not(pre)>code[class*=language-],pre[class*=language-]{padding:.65em .8em .8em;background:var(--code-bk)}.tippy-box{box-shadow:var(--element-shadow-mid)}.tippy-box a{color:var(--active-color)}.tippy-box a:visited{color:var(--visited-color)}.tippy-content{padding:.55em .55em .5em}.tippy-content header{margin:0 0 .4em;padding:.15em .3em .1em;border-radius:2px;background:rgba(255,255,255,.1);text-shadow:0 1px rgba(0,0,0,.9)}.tippy-content table,.tippy-content tbody,.tippy-content td,.tippy-content tr{margin:0;padding:0;border:none;border-spacing:0;border-collapse:collapse;background:0 0!important;background-color:transparent!important}.tippy-content table{margin:0 .3em}.tippy-content td{font-size:.9em;padding:.2em 0 0}.tippy-content td:first-child{padding-right:.5em}a[path-0$="github.com"]:before{content:"\f09b";color:var(--page-text);margin:0 .25em 0 0;font-family:FontAwesome;text-decoration:none;display:inline-block;vertical-align:bottom}a[path-0$="github.com"][path-3=issues][path-4],a[path-0$="github.com"][path-3=projects],a[path-0$="github.com"][path-3=pull],a[path-0$="github.com"][path-3=releases]{text-decoration:none}a[path-0$="github.com"][path-3=issues][path-4] span,a[path-0$="github.com"][path-3=projects] span,a[path-0$="github.com"][path-3=pull] span,a[path-0$="github.com"][path-3=releases] span{display:none}a[path-0$="github.com"][path-3=issues][path-4]:after{content:"Issue #" attr(path-4)}a[path-0$="github.com"][path-3=pull]:after{content:"Pull Request #" attr(path-4)}a[path-0$="github.com"][path-3=releases][path-5]:after{content:"Release " attr(path-5)}a[path-0$="github.com"][path-3=projects]:after{content:"Project #" attr(path-4)}[issue-count]:after{content:"Issues (" attr(issue-count) ")";margin:0 0 0 .3em;padding:.1em 0 0}[issue-count=""][animate]{display:none;opacity:0}[issue-count][animate]:not([issue-count=""]){animation:display-show 1s}[panel-toggle]{cursor:pointer}.panel-header{display:flex;align-items:center;height:var(--header-height)}.panel-header>*{display:flex;height:100%;padding:.1em .8em 0;align-items:center}.slide-panel{width:calc(100% - 1em);max-width:475px;transition:transform .35s ease}.slide-panel[panel-open]{transform:translateX(0)}.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}.mermaid{display:flex;align-items:center;justify-content:center;margin:1.5em 0 1.75em}.reference-list{margin:0;padding:0;list-style:none}.reference-list dd a,.reference-status{font-style:italic}.reference-status{color:var(--green-status)}.tippy-box .reference-status{color:var(--light-green-status)}code[class*=language-],pre,pre[class*=language-]{font-size:.9em;margin:1em 0 1.5em;border-radius:3px}.example code[class*=language-],.example pre,.example pre[class*=language-]{margin:0}#svg{display:none}#header{position:sticky;position:-webkit-sticky;padding:0;top:0;margin:-.5em -2em 0 -2em;background:rgba(255,255,255,.9);border-bottom:1px solid rgba(0,0,0,.175);box-shadow:0 1px 3px 1px rgba(0,0,0,.1);z-index:2}#logo{box-sizing:border-box;display:flex;align-items:center;height:100%;padding:.5em}#logo img{height:100%}#logo+span{margin-left:auto}#header #toc_toggle{display:none;padding:0 1em;border-right:1px solid rgba(0,0,0,.15)}#content{max-width:800px}#content h1:first-of-type{margin:1em 0 .5em}#content h1:first-of-type .markdownIt-Anchor{display:none}#repo_issues{width:calc(100% - 1.5em);max-width:450px;border-left:1px solid rgba(0,0,0,.15)}#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}#toc{display:flex;flex-direction:column;width:25%;max-width:325px;min-width:275px;background:#eceff1}#toc header{color:var(--themed-element-text);background:var(--themed-element-bk);box-shadow:0 1px 3px 0 rgba(0,0,0,.3);border:var(--themed-element-border);border-top:none;border-left:none}#toc header [panel-toggle]{display:none;height:var(--header-height);line-height:var(--header-height);margin-left:auto;padding:0 1em;color:inherit;font-weight:700;text-decoration:none}#toc_list{flex:1;padding:1em .8em;overflow:auto}.toc{padding:0 0 1.75em;font-size:.85em}.toc,.toc ul{margin:0;list-style:none}.toc ul{padding:0 0 0 1em}.toc a{display:block;padding:.4em .3em .225em;text-decoration:none;border-radius:3px;color:#333}.toc a:before{color:#000;font-weight:700}.toc a:hover{text-shadow:0 1px 1px #fff;background:rgba(0,0,0,.1)}.toc>li a:before{counter-increment:toc1;content:counter(toc1) ".";padding:0 .4em 0 .2em}.toc>li>ul{counter-reset:toc2}.toc>li>ul>li a:before{counter-increment:toc2;content:counter(toc1) "." counter(toc2);padding:0 .45em 0 .2em}.toc>li>ul ul{counter-reset:toc3}.toc>li>ul ul li a:before{counter-increment:toc3;content:counter(toc1) "." counter(toc2) "." counter(toc3);padding:0 .5em 0 .2em}@media (min-width:900px){slide-panel{z-index:2}#slidepanels[open=sidebar]:before{opacity:0;transition:none;pointer-events:none}#slidepanels:before{z-index:1}#toc{transition:none;transform:translate3d(0,0,0);box-shadow:0 0 5px 1px rgba(0,0,0,.15) inset;z-index:0}}@media (max-width:900px){main{width:100%;min-width:auto;max-width:none;padding:.5em 1.25em 1.5em 1.25em}#header{margin:-.5em -1.25em 0 -1.25em}#toc header [panel-toggle]{display:block}#header #toc_toggle{display:flex}}@media (max-width:550px){td{font-size:.8em}}@keyframes display-show{0%{display:none;opacity:0}1%{display:block}100%{opacity:1}}@keyframes highlight{50%{background-color:#ff0}}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}.btn,.no-xref-found-message{font-variant:small-caps;text-transform:uppercase}.no-xref-found-message{background:#f8c481!important;color:#03365f!important;margin:0 .5em;padding:0 .8em;border-radius:.25rem;font-size:.8rem}.powered-by,.snapshots{margin:0;padding:0;flex:none}.powered-by{text-align:center;font-size:.7em}.snapshots a{display:block;margin:.5em;padding:.5em .8em;border-radius:.25rem;background:#a9dde0;color:#03365f;text-decoration:none;font-size:1rem}
|
|
14
|
+
:root{--base-theme-color:207,71%;--themed-element-bk:hsl(var(--base-theme-color), 40%);--themed-element-text:#fff;--themed-element-border:1px solid hsl(var(--base-theme-color), 26%);--themed-heading-text:hsl(var(--base-theme-color), 30%);--no-color:255,255,255;--faint-color:245,245,245;--dim-color:225,225,225;--low-color:200,200,200;--mid-color:100,100,100;--high-color:50,50,50;--full-color:0,0,0;--active-color:#3aaaff;--visited-color:rgb(188, 129, 255);--green-status:rgb(0, 123, 9);--light-green-status:rgb(0, 194, 13);--page-bk:rgb(var(--no-color));--page-text:rgb(var(--full-color));--page-text-hover:rgb(var(--full-color));--element-bk:rgb(var(--no-color));--element-bk-hover:rgba(var(--low-color), 0.5);--element-bk-transparent:rgba(var(--dim-color), 0.92);--element-border:rgba(var(--high-color), 0.4);--element-border-focus:rgb(var(--full-color), 0.75);--element-border-radius:3px;--element-shadow-low:0 1px 3px 0px rgba(0,0,0, 0.25);--element-shadow-mid:0 1px 3px 0px rgba(0,0,0, 0.35);--element-shadow-high:0 1px 5px 0px rgba(0,0,0, 0.45);--code-bk:#1a1e23;--input-bk:rgba(var(--dim-color), 0.6);--input-border:rgba(var(--high-color), 0.4);--header-height:48px;--header-bk:rgba(var(--low-color), 0.985);--header-text:rgb(var(--full-color));--header-border:rgba(var(--full-color), 0.1);--header-border-inverse:rgba(var(--no-color), 0.3);--text-shadow:0 1px 2px rgba(0,0,0,0.8);--svg-size:2vw;--font-size:14px}:target{scroll-margin:calc(var(--header-height)/ .75) 0 0}body:not([hashscroll]) :target{animation:highlight 1.5s .25s ease}body{margin:0;padding:0;font-family:Heebo,san-serif;line-height:1.5em;widows:2;orphans:2;word-wrap:break-word;overflow-wrap:break-word;color:#000;word-spacing:1px;counter-reset:h2 toc1}h1{font-size:2em;font-weight:700;line-height:1.2em}h2{margin:1.5em 0 1em}blockquote{position:relative;padding:0;margin:1.75em .75em;color:rgb(var(--mid-color));background:rgb(var(--faint-color))}blockquote:after,blockquote:before{content:"“";position:absolute;top:.065em;left:.065em;font-size:3em;height:.34em;line-height:100%;color:rgb(var(--low-color))}blockquote:after{content:"”";top:auto;left:auto;bottom:.065em;right:.065em;text-align:center}blockquote>p{padding:.6em 1.8em .5em 1.8em}strong strong{font-size:.9em;color:#b30032;font-weight:400;text-transform:uppercase}main article>ol,main article>ul{padding:0 0 0 2em}main article h1,main article h2,main article h3,main article h4,main article h5,main article h6{color:var(--themed-heading-text)}main article h2,main article h3,main article h4{display:flex;font-weight:500}main article h2{counter-reset:h3 h4}main article h3{counter-reset:h4}main article h2:after{counter-increment:h2;content:counter(h2) ".";padding:0 .4em 0 .2em;order:-1}main article h3:after{counter-increment:h3;content:counter(h2) "." counter(h3);padding:0 .45em 0 .2em;order:-1}main article h4:after{counter-increment:h4;content:counter(h2) "." counter(h3) "." counter(h4);padding:0 .5em 0 .2em;order:-1}h1 .toc-anchor{display:none}.toc-anchor{margin:-.1em 0 0;font-size:.875em;color:inherit;text-decoration:none;opacity:.35;order:-1;transition:opacity .3s ease}.toc-anchor:hover{opacity:1}pre{overflow:auto}code{padding:.085em .3em .1em;font-size:1.075em;color:#c7001c;vertical-align:middle;background:#f0f0f0;border-radius:4px}pre code{background:unset;padding:unset;border-radius:unset}h1 code,h2 code,h3 code,h4 code,h5 code,h6 code{font-size:1.25em;margin:-.11em .3em 0 0;border-radius:3px}ol,ul{margin:0;padding:0 0 0 1.2em}dl.terms-and-definitions-list{margin:0;padding:0}dl.terms-and-definitions-list dt{font-weight:700;margin:0;background-color:#f0f0f0;border:1px solid #ccc;padding:10px;border-radius:5px 5px 0 0}dl.terms-and-definitions-list dd{margin:0;background-color:#f9f9f9;border:1px solid #ccc;border-top:none;padding:.5em 2em;border-bottom:none}dl.terms-and-definitions-list dd p{margin:0}dl.terms-and-definitions-list dd+dd{border-bottom:none}dl.terms-and-definitions-list dd+dt{margin-top:2em}dl.terms-and-definitions-list dd.last-dd{border-radius:0 0 5px 5px;border-bottom:1px solid #ccc}main{box-sizing:border-box;float:right;width:75%;min-width:calc(100% - 325px);max-width:calc(100% - 275px);padding:.5em 2em 1.5em 2em;background:#fff;box-shadow:0 0 5px -1px rgba(0,0,0,.3)}table{display:block;width:-webkit-fill-available;width:fit-content;max-width:100%;margin:1.5em 0 1.75em;border-spacing:0;border-collapse:collapse;overflow-x:auto;word-wrap:normal;overflow-wrap:normal;hyphens:manual}thead tr th{color:var(--themed-element-text);background:var(--themed-element-bk);border:var(--themed-element-border);text-shadow:0 1px 1px rgba(0,0,0,.5)}tr{border-top:1px solid #ccc;background-color:#fff;margin:0;padding:0}tr:nth-child(2n){background-color:#f0f0f0}tr th{font-weight:400;border:1px solid #ccc;text-align:left;margin:0;padding:6px 13px}td,th{padding:9px 13px;border:1px solid #d8d8d8}tr td{border:1px solid #ccc;text-align:left;margin:0;padding:.55em .75em .55em}tr td :first-child,tr th :first-child{margin-top:0}tr td :last-child,tr th :last-child{margin-bottom:0}table pre[class*=language-]{border:none;border-radius:0}table pre[class*=language-]:before{display:none}svg[icon]{width:1.25em;height:1.25em;vertical-align:text-top;pointer-events:none}article p>img{max-width:100%;margin:0 auto}article li{margin-top:.4em}slide-panel>:not(header):not(footer){flex:1}:not(pre)>code[class*=language-],pre[class*=language-]{padding:.65em .8em .8em;background:var(--code-bk)}.tippy-box{box-shadow:var(--element-shadow-mid)}.tippy-box a{color:var(--active-color)}.tippy-box a:visited{color:var(--visited-color)}.tippy-content{padding:.55em .55em .5em}.tippy-content header{margin:0 0 .4em;padding:.15em .3em .1em;border-radius:2px;background:rgba(255,255,255,.1);text-shadow:0 1px rgba(0,0,0,.9)}.tippy-content table,.tippy-content tbody,.tippy-content td,.tippy-content tr{margin:0;padding:0;border:none;border-spacing:0;border-collapse:collapse;background:0 0!important;background-color:transparent!important}.tippy-content table{margin:0 .3em}.tippy-content td{font-size:.9em;padding:.2em 0 0}.tippy-content td:first-child{padding-right:.5em}a[path-0$="github.com"]:before{content:"\f09b";color:var(--page-text);margin:0 .25em 0 0;font-family:FontAwesome;text-decoration:none;display:inline-block;vertical-align:bottom}a[path-0$="github.com"][path-3=issues][path-4],a[path-0$="github.com"][path-3=projects],a[path-0$="github.com"][path-3=pull],a[path-0$="github.com"][path-3=releases]{text-decoration:none}a[path-0$="github.com"][path-3=issues][path-4] span,a[path-0$="github.com"][path-3=projects] span,a[path-0$="github.com"][path-3=pull] span,a[path-0$="github.com"][path-3=releases] span{display:none}a[path-0$="github.com"][path-3=issues][path-4]:after{content:"Issue #" attr(path-4)}a[path-0$="github.com"][path-3=pull]:after{content:"Pull Request #" attr(path-4)}a[path-0$="github.com"][path-3=releases][path-5]:after{content:"Release " attr(path-5)}a[path-0$="github.com"][path-3=projects]:after{content:"Project #" attr(path-4)}[issue-count]:after{content:"Issues (" attr(issue-count) ")";margin:0 0 0 .3em;padding:.1em 0 0}[issue-count=""][animate]{display:none;opacity:0}[issue-count][animate]:not([issue-count=""]){animation:display-show 1s}[panel-toggle]{cursor:pointer}.panel-header{display:flex;align-items:center;height:var(--header-height)}.panel-header>*{display:flex;height:100%;padding:.1em .8em 0;align-items:center}.slide-panel{width:calc(100% - 1em);max-width:475px;transition:transform .35s ease}.slide-panel[panel-open]{transform:translateX(0)}.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}.mermaid{display:flex;align-items:center;justify-content:center;margin:1.5em 0 1.75em}.reference-list{margin:0;padding:0;list-style:none}.reference-list dd a,.reference-status{font-style:italic}.reference-status{color:var(--green-status)}.tippy-box .reference-status{color:var(--light-green-status)}code[class*=language-],pre,pre[class*=language-]{font-size:.9em;margin:1em 0 1.5em;border-radius:3px}.example code[class*=language-],.example pre,.example pre[class*=language-]{margin:0}#svg{display:none}#header{position:sticky;position:-webkit-sticky;padding:0;top:0;margin:-.5em -2em 0 -2em;background:rgba(255,255,255,.9);border-bottom:1px solid rgba(0,0,0,.175);box-shadow:0 1px 3px 1px rgba(0,0,0,.1);z-index:2}#logo{box-sizing:border-box;display:flex;align-items:center;height:100%;padding:.5em}#logo img{height:100%}#logo+span{margin-left:auto}#header #toc_toggle{display:none;padding:0 1em;border-right:1px solid rgba(0,0,0,.15)}#content{max-width:800px}#content h1:first-of-type{margin:1em 0 .5em}#content h1:first-of-type .markdownIt-Anchor{display:none}#repo_issues{width:calc(100% - 1.5em);max-width:450px;border-left:1px solid rgba(0,0,0,.15)}#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}#toc{display:flex;flex-direction:column;width:25%;max-width:325px;min-width:275px;background:#eceff1}#toc header{color:var(--themed-element-text);background:var(--themed-element-bk);box-shadow:0 1px 3px 0 rgba(0,0,0,.3);border:var(--themed-element-border);border-top:none;border-left:none}#toc header [panel-toggle]{display:none;height:var(--header-height);line-height:var(--header-height);margin-left:auto;padding:0 1em;color:inherit;font-weight:700;text-decoration:none}#toc_list{flex:1;padding:1em .8em;overflow:auto}.toc{padding:0 0 1.75em;font-size:.85em}.toc,.toc ul{margin:0;list-style:none}.toc ul{padding:0 0 0 1em}.toc a{display:block;padding:.4em .3em .225em;text-decoration:none;border-radius:3px;color:#333}.toc a:before{color:#000;font-weight:700}.toc a:hover{text-shadow:0 1px 1px #fff;background:rgba(0,0,0,.1)}.toc>li a:before{counter-increment:toc1;content:counter(toc1) ".";padding:0 .4em 0 .2em}.toc>li>ul{counter-reset:toc2}.toc>li>ul>li a:before{counter-increment:toc2;content:counter(toc1) "." counter(toc2);padding:0 .45em 0 .2em}.toc>li>ul ul{counter-reset:toc3}.toc>li>ul ul li a:before{counter-increment:toc3;content:counter(toc1) "." counter(toc2) "." counter(toc3);padding:0 .5em 0 .2em}@media (min-width:900px){slide-panel{z-index:2}#slidepanels[open=sidebar]:before{opacity:0;transition:none;pointer-events:none}#slidepanels:before{z-index:1}#toc{transition:none;transform:translate3d(0,0,0);box-shadow:0 0 5px 1px rgba(0,0,0,.15) inset;z-index:0}}@media (max-width:900px){main{width:100%;min-width:auto;max-width:none;padding:.5em 1.25em 1.5em 1.25em}#header{margin:-.5em -1.25em 0 -1.25em}#toc header [panel-toggle]{display:block}#header #toc_toggle{display:flex}}@media (max-width:550px){td{font-size:.8em}}@keyframes display-show{0%{display:none;opacity:0}1%{display:block}100%{opacity:1}}@keyframes highlight{50%{background-color:#ff0}}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}.btn,.no-xref-found-message{font-variant:small-caps;text-transform:uppercase}.no-xref-found-message{background:#f8c481!important;color:#03365f!important;margin:0 .5em;padding:0 .8em;border-radius:.25rem;font-size:.8rem}.powered-by,.snapshots{margin:0;padding:0;flex:none}.powered-by{text-align:center;font-size:.7em}.snapshots a{display:block;margin:.5em;padding:.5em .8em;border-radius:.25rem;background:#a9dde0;color:#03365f;text-decoration:none;font-size:1rem}
|
package/assets/css/index.css
CHANGED
|
@@ -227,12 +227,13 @@ ol, ul {
|
|
|
227
227
|
padding: 0 0 0 1.2em;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
/* START: Definition list for terms */
|
|
231
|
+
dl.terms-and-definitions-list {
|
|
231
232
|
margin: 0;
|
|
232
233
|
padding: 0;
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
dt {
|
|
236
|
+
dl.terms-and-definitions-list dt {
|
|
236
237
|
font-weight: bold;
|
|
237
238
|
margin: 0;
|
|
238
239
|
background-color: #f0f0f0;
|
|
@@ -241,7 +242,7 @@ dt {
|
|
|
241
242
|
border-radius: 5px 5px 0 0;
|
|
242
243
|
}
|
|
243
244
|
|
|
244
|
-
dd {
|
|
245
|
+
dl.terms-and-definitions-list dd {
|
|
245
246
|
margin: 0;
|
|
246
247
|
background-color: #f9f9f9;
|
|
247
248
|
border: 1px solid #ccc;
|
|
@@ -252,24 +253,26 @@ dd {
|
|
|
252
253
|
/* Remove bottom borders for all dd's by default */
|
|
253
254
|
}
|
|
254
255
|
|
|
255
|
-
dd p {
|
|
256
|
+
dl.terms-and-definitions-list dd p {
|
|
256
257
|
margin: 0;
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
/* Remove borders between consecutive <dd> elements */
|
|
260
|
-
dd+dd {
|
|
261
|
+
dl.terms-and-definitions-list dd+dd {
|
|
261
262
|
border-bottom: none;
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
/* Add a margin between the last <dd> and the next <dt> */
|
|
265
|
-
dd+dt {
|
|
266
|
+
dl.terms-and-definitions-list dd+dt {
|
|
266
267
|
margin-top: 2em;
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
dd.last-dd {
|
|
270
|
+
dl.terms-and-definitions-list dd.last-dd {
|
|
270
271
|
border-radius: 0 0 5px 5px;
|
|
271
272
|
border-bottom: 1px solid #ccc;
|
|
272
273
|
}
|
|
274
|
+
/* END: Definition list for terms */
|
|
275
|
+
|
|
273
276
|
|
|
274
277
|
main {
|
|
275
278
|
box-sizing: border-box;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
function collapseDefinitions() {
|
|
2
|
-
const dds = document.querySelectorAll('#content dl dd');
|
|
2
|
+
const dds = document.querySelectorAll('#content dl.terms-and-definitions-list > dd');
|
|
3
|
+
const dts = document.querySelectorAll('#content dl.terms-and-definitions-list > dt');
|
|
3
4
|
const buttons = document.querySelectorAll('.collapse-all-defs-button');
|
|
4
5
|
|
|
5
6
|
function toggleVisibility() {
|
|
@@ -15,7 +16,7 @@ function collapseDefinitions() {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
// Add button as last child of every <dl>
|
|
18
|
-
|
|
19
|
+
dts.forEach(dt => {
|
|
19
20
|
const button = document.createElement('button');
|
|
20
21
|
button.classList.add('collapse-all-defs-button', 'btn');
|
|
21
22
|
button.innerHTML = '▲';
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
module.exports = function (options = {}) {
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const gulp = require('gulp');
|
|
5
6
|
|
|
6
7
|
const {
|
|
7
8
|
fetchExternalSpecs,
|
|
@@ -21,7 +22,6 @@ module.exports = function (options = {}) {
|
|
|
21
22
|
const { insertTermIndex } = require('./src/insert-term-index.js');
|
|
22
23
|
insertTermIndex();
|
|
23
24
|
|
|
24
|
-
const gulp = require('gulp');
|
|
25
25
|
const findPkgDir = require('find-pkg-dir');
|
|
26
26
|
const modulePath = findPkgDir(__dirname);
|
|
27
27
|
let config = fs.readJsonSync('./output/specs-generated.json');
|
|
@@ -29,6 +29,8 @@ module.exports = function (options = {}) {
|
|
|
29
29
|
const createVersionsIndex = require('./src/create-versions-index.js');
|
|
30
30
|
createVersionsIndex(config.specs[0].output_path);
|
|
31
31
|
|
|
32
|
+
const { fixMarkdownFiles } = require('./src/fix-markdown-files.js');
|
|
33
|
+
|
|
32
34
|
let template = fs.readFileSync(path.join(modulePath, 'templates/template.html'), 'utf8');
|
|
33
35
|
let assets = fs.readJsonSync(modulePath + '/src/asset-map.json');
|
|
34
36
|
let externalReferences;
|
|
@@ -46,20 +48,25 @@ module.exports = function (options = {}) {
|
|
|
46
48
|
return fs.readFileSync(path, 'utf8');
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
|
-
];
|
|
51
|
+
];
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
// Synchronously process markdown files
|
|
54
|
+
fixMarkdownFiles(path.join(config.specs[0].spec_directory, config.specs[0].spec_terms_directory));
|
|
55
|
+
|
|
56
|
+
function createScriptElementWithXrefDataForEmbeddingInHtml() {
|
|
57
|
+
// Test if xrefs-data.js exists, else make it an empty string
|
|
58
|
+
const inputPath = path.join('output', 'xrefs-data.js');
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
let xrefsData = "";
|
|
61
|
+
if (fs.existsSync(inputPath)) {
|
|
62
|
+
xrefsData = '<script>' + fs.readFileSync(inputPath, 'utf8') + '</script>';
|
|
63
|
+
}
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
const inputPath = 'output/xrefs-data.js';
|
|
58
|
-
let xrefsData = "";
|
|
59
|
-
if (fs.existsSync(inputPath)) {
|
|
60
|
-
xrefsData = '<script>' + fs.readFileSync(inputPath, 'utf8') + '</script>';
|
|
65
|
+
return xrefsData;
|
|
61
66
|
}
|
|
62
67
|
|
|
68
|
+
const xrefsData = createScriptElementWithXrefDataForEmbeddingInHtml();
|
|
69
|
+
|
|
63
70
|
function applyReplacers(doc) {
|
|
64
71
|
return doc.replace(replacerRegex, function (match, type, args) {
|
|
65
72
|
let replacer = replacers.find(r => type.trim().match(r.test));
|
|
@@ -101,6 +108,74 @@ module.exports = function (options = {}) {
|
|
|
101
108
|
throw Error("katex distribution could not be located");
|
|
102
109
|
}
|
|
103
110
|
|
|
111
|
+
// Custom plugin to add class to <dl> and the last <dd> in each series after a <dt>
|
|
112
|
+
function addClassToDefinitionList(md) {
|
|
113
|
+
const originalRender = md.renderer.rules.dl_open || function (tokens, idx, options, env, self) {
|
|
114
|
+
return self.renderToken(tokens, idx, options);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Variable to keep track of whether the class has been added to the first <dl> after the target HTML
|
|
118
|
+
let classAdded = false;
|
|
119
|
+
|
|
120
|
+
md.renderer.rules.dl_open = function (tokens, idx, options, env, self) {
|
|
121
|
+
|
|
122
|
+
const targetHtml = 'terminology-section-start-h7vc6omi2hr2880';
|
|
123
|
+
let targetIndex = -1;
|
|
124
|
+
|
|
125
|
+
// Find the index of the target HTML
|
|
126
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
127
|
+
if (tokens[i].content && tokens[i].content.includes(targetHtml)) {
|
|
128
|
+
targetIndex = i;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Add class to the first <dl> only if it comes after the target HTML
|
|
134
|
+
if (targetIndex !== -1 && idx > targetIndex && !classAdded) {
|
|
135
|
+
tokens[idx].attrPush(['class', 'terms-and-definitions-list']);
|
|
136
|
+
classAdded = true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let lastDdIndex = -1;
|
|
140
|
+
|
|
141
|
+
for (let i = idx + 1; i < tokens.length; i++) {
|
|
142
|
+
if (tokens[i].type === 'dl_close') {
|
|
143
|
+
// Add class to the last <dd> before closing <dl>
|
|
144
|
+
if (lastDdIndex !== -1) {
|
|
145
|
+
const ddToken = tokens[lastDdIndex];
|
|
146
|
+
const classIndex = ddToken.attrIndex('class');
|
|
147
|
+
if (classIndex < 0) {
|
|
148
|
+
ddToken.attrPush(['class', 'last-dd']);
|
|
149
|
+
} else {
|
|
150
|
+
ddToken.attrs[classIndex][1] += ' last-dd';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (tokens[i].type === 'dt_open') {
|
|
157
|
+
// Add class to the last <dd> before a new <dt>
|
|
158
|
+
if (lastDdIndex !== -1) {
|
|
159
|
+
const ddToken = tokens[lastDdIndex];
|
|
160
|
+
const classIndex = ddToken.attrIndex('class');
|
|
161
|
+
if (classIndex < 0) {
|
|
162
|
+
ddToken.attrPush(['class', 'last-dd']);
|
|
163
|
+
} else {
|
|
164
|
+
ddToken.attrs[classIndex][1] += ' last-dd';
|
|
165
|
+
}
|
|
166
|
+
lastDdIndex = -1; // Reset for the next series
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (tokens[i].type === 'dd_open') {
|
|
171
|
+
lastDdIndex = i;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return originalRender(tokens, idx, options, env, self);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
104
179
|
try {
|
|
105
180
|
|
|
106
181
|
var toc;
|
|
@@ -218,55 +293,7 @@ module.exports = function (options = {}) {
|
|
|
218
293
|
})
|
|
219
294
|
.use(require('@traptitech/markdown-it-katex'))
|
|
220
295
|
|
|
221
|
-
// Custom plugin to add class to <dl> and the last <dd> in each series after a <dt>
|
|
222
|
-
function addClassToDefinitionList(md) {
|
|
223
|
-
const originalRender = md.renderer.rules.dl_open || function (tokens, idx, options, env, self) {
|
|
224
|
-
return self.renderToken(tokens, idx, options);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
md.renderer.rules.dl_open = function (tokens, idx, options, env, self) {
|
|
228
|
-
// Add class to <dl>
|
|
229
|
-
tokens[idx].attrPush(['class', 'terms-and-definitions-list']);
|
|
230
|
-
|
|
231
|
-
let lastDdIndex = -1;
|
|
232
|
-
|
|
233
|
-
for (let i = idx + 1; i < tokens.length; i++) {
|
|
234
|
-
if (tokens[i].type === 'dl_close') {
|
|
235
|
-
// Add class to the last <dd> before closing <dl>
|
|
236
|
-
if (lastDdIndex !== -1) {
|
|
237
|
-
const ddToken = tokens[lastDdIndex];
|
|
238
|
-
const classIndex = ddToken.attrIndex('class');
|
|
239
|
-
if (classIndex < 0) {
|
|
240
|
-
ddToken.attrPush(['class', 'last-dd']);
|
|
241
|
-
} else {
|
|
242
|
-
ddToken.attrs[classIndex][1] += ' last-dd';
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (tokens[i].type === 'dt_open') {
|
|
249
|
-
// Add class to the last <dd> before a new <dt>
|
|
250
|
-
if (lastDdIndex !== -1) {
|
|
251
|
-
const ddToken = tokens[lastDdIndex];
|
|
252
|
-
const classIndex = ddToken.attrIndex('class');
|
|
253
|
-
if (classIndex < 0) {
|
|
254
|
-
ddToken.attrPush(['class', 'last-dd']);
|
|
255
|
-
} else {
|
|
256
|
-
ddToken.attrs[classIndex][1] += ' last-dd';
|
|
257
|
-
}
|
|
258
|
-
lastDdIndex = -1; // Reset for the next series
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (tokens[i].type === 'dd_open') {
|
|
263
|
-
lastDdIndex = i;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
296
|
|
|
267
|
-
return originalRender(tokens, idx, options, env, self);
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
297
|
|
|
271
298
|
md.use(addClassToDefinitionList);
|
|
272
299
|
|
|
@@ -288,6 +315,14 @@ module.exports = function (options = {}) {
|
|
|
288
315
|
if (spec.external_specs && !externalReferences) {
|
|
289
316
|
externalReferences = await fetchExternalSpecs(spec);
|
|
290
317
|
}
|
|
318
|
+
|
|
319
|
+
// Find the index of the terms-and-definitions-intro.md file
|
|
320
|
+
const termsIndex = (spec.markdown_paths || ['spec.md']).indexOf('terms-and-definitions-intro.md');
|
|
321
|
+
if (termsIndex !== -1) {
|
|
322
|
+
// 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.
|
|
323
|
+
docs[termsIndex] += '\n\n<div id="alphabet-index-h7vc6omi2hr2880"></div>\n\n<div id="terminology-section-start-h7vc6omi2hr2880"></div>\n\n<hr>\n\n';
|
|
324
|
+
}
|
|
325
|
+
|
|
291
326
|
let doc = docs.join("\n");
|
|
292
327
|
doc = applyReplacers(doc);
|
|
293
328
|
md[spec.katex ? "enable" : "disable"](katexRules);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-up-t",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.77",
|
|
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/create-term-index.js
CHANGED
|
@@ -21,7 +21,7 @@ function createTermIndex() {
|
|
|
21
21
|
const config = fs.readJsonSync('specs.json');
|
|
22
22
|
const specDirectories = config.specs.map(spec => spec.spec_directory);
|
|
23
23
|
const specTermDirectoryName = config.specs.map(spec => spec.spec_terms_directory);
|
|
24
|
-
const outputPathJSON = '
|
|
24
|
+
const outputPathJSON = path.join('output', 'term-index.json');
|
|
25
25
|
const files = fs.readdirSync(path.join(specDirectories[0], specTermDirectoryName[0]))
|
|
26
26
|
.filter(file => !file.startsWith('_'));
|
|
27
27
|
|
|
@@ -2,7 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
4
|
// Function to process markdown files in a directory recursively
|
|
5
|
-
function
|
|
5
|
+
function fixMarkdownFiles(directory) {
|
|
6
6
|
// Helper function to process a directory
|
|
7
7
|
function processDirectory(directory) {
|
|
8
8
|
try {
|
|
@@ -92,5 +92,5 @@ function processMarkdownFiles(directory) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
module.exports = {
|
|
95
|
-
|
|
95
|
+
fixMarkdownFiles
|
|
96
96
|
};
|
package/src/get-xrefs-data.js
CHANGED
|
@@ -92,22 +92,44 @@ async function fetchTermInfoFromGithub(GITHUB_API_TOKEN, xref) {
|
|
|
92
92
|
|
|
93
93
|
// Function to fetch the content of a file from a specific commit in a GitHub repository.
|
|
94
94
|
async function fetchFileContentFromCommit(GITHUB_API_TOKEN, owner, repo, commitHash, filePath) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
95
|
+
const MAX_RETRIES = 3;
|
|
96
|
+
let retries = 0;
|
|
97
|
+
|
|
98
|
+
while (retries < MAX_RETRIES) {
|
|
99
|
+
try {
|
|
100
|
+
const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${commitHash}?recursive=1`;
|
|
101
|
+
const treeResponse = await fetch(treeUrl, { headers: setupFetchHeaders(GITHUB_API_TOKEN) });
|
|
102
|
+
|
|
103
|
+
if (treeResponse.ok) {
|
|
104
|
+
const treeData = await treeResponse.json();
|
|
105
|
+
const file = treeData.tree.find(item => item.path === filePath);
|
|
106
|
+
if (file) {
|
|
107
|
+
const fileContentResponse = await fetch(file.url);
|
|
108
|
+
const fileContentData = await fileContentResponse.json();
|
|
109
|
+
if (fileContentData.content) {
|
|
110
|
+
return Buffer.from(fileContentData.content, 'base64').toString('utf-8');
|
|
111
|
+
} else {
|
|
112
|
+
console.error('Error: fileContentData.content is undefined');
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
console.error(`Error: File ${filePath} not found in commit ${commitHash}`);
|
|
116
|
+
}
|
|
117
|
+
} else if (treeResponse.status === 403 && treeResponse.headers.get('X-RateLimit-Remaining') === '0') {
|
|
118
|
+
const resetTime = treeResponse.headers.get('X-RateLimit-Reset');
|
|
119
|
+
const waitTime = resetTime ? (resetTime - Math.floor(Date.now() / 1000)) * 1000 : 60000;
|
|
120
|
+
console.warn(`Rate limit exceeded. Retrying in ${waitTime / 1000} seconds...`);
|
|
121
|
+
await new Promise(resolve => setTimeout(resolve, waitTime));
|
|
122
|
+
retries++;
|
|
123
|
+
} else {
|
|
124
|
+
console.error(`Error: Failed to fetch tree from ${treeUrl}`);
|
|
125
|
+
break;
|
|
106
126
|
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error(`Error fetching file content: ${error.message}`);
|
|
129
|
+
break;
|
|
107
130
|
}
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error(`\n SPEC-UP-T: Error fetching file content: ${error.message}\n`);
|
|
110
131
|
}
|
|
132
|
+
|
|
111
133
|
return null;
|
|
112
134
|
}
|
|
113
135
|
|
package/src/insert-term-index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
2
|
+
* Inserts term index into the specification.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
* term directories, and updates the specification with the term index.
|
|
4
|
+
* This function reads the entries from term-index.json,
|
|
5
|
+
* processes the term directories, and updates the specification with the term index.
|
|
6
|
+
* It modifies the markdown paths in the specification and saves the updated specification
|
|
7
|
+
* to a JSON file in the output directory.
|
|
6
8
|
*
|
|
7
9
|
* @function
|
|
8
10
|
* @name insertTermIndex
|
|
@@ -16,13 +18,16 @@
|
|
|
16
18
|
function insertTermIndex() {
|
|
17
19
|
const fs = require('fs-extra');
|
|
18
20
|
const path = require('path');
|
|
19
|
-
const config = fs.readJsonSync('
|
|
20
|
-
const terms = fs.readJsonSync('
|
|
21
|
+
const config = fs.readJsonSync(path.join('specs.json'));
|
|
22
|
+
const terms = fs.readJsonSync(path.join('output', 'term-index.json'));
|
|
21
23
|
const outputPathJSON = path.join('output', 'specs-generated.json');
|
|
22
24
|
let specGenerated = config;
|
|
23
25
|
let markdownPaths = specGenerated.specs[0].markdown_paths;
|
|
24
26
|
|
|
27
|
+
// Find the index of the "terms-and-definitions-intro.md" file in the markdown paths
|
|
25
28
|
const index = markdownPaths.indexOf('terms-and-definitions-intro.md');
|
|
29
|
+
|
|
30
|
+
//
|
|
26
31
|
if (index !== -1) {
|
|
27
32
|
// Insert the items of the "terms" array after the found index
|
|
28
33
|
markdownPaths.splice(index + 1, 0, ...terms);
|
package/index.spec-up.js
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = function (options = {}) {
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
fetchExternalSpecs,
|
|
6
|
-
validateReferences,
|
|
7
|
-
findExternalSpecByKey
|
|
8
|
-
} = require('./references.js');
|
|
9
|
-
const gulp = require('gulp');
|
|
10
|
-
const fs = require('fs-extra');
|
|
11
|
-
const path = require('path');
|
|
12
|
-
const findPkgDir = require('find-pkg-dir');
|
|
13
|
-
const modulePath = findPkgDir(__dirname);
|
|
14
|
-
let config = fs.readJsonSync('./specs.json');
|
|
15
|
-
let assets = fs.readJsonSync(modulePath + '/src/asset-map.json');
|
|
16
|
-
let externalReferences;
|
|
17
|
-
let references = [];
|
|
18
|
-
let definitions = [];
|
|
19
|
-
|
|
20
|
-
const katexRules = ['math_block', 'math_inline']
|
|
21
|
-
const replacerRegex = /\[\[\s*([^\s\[\]:]+):?\s*([^\]\n]+)?\]\]/img;
|
|
22
|
-
const replacerArgsRegex = /\s*,+\s*/;
|
|
23
|
-
const replacers = [
|
|
24
|
-
{
|
|
25
|
-
test: 'insert',
|
|
26
|
-
transform: function (path) {
|
|
27
|
-
if (!path) return '';
|
|
28
|
-
return fs.readFileSync(path, 'utf8');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
function applyReplacers(doc) {
|
|
34
|
-
return doc.replace(replacerRegex, function (match, type, args) {
|
|
35
|
-
let replacer = replacers.find(r => type.trim().match(r.test));
|
|
36
|
-
return replacer ? replacer.transform(...args.trim().split(replacerArgsRegex)) : match;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function normalizePath(path) {
|
|
41
|
-
return path.trim().replace(/\/$/g, '') + '/';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function renderRefGroup(type) {
|
|
45
|
-
let group = specGroups[type];
|
|
46
|
-
if (!group) return '';
|
|
47
|
-
let html = Object.keys(group).sort().reduce((html, name) => {
|
|
48
|
-
let ref = group[name];
|
|
49
|
-
return html += `
|
|
50
|
-
<dt id="ref:${name}">${name}</dt>
|
|
51
|
-
<dd>
|
|
52
|
-
<cite><a href="${ref.href}">${ref.title}</a></cite>.
|
|
53
|
-
${ref.authors.join('; ')}; ${ref.rawDate}. <span class="reference-status">Status: ${ref.status}</span>.
|
|
54
|
-
</dd>
|
|
55
|
-
`;
|
|
56
|
-
}, '<dl class="reference-list">')
|
|
57
|
-
return `\n${html}\n</dl>\n`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function findKatexDist() {
|
|
61
|
-
const relpath = "node_modules/katex/dist";
|
|
62
|
-
const paths = [
|
|
63
|
-
path.join(process.cwd(), relpath),
|
|
64
|
-
path.join(__dirname, relpath),
|
|
65
|
-
];
|
|
66
|
-
for (const abspath of paths) {
|
|
67
|
-
if (fs.existsSync(abspath)) {
|
|
68
|
-
return abspath
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
throw Error("katex distribution could not be located");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
|
|
76
|
-
var toc;
|
|
77
|
-
var specGroups = {};
|
|
78
|
-
const noticeTypes = {
|
|
79
|
-
note: 1,
|
|
80
|
-
issue: 1,
|
|
81
|
-
example: 1,
|
|
82
|
-
warning: 1,
|
|
83
|
-
todo: 1
|
|
84
|
-
};
|
|
85
|
-
const spaceRegex = /\s+/g;
|
|
86
|
-
const specNameRegex = /^spec$|^spec[-]*\w+$/i;
|
|
87
|
-
const terminologyRegex = /^def$|^ref$|^xref/i;
|
|
88
|
-
const specCorpus = fs.readJsonSync(modulePath + '/assets/compiled/refs.json');
|
|
89
|
-
const containers = require('markdown-it-container');
|
|
90
|
-
const md = require('markdown-it')({
|
|
91
|
-
html: true,
|
|
92
|
-
linkify: true,
|
|
93
|
-
typographer: true
|
|
94
|
-
})
|
|
95
|
-
.use(require('./src/markdown-it-extensions.js'), [
|
|
96
|
-
{
|
|
97
|
-
filter: type => type.match(terminologyRegex),
|
|
98
|
-
parse(token, type, primary) {
|
|
99
|
-
if (!primary) return;
|
|
100
|
-
if (type === 'def') {
|
|
101
|
-
definitions.push(token.info.args);
|
|
102
|
-
return token.info.args.reduce((acc, syn) => {
|
|
103
|
-
return `<span id="term:${syn.replace(spaceRegex, '-').toLowerCase()}">${acc}</span>`;
|
|
104
|
-
}, primary);
|
|
105
|
-
}
|
|
106
|
-
else if (type === 'xref') {
|
|
107
|
-
const url = findExternalSpecByKey(config, token.info.args[0]);
|
|
108
|
-
const term = token.info.args[1].replace(spaceRegex, '-').toLowerCase();
|
|
109
|
-
return `<a class="term-reference" data-local-href="#term:${token.info.args[0]}:${term}"
|
|
110
|
-
href="${url}#term:${term}">${token.info.args[1]}</a>`;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
references.push(primary);
|
|
114
|
-
return `<a class="term-reference" href="#term:${primary.replace(spaceRegex, '-').toLowerCase()}">${primary}</a>`;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
filter: type => type.match(specNameRegex),
|
|
120
|
-
parse(token, type, name) {
|
|
121
|
-
if (name) {
|
|
122
|
-
let _name = name.replace(spaceRegex, '-').toUpperCase();
|
|
123
|
-
let spec = specCorpus[_name] ||
|
|
124
|
-
specCorpus[_name.toLowerCase()] ||
|
|
125
|
-
specCorpus[name.toLowerCase()] ||
|
|
126
|
-
specCorpus[name];
|
|
127
|
-
if (spec) {
|
|
128
|
-
spec._name = _name;
|
|
129
|
-
let group = specGroups[type] = specGroups[type] || {};
|
|
130
|
-
token.info.spec = group[_name] = spec;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
render(token, type, name) {
|
|
135
|
-
if (name) {
|
|
136
|
-
let spec = token.info.spec;
|
|
137
|
-
if (spec) return `[<a class="spec-reference" href="#ref:${spec._name}">${spec._name}</a>]`;
|
|
138
|
-
}
|
|
139
|
-
else return renderRefGroup(type);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
])
|
|
143
|
-
.use(require('markdown-it-attrs'))
|
|
144
|
-
.use(require('markdown-it-chart').default)
|
|
145
|
-
.use(require('markdown-it-deflist'))
|
|
146
|
-
.use(require('markdown-it-references'))
|
|
147
|
-
.use(require('markdown-it-icons').default, 'font-awesome')
|
|
148
|
-
.use(require('markdown-it-ins'))
|
|
149
|
-
.use(require('markdown-it-mark'))
|
|
150
|
-
.use(require('markdown-it-textual-uml'))
|
|
151
|
-
.use(require('markdown-it-sub'))
|
|
152
|
-
.use(require('markdown-it-sup'))
|
|
153
|
-
.use(require('markdown-it-task-lists'))
|
|
154
|
-
.use(require('markdown-it-multimd-table'), {
|
|
155
|
-
multiline: true,
|
|
156
|
-
rowspan: true,
|
|
157
|
-
headerless: true
|
|
158
|
-
})
|
|
159
|
-
.use(containers, 'notice', {
|
|
160
|
-
validate: function (params) {
|
|
161
|
-
let matches = params.match(/(\w+)\s?(.*)?/);
|
|
162
|
-
return matches && noticeTypes[matches[1]];
|
|
163
|
-
},
|
|
164
|
-
render: function (tokens, idx) {
|
|
165
|
-
let matches = tokens[idx].info.match(/(\w+)\s?(.*)?/);
|
|
166
|
-
if (matches && tokens[idx].nesting === 1) {
|
|
167
|
-
let id;
|
|
168
|
-
let type = matches[1];
|
|
169
|
-
if (matches[2]) {
|
|
170
|
-
id = matches[2].trim().replace(/\s+/g, '-').toLowerCase();
|
|
171
|
-
if (noticeTitles[id]) id += '-' + noticeTitles[id]++;
|
|
172
|
-
else noticeTitles[id] = 1;
|
|
173
|
-
}
|
|
174
|
-
else id = type + '-' + noticeTypes[type]++;
|
|
175
|
-
return `<div id="${id}" class="notice ${type}"><a class="notice-link" href="#${id}">${type.toUpperCase()}</a>`;
|
|
176
|
-
}
|
|
177
|
-
else return '</div>\n';
|
|
178
|
-
}
|
|
179
|
-
})
|
|
180
|
-
.use(require('markdown-it-prism'))
|
|
181
|
-
.use(require('markdown-it-toc-and-anchor').default, {
|
|
182
|
-
tocClassName: 'toc',
|
|
183
|
-
tocFirstLevel: 2,
|
|
184
|
-
tocLastLevel: 4,
|
|
185
|
-
tocCallback: (_md, _tokens, html) => toc = html,
|
|
186
|
-
anchorLinkSymbol: '§',
|
|
187
|
-
anchorClassName: 'toc-anchor'
|
|
188
|
-
})
|
|
189
|
-
.use(require('@traptitech/markdown-it-katex'))
|
|
190
|
-
|
|
191
|
-
async function render(spec, assets) {
|
|
192
|
-
try {
|
|
193
|
-
noticeTitles = {};
|
|
194
|
-
specGroups = {};
|
|
195
|
-
console.log('Rendering: ' + spec.title);
|
|
196
|
-
return new Promise(async (resolve, reject) => {
|
|
197
|
-
Promise.all((spec.markdown_paths || ['spec.md']).map(_path => {
|
|
198
|
-
return fs.readFile(spec.spec_directory + _path, 'utf8').catch(e => reject(e))
|
|
199
|
-
})).then(async docs => {
|
|
200
|
-
const features = (({ source, logo }) => ({ source, logo }))(spec);
|
|
201
|
-
if (spec.external_specs && !externalReferences) {
|
|
202
|
-
externalReferences = await fetchExternalSpecs(spec);
|
|
203
|
-
}
|
|
204
|
-
let doc = docs.join("\n");
|
|
205
|
-
doc = applyReplacers(doc);
|
|
206
|
-
md[spec.katex ? "enable" : "disable"](katexRules);
|
|
207
|
-
const render = md.render(doc);
|
|
208
|
-
fs.writeFile(path.join(spec.destination, 'index.html'), `
|
|
209
|
-
<!DOCTYPE html>
|
|
210
|
-
<html lang="en">
|
|
211
|
-
<head>
|
|
212
|
-
<meta charset="utf-8">
|
|
213
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
214
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
215
|
-
|
|
216
|
-
<title>${spec.title}</title>
|
|
217
|
-
|
|
218
|
-
<link href="https://fonts.googleapis.com/css2?family=Heebo:wght@300;400&display=swap" rel="stylesheet">
|
|
219
|
-
|
|
220
|
-
${assets.head}
|
|
221
|
-
</head>
|
|
222
|
-
<body features="${Object.keys(features).join(' ')}">
|
|
223
|
-
|
|
224
|
-
${assets.svg}
|
|
225
|
-
|
|
226
|
-
<main>
|
|
227
|
-
|
|
228
|
-
<header id="header" class="panel-header">
|
|
229
|
-
<span id="toc_toggle" panel-toggle="toc">
|
|
230
|
-
<svg icon><use xlink:href="#svg-nested-list"></use></svg>
|
|
231
|
-
</span>
|
|
232
|
-
<a id="logo" href="${spec.logo_link ? spec.logo_link : '#_'}">
|
|
233
|
-
<img src="${spec.logo}" />
|
|
234
|
-
</a>
|
|
235
|
-
<span issue-count animate panel-toggle="repo_issues">
|
|
236
|
-
<svg icon><use xlink:href="#svg-github"></use></svg>
|
|
237
|
-
</span>
|
|
238
|
-
</header>
|
|
239
|
-
|
|
240
|
-
<article id="content">
|
|
241
|
-
${render}
|
|
242
|
-
</article>
|
|
243
|
-
|
|
244
|
-
</main>
|
|
245
|
-
|
|
246
|
-
<slide-panels id="slidepanels">
|
|
247
|
-
<slide-panel id="repo_issues" options="right">
|
|
248
|
-
<header class="panel-header">
|
|
249
|
-
<span>
|
|
250
|
-
<svg icon><use xlink:href="#svg-github"></use></svg>
|
|
251
|
-
<span issue-count></span>
|
|
252
|
-
</span>
|
|
253
|
-
<span class="repo-issue-toggle" panel-toggle="repo_issues">✕</span>
|
|
254
|
-
</header>
|
|
255
|
-
<ul id="repo_issue_list"></ul>
|
|
256
|
-
</slide-panel>
|
|
257
|
-
|
|
258
|
-
<slide-panel id="toc">
|
|
259
|
-
<header class="panel-header">
|
|
260
|
-
<span>Table of Contents</span>
|
|
261
|
-
<span panel-toggle="toc">✕</span>
|
|
262
|
-
</header>
|
|
263
|
-
<div id="toc_list">
|
|
264
|
-
${toc}
|
|
265
|
-
</div>
|
|
266
|
-
</slide-panel>
|
|
267
|
-
|
|
268
|
-
</slide-panels>
|
|
269
|
-
<div style="display: none;">
|
|
270
|
-
${externalReferences}
|
|
271
|
-
</div>
|
|
272
|
-
</body>
|
|
273
|
-
<script>window.specConfig = ${JSON.stringify(spec)}</script>
|
|
274
|
-
${assets.body}
|
|
275
|
-
</html>
|
|
276
|
-
`, function (err, data) {
|
|
277
|
-
if (err) {
|
|
278
|
-
reject(err);
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
resolve();
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
validateReferences(references, definitions, render);
|
|
285
|
-
references = [];
|
|
286
|
-
definitions = [];
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
catch (e) {
|
|
291
|
-
console.error(e);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
config.specs.forEach(spec => {
|
|
296
|
-
spec.spec_directory = normalizePath(spec.spec_directory);
|
|
297
|
-
spec.destination = normalizePath(spec.output_path || spec.spec_directory);
|
|
298
|
-
|
|
299
|
-
fs.ensureDirSync(spec.destination);
|
|
300
|
-
|
|
301
|
-
let assetTags = {
|
|
302
|
-
svg: fs.readFileSync(modulePath + '/assets/icons.svg', 'utf8') || ''
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
let customAssets = (spec.assets || []).reduce((assets, asset) => {
|
|
306
|
-
let ext = asset.path.split('.').pop();
|
|
307
|
-
if (ext === 'css') {
|
|
308
|
-
assets.css += `<link href="${asset.path}" rel="stylesheet"/>`;
|
|
309
|
-
}
|
|
310
|
-
if (ext === 'js') {
|
|
311
|
-
assets.js[asset.inject || 'body'] += `<script src="${asset.path}" ${asset.module ? 'type="module"' : ''} ></script>`;
|
|
312
|
-
}
|
|
313
|
-
return assets;
|
|
314
|
-
}, {
|
|
315
|
-
css: '',
|
|
316
|
-
js: { head: '', body: '' }
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
if (options.dev) {
|
|
320
|
-
assetTags.head = assets.head.css.map(_path => `<link href="${_path}" rel="stylesheet"/>`).join('') +
|
|
321
|
-
customAssets.css +
|
|
322
|
-
assets.head.js.map(_path => `<script src="${_path}"></script>`).join('') +
|
|
323
|
-
customAssets.js.head;
|
|
324
|
-
assetTags.body = assets.body.js.map(_path => `<script src="${_path}" data-manual></script>`).join('') +
|
|
325
|
-
customAssets.js.body;
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
assetTags.head = `
|
|
329
|
-
<style>${fs.readFileSync(modulePath + '/assets/compiled/head.css', 'utf8')}</style>
|
|
330
|
-
${customAssets.css}
|
|
331
|
-
<script>${fs.readFileSync(modulePath + '/assets/compiled/head.js', 'utf8')}</script>
|
|
332
|
-
${customAssets.js.head}
|
|
333
|
-
`;
|
|
334
|
-
assetTags.body = `<script>${fs.readFileSync(modulePath + '/assets/compiled/body.js', 'utf8')}</script>
|
|
335
|
-
${customAssets.js.body}`;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (spec.katex) {
|
|
339
|
-
const katexDist = findKatexDist();
|
|
340
|
-
assetTags.body += `<script>/* katex */${fs.readFileSync(path.join(katexDist, 'katex.min.js'),
|
|
341
|
-
'utf8')}</script>`;
|
|
342
|
-
assetTags.body += `<style>/* katex */${fs.readFileSync(path.join(katexDist, 'katex.min.css'),
|
|
343
|
-
'utf8')}</style>`;
|
|
344
|
-
|
|
345
|
-
fs.copySync(path.join(katexDist, 'fonts'), path.join(spec.destination, 'fonts'));
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
if (!options.nowatch) {
|
|
349
|
-
gulp.watch(
|
|
350
|
-
[spec.spec_directory + '**/*', '!' + path.join(spec.destination, 'index.html')],
|
|
351
|
-
render.bind(null, spec, assetTags)
|
|
352
|
-
)
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
render(spec, assetTags).then(() => {
|
|
356
|
-
if (options.nowatch) process.exit(0)
|
|
357
|
-
}).catch(() => process.exit(1));
|
|
358
|
-
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
catch (e) {
|
|
363
|
-
console.error(e);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
}
|