spec-up-t 1.2.2 → 1.2.4

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.
Files changed (49) hide show
  1. package/.sonarlint/connectedMode.json +5 -0
  2. package/assets/compiled/body.js +31 -31
  3. package/assets/compiled/head.css +5 -5
  4. package/assets/compiled/head.js +3 -3
  5. package/assets/css/adjust-font-size.css +6 -11
  6. package/assets/css/backToTop.css +0 -1
  7. package/assets/css/index.css +1 -2
  8. package/assets/css/pdf-styles.css +23 -27
  9. package/assets/css/repo-issues.css +0 -6
  10. package/assets/css/search.css +0 -1
  11. package/assets/css/sidebar-toc.css +13 -12
  12. package/assets/css/terms-and-definitions.css +43 -37
  13. package/assets/js/add-href-to-snapshot-link.js +2 -1
  14. package/assets/js/addAnchorsToTerms.js +0 -1
  15. package/assets/js/adjust-font-size.js +0 -9
  16. package/assets/js/create-alphabet-index.js +1 -1
  17. package/assets/js/custom-elements.js +13 -18
  18. package/assets/js/declare-markdown-it.js +1 -1
  19. package/assets/js/highlightMenuItems.js +3 -3
  20. package/assets/js/index.js +1 -5
  21. package/assets/js/insert-trefs.js +2 -2
  22. package/assets/js/modal.js +3 -3
  23. package/assets/js/search.js +3 -3
  24. package/assets/js/utils.js +2 -3
  25. package/index.js +5 -15
  26. package/package.json +2 -2
  27. package/src/add-remove-xref-source.js +0 -2
  28. package/src/collect-external-references.js +187 -179
  29. package/src/collectExternalReferences/fetchTermsFromIndex.js +2 -1
  30. package/src/create-external-specs-list.js +1 -1
  31. package/src/fix-markdown-files.js +152 -90
  32. package/src/health-check/external-specs-checker.js +173 -94
  33. package/src/health-check/output-gitignore-checker.js +327 -191
  34. package/src/health-check/specs-configuration-checker.js +288 -210
  35. package/src/health-check/term-references-checker.js +200 -123
  36. package/src/health-check/tref-term-checker.js +264 -179
  37. package/src/health-check.js +51 -35
  38. package/src/init.js +0 -3
  39. package/src/install-from-boilerplate/boilerplate/gitignore +2 -1
  40. package/src/install-from-boilerplate/config-system-files.js +9 -1
  41. package/src/install-from-boilerplate/copy-system-files.js +1 -1
  42. package/src/install-from-boilerplate/menu.sh +17 -3
  43. package/src/markdown-it-extensions.js +199 -106
  44. package/src/references.js +1 -2
  45. package/src/utils/doesUrlExist.js +7 -5
  46. package/templates/template.html +1 -2
  47. package/assets/js/insert-xrefs.js +0 -370
  48. package/src/create-term-relations.js +0 -131
  49. package/src/prepare-tref.js +0 -174
