spec-up-t 1.1.45 → 1.1.46

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.
@@ -12,7 +12,7 @@ dl>dd:has(table).meta-info-content-wrapper{max-height:10em;transition:max-height
12
12
  .spec-up-t-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}.spec-up-t-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)}.spec-up-t-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:30px;line-height:30px;margin:2px;text-align:center;text-decoration:none;width:30px}
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)}
15
- h2,h3,h4,h5,h6{margin-top:1.5em!important}.toc-anchor{font-size:.875em;color:inherit;text-decoration:none;color:#73c2df;transition:opacity .3s ease}.toc-anchor:hover{opacity:1}#terminology-section-utility-container{display:flex;flex-wrap:wrap;justify-content:center;margin:1em auto;padding:0;width:100%}@media (min-width:576px){#terminology-section-utility-container{position:sticky;top:3.5em}}.transcluded-xref-term{background:#a9dde03b!important;padding:.5em;margin:1em 0}.transclusion-heading{font-size:1.3em;font-weight:700;margin:1em 0 .5em}dl.terms-and-definitions-list>dd.transcluded-xref-term-embedded{background-image:linear-gradient(45deg,hsl(190deg 60% 95%) 0,hsl(189deg 60% 93%) 8%,hsl(189deg 60% 91%) 17%,hsl(188deg 60% 89%) 25%,hsl(188deg 60% 87%) 33%,hsl(187deg 60% 85%) 42%,hsl(186deg 60% 83%) 50%,hsl(190deg 60% 83%) 58%,hsl(193deg 60% 83%) 67%,hsl(197deg 60% 83%) 75%,hsl(202deg 60% 83%) 83%,hsl(207deg 60% 83%) 92%,hsl(212deg 60% 83%) 100%)!important}.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}dl.terms-and-definitions-list{margin:0;padding:0}dl.terms-and-definitions-list>dt{font-weight:700;margin:0;background-color:var(--card-bg-dt);border:1px solid var(--card-border);padding:.1rem 1.25rem;border-radius:.375rem .375rem 0 0;box-shadow:0 .125rem .25rem var(--card-shadow);color:var(--card-text)}dl.terms-and-definitions-list>dd{margin:0;background-color:var(--card-bg);border:1px solid var(--card-border);border-top:none;padding:1rem 1.25rem;color:var(--card-text);overflow:scroll;width:100%}dl.terms-and-definitions-list dd p{margin:0;color:var(--card-text)}dl.terms-and-definitions-list dt+dd{border-bottom:none}dl.terms-and-definitions-list dd+dd{border-top:none;border-bottom:none}dl.terms-and-definitions-list dd+dt{margin-top:1.5rem}dl.terms-and-definitions-list dd.last-dd{border-radius:0 0 .375rem .375rem;border-bottom:1px solid var(--card-border)}dl.terms-and-definitions-list>dt:hover{background-color:var(--card-hover-bg);transition:background-color .2s ease-in-out}
15
+ h2,h3,h4,h5,h6{margin-top:1.5em!important}.toc-anchor{font-size:.875em;color:inherit;text-decoration:none;color:#73c2df;transition:opacity .3s ease}.toc-anchor:hover{opacity:1}#terminology-section-utility-container{display:flex;flex-wrap:wrap;justify-content:center;margin:1em auto;padding:0;width:100%}@media (min-width:576px){#terminology-section-utility-container{position:sticky;top:3.5em}}.transcluded-xref-term{background:#a9dde03b!important;padding:.5em;margin:1em 0}.transclusion-heading{font-size:1.3em;font-weight:700;margin:1em 0 .5em}dl.terms-and-definitions-list>dd.transcluded-xref-term-embedded{background-image:linear-gradient(45deg,hsl(190deg 60% 95%) 0,hsl(189deg 60% 93%) 8%,hsl(189deg 60% 91%) 17%,hsl(188deg 60% 89%) 25%,hsl(188deg 60% 87%) 33%,hsl(187deg 60% 85%) 42%,hsl(186deg 60% 83%) 50%,hsl(190deg 60% 83%) 58%,hsl(193deg 60% 83%) 67%,hsl(197deg 60% 83%) 75%,hsl(202deg 60% 83%) 83%,hsl(207deg 60% 83%) 92%,hsl(212deg 60% 83%) 100%)!important}.placeholder-tref{display:none}.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}dl.terms-and-definitions-list{margin:0;padding:0}dl.terms-and-definitions-list>dt{font-weight:700;margin:0;background-color:var(--card-bg-dt);border:1px solid var(--card-border);padding:.1rem 1.25rem;border-radius:.375rem .375rem 0 0;box-shadow:0 .125rem .25rem var(--card-shadow);color:var(--card-text)}dl.terms-and-definitions-list>dd{margin:0;background-color:var(--card-bg);border:1px solid var(--card-border);border-top:none;padding:1rem 1.25rem;color:var(--card-text);overflow:scroll;width:100%}dl.terms-and-definitions-list dd p{margin:0;color:var(--card-text)}dl.terms-and-definitions-list dt+dd{border-bottom:none}dl.terms-and-definitions-list dd+dd{border-top:none;border-bottom:none}dl.terms-and-definitions-list dd+dt{margin-top:1.5rem}dl.terms-and-definitions-list dd.last-dd{border-radius:0 0 .375rem .375rem;border-bottom:1px solid var(--card-border)}dl.terms-and-definitions-list>dt:hover{background-color:var(--card-hover-bg);transition:background-color .2s ease-in-out}
16
16
  @charset "UTF-8";/*!
17
17
  * Bootstrap v5.3.3 (https://getbootstrap.com/)
18
18
  * Copyright 2011-2024 The Bootstrap Authors
@@ -71,6 +71,9 @@ dl.terms-and-definitions-list>dd.transcluded-xref-term-embedded {
71
71
 
72
72
  }
73
73
 
74
+ .placeholder-tref {
75
+ display: none;
76
+ }
74
77
 
75
78
  /* End Transclusions */
76
79
 
package/index.js CHANGED
@@ -49,10 +49,16 @@ module.exports = async function (options = {}) {
49
49
  const replacers = [
50
50
  {
51
51
  test: 'insert',
52
- transform: function (path) {
52
+ transform: function (originalMatch, type, path) {
53
53
  if (!path) return '';
54
54
  return fs.readFileSync(path, 'utf8');
55
55
  }
56
+ },
57
+ {
58
+ test: 'tref',
59
+ transform: function (originalMatch, type, spec, term) {
60
+ return `${originalMatch}\n: <span class="placeholder-tref">No custom content found for ${spec}:${term}</span> { .placeholder-dd }\n`;
61
+ }
56
62
  }
57
63
  ];
58
64
 
@@ -78,10 +84,13 @@ module.exports = async function (options = {}) {
78
84
  function applyReplacers(doc) {
79
85
  return doc.replace(replacerRegex, function (match, type, args) {
80
86
  let replacer = replacers.find(r => type.trim().match(r.test));
81
- return replacer ? replacer.transform(...args.trim().split(replacerArgsRegex)) : match;
87
+ if (replacer) {
88
+ let argsArray = args ? args.trim().split(replacerArgsRegex) : [];
89
+ return replacer.transform(match, type, ...argsArray);
90
+ }
91
+ return match;
82
92
  });
83
93
  }
84
-
85
94
  function normalizePath(path) {
86
95
  return path.trim().replace(/\/$/g, '') + '/';
87
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.1.45",
3
+ "version": "1.1.46",
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": {
@@ -1,3 +1,24 @@
1
+ /**
2
+ * @file prepare-tref.js
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.
18
+ *
19
+ * @module prepareTref
20
+ */
21
+
1
22
  const fs = require('fs');
2
23
  const path = require('path');
3
24
  const dedent = require('dedent');
@@ -47,8 +68,7 @@ function prepareTref(directory) {
47
68
 
48
69
  // Variable to store content after the span or tref line
49
70
  let contentAfterSpan = '';
50
-
51
- const spanMarker = '- - -';
71
+ const spanMarker = '<span style="display: none;">End of included external content. Add your optional custom content below.</span>';
52
72
  const spanIndex = data.indexOf(spanMarker);
53
73
 
54
74
  if (spanIndex !== -1) {
@@ -81,9 +101,16 @@ function prepareTref(directory) {
81
101
 
82
102
  const readyForWrite = dedent`
83
103
  ${match[0]}
104
+ | Property | Value |
105
+ | -------- | ----- |
106
+ | Owner | ![avatar](${localXTrefContent.avatarUrl}) ${localXTrefContent.owner} |
107
+ | Repo | [${localXTrefContent.repo}](${localXTrefContent.repoUrl}) |
108
+ | Commit hash | ${localXTrefContent.commitHash} |
84
109
 
110
+ ${localXTrefContent.content}
85
111
  ${spanMarker}
86
112
 
113
+ ${contentAfterSpan}
87
114
 
88
115
  `;
89
116