@@ -24,17 +24,16 @@ customElements.define('slide-panels', class SidePanels extends HTMLElement {
24
24
  close (){
25
25
  this.removeAttribute('open');
26
26
  }
27
+
27
28
  attributeChangedCallback(attr, last, current) {
28
- switch(attr) {
29
- case 'open': for (let child of this.children) {
29
+ if (attr === 'open') {
30
+ for (let child of this.children) {
30
31
  if (child.id === current) child.setAttribute('open', '');
31
32
  else child.removeAttribute('open', '');
32
33
  }
33
- break;
34
34
  }
35
35
  }
36
36
  });
37
-
38
37
  customElements.define('detail-box', class DetailBox extends HTMLElement {
39
38
  static get observedAttributes() {
40
39
  return ['open'];
@@ -60,23 +59,19 @@ customElements.define('detail-box', class DetailBox extends HTMLElement {
60
59
  this.toggleAttribute('open');
61
60
  }
62
61
  attributeChangedCallback(attr, last, current) {
63
- switch(attr) {
64
- case 'open':
65
- for (let node of this.children) {
66
- if (node.tagName === 'SECTION') {
67
- if (current !== null) {
68
- if (node.offsetHeight < node.scrollHeight) {
69
- node.style.height = node.scrollHeight + 'px';
70
- }
62
+ if (attr === 'open') {
63
+ for (let node of this.children) {
64
+ if (node.tagName === 'SECTION') {
65
+ if (current !== null) {
66
+ if (node.offsetHeight < node.scrollHeight) {
67
+ node.style.height = node.scrollHeight + 'px';
71
68
  }
72
- else if (node.offsetHeight > 0) {
73
- node.style.height = node.offsetHeight + 'px';
74
- let scroll = this.scrollHeight;
75
- node.style.height = 0;
76
- }
77
- break;
69
+ } else if (node.offsetHeight > 0) {
70
+ node.style.height = node.offsetHeight + 'px';
71
+ node.style.height = 0;
78
72
  }
79
73
  }
74
+ }
80
75
  }
81
76
  }
82
77
  });
@@ -1,5 +1,5 @@
1
1
 
2
- var md = window.markdownit({
2
+ const md = window.markdownit({
3
3
  html: true, // Allow raw HTML in Markdown
4
4
  linkify: true, // Automatically convert URLs to clickable links
5
5
  typographer: true // Enable smart quotes and other typographic enhancements
@@ -18,7 +18,7 @@ function highlightMenuItems() {
18
18
  if (menuItem) {
19
19
  menuItem.classList.add("highlight-cfib41dyhcd99sm");
20
20
  menuItem.scrollIntoView({ behavior: "smooth", block: "center" });
21
-
21
+
22
22
  // Dispatch custom event for the collapsible menu to handle
23
23
  document.dispatchEvent(new CustomEvent('highlight-menu-item', {
24
24
  detail: { menuItem, headingId: heading.id }
@@ -40,10 +40,10 @@ function highlightMenuItems() {
40
40
  // Update last heading in view to the first one found in the current viewport
41
41
  lastHeadingInView = headingsInView[0];
42
42
  highlightMenuItem(lastHeadingInView);
43
- } else {
43
+ } else if (lastHeadingInView) {
44
44
  // No headings are currently in view
45
45
  // Highlight the last heading in view if it exists
46
- if (lastHeadingInView) highlightMenuItem(lastHeadingInView);
46
+ highlightMenuItem(lastHeadingInView);
47
47
  }
48
48
  }, options);
49
49
 
@@ -1,9 +1,6 @@
1
1
 
2
2
  (function(){
3
3
 
4
- var markdown = window.markdownit();
5
-
6
-
7
4
  /* GitHub Issues */
8
5
 
9
6
  let source = specConfig.source;
@@ -19,7 +16,7 @@ var markdown = window.markdownit();
19
16
  repo_issue_list.innerHTML = issues.map(issue => {
20
17
  return `<li class="repo-issue">
21
18
  <detail-box>
22
- <section>${markdown.render(issue.body || '')}</section>
19
+ <section>${md.render(issue.body || '')}</section>
23
20
  <header class="repo-issue-title">
24
21
  <span class="repo-issue-number">${issue.number}</span>
25
22
  <span class="repo-issue-link">
@@ -34,7 +31,6 @@ var markdown = window.markdownit();
34
31
  })
35
32
  }
36
33
  }
37
- //${markdown.render(issue.body)}
38
34
 
39
35
  /* Mermaid Diagrams */
40
36
 
@@ -41,7 +41,7 @@ function insertTrefs(allXTrefs) { // Pass allXTrefs as a parameter
41
41
  const dt = termElement.closest('dt');
42
42
  if (dt) {
43
43
  const nextElement = dt.nextElementSibling;
44
- if (nextElement && nextElement.classList.contains('transcluded-xref-term') &&
44
+ if (nextElement?.classList.contains('transcluded-xref-term') &&
45
45
  nextElement.classList.contains('meta-info-content-wrapper')) {
46
46
  return; // Already processed
47
47
  }
@@ -134,7 +134,7 @@ function insertTrefs(allXTrefs) { // Pass allXTrefs as a parameter
134
134
  }
135
135
 
136
136
 
137
- if (allXTrefs && allXTrefs.xtrefs) {
137
+ if (allXTrefs?.xtrefs) {
138
138
  processTerms(allXTrefs);
139
139
  } else {
140
140
  console.error('allXTrefs is undefined or missing xtrefs property');
@@ -2,6 +2,9 @@
2
2
  * Displays a modal with the given content.
3
3
  *
4
4
  * @param {string} content - The HTML content to display inside the modal.
5
+ *
6
+ * Example usage:
7
+ * showModal('<h2>This is a Modal</h2><p>You can put any content here.</p>');
5
8
  */
6
9
  function showModal(content) {
7
10
  // Create the modal overlay
@@ -47,6 +50,3 @@ function showModal(content) {
47
50
  }
48
51
  }, { once: true });
49
52
  }
50
-
51
- // // Example usage:
52
- // showModal('<h2>This is a Modal</h2><p>You can put any content here.</p>');
@@ -295,9 +295,9 @@ function inPageSearch() {
295
295
  */
296
296
  function hasHiddenAncestor(node) {
297
297
  while (node) {
298
- if (node.classList && node.classList.contains('hidden')) {
299
- return true;
300
- }
298
+ if (node?.classList?.contains('hidden')) {
299
+ return true;
300
+ }
301
301
  node = node.parentNode;
302
302
  }
303
303
  return false;
@@ -1,4 +1,3 @@
1
-
2
1
  function delegateEvent(type, selector, fn, options = {}){
3
2
  return (options.container || document).addEventListener(type, e => {
4
3
  let match = e.target.closest(selector);
@@ -6,8 +5,8 @@ function delegateEvent(type, selector, fn, options = {}){
6
5
  }, options);
7
6
  }
8
7
 
9
- skipAnimationFrame = fn => requestAnimationFrame(() => requestAnimationFrame(fn));
8
+ const skipAnimationFrame = fn => requestAnimationFrame(() => requestAnimationFrame(fn));
10
9
 
11
- var domReady = new Promise(resolve => {
10
+ const domReady = new Promise(resolve => {
12
11
  document.addEventListener('DOMContentLoaded', e => resolve())
13
12
  });
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const { initialize } = require('./src/init');
2
- const {fetchExternalTerms} = require('./src/utils/fetch');
3
2
 
4
3
  module.exports = async function (options = {}) {
5
4
  try {
@@ -18,9 +17,6 @@ module.exports = async function (options = {}) {
18
17
  const { runJsonKeyValidatorSync } = require('./src/json-key-validator.js');
19
18
  runJsonKeyValidatorSync();
20
19
 
21
- // const { createTermRelations } = require('./src/create-term-relations.js');
22
- // createTermRelations();
23
-
24
20
  const { createTermIndex } = require('./src/create-term-index.js');
25
21
  createTermIndex();
26
22
 
@@ -31,8 +27,6 @@ module.exports = async function (options = {}) {
31
27
  const modulePath = findPkgDir(__dirname);
32
28
  let config = fs.readJsonSync('./output/specs-generated.json');
33
29
 
34
- const externalTerms = fetchExternalTerms();
35
-
36
30
  const createExternalSpecsList = require('./src/create-external-specs-list.js');
37
31
 
38
32
  const externalSpecsList = createExternalSpecsList(config);
@@ -42,16 +36,14 @@ module.exports = async function (options = {}) {
42
36
 
43
37
  const { fixMarkdownFiles } = require('./src/fix-markdown-files.js');
44
38
 
45
- // const { prepareTref } = require('./src/prepare-tref.js');
46
-
47
39
  let template = fs.readFileSync(path.join(modulePath, 'templates/template.html'), 'utf8');
48
40
  let assets = fs.readJsonSync(modulePath + '/src/asset-map.json');
49
41
  let externalReferences;
50
42
  let references = [];
51
43
  let definitions = [];
52
- var toc;
53
- var specGroups = {};
54
- var noticeTitles = {};
44
+ let toc;
45
+ let specGroups = {};
46
+ let noticeTitles = {};
55
47
 
56
48
  const noticeTypes = {
57
49
  note: 1,
@@ -61,7 +53,7 @@ module.exports = async function (options = {}) {
61
53
  todo: 1
62
54
  };
63
55
  const spaceRegex = /\s+/g;
64
- const specNameRegex = /^spec$|^spec[-]*\w+$/i;
56
+ const specNameRegex = /^spec$|^spec-*\w+$/i;
65
57
  const terminologyRegex = /^def$|^ref$|^xref|^tref$/i;
66
58
  const specCorpus = fs.readJsonSync(modulePath + '/assets/compiled/refs.json');
67
59
  const containers = require('markdown-it-container');
@@ -221,8 +213,6 @@ module.exports = async function (options = {}) {
221
213
  }
222
214
  ];
223
215
 
224
- // prepareTref(path.join(config.specs[0].spec_directory, config.specs[0].spec_terms_directory));
225
-
226
216
  // Synchronously process markdown files
227
217
  fixMarkdownFiles(path.join(config.specs[0].spec_directory, config.specs[0].spec_terms_directory));
228
218
 
@@ -397,7 +387,7 @@ module.exports = async function (options = {}) {
397
387
 
398
388
  // Then filter to find the one with the terms-and-definitions-list class
399
389
  const dlElements = allDls.filter(dl => {
400
- return dl.classList && dl.classList.contains('terms-and-definitions-list');
390
+ return dl?.classList?.contains('terms-and-definitions-list');
401
391
  });
402
392
 
403
393
  // Find any transcluded term dt elements anywhere in the document
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
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": {
@@ -34,7 +34,7 @@
34
34
  "gulp": "4.0.2",
35
35
  "gulp-clean-css": "4.3.0",
36
36
  "gulp-concat": "2.6.1",
37
- "gulp-terser": "1.2.0",
37
+ "gulp-terser": "^2.1.0",
38
38
  "jsdom": "^25.0.0",
39
39
  "markdown-it": "^13.0.1",
40
40
  "markdown-it-anchor": "^9.2.0",
@@ -125,7 +125,6 @@ function updateJSON() {
125
125
  externalSpecs.push(inputs);
126
126
 
127
127
  fs.writeFileSync(JSON_FILE, JSON.stringify(data, null, 2), 'utf8');
128
- // console.log(`Updated ${JSON_FILE} successfully.`);
129
128
  console.log(`Updated successfully.`);
130
129
  } catch (error) {
131
130
  console.error(`Error: Failed to update ${JSON_FILE}.`, error.message);
@@ -159,7 +158,6 @@ function removeEntry(externalSpec) {
159
158
  data.specs[0].external_specs = filteredSpecs;
160
159
 
161
160
  fs.writeFileSync(JSON_FILE, JSON.stringify(data, null, 2), 'utf8');
162
- // console.log(`Removed entry with external_spec "${externalSpec}" successfully.`);
163
161
  console.log(`Removed entry successfully.`);
164
162
  } catch (error) {
165
163
  console.error(`Error: Failed to update ${JSON_FILE}.`, error.message);