spec-up-t 1.0.59 → 1.0.61
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/package.json +1 -1
- package/src/fix-markdown-files.js +30 -23
- package/src/get-xrefs-data.js +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-up-t",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.61",
|
|
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": {
|
|
@@ -24,47 +24,54 @@ function processMarkdownFiles(directory) {
|
|
|
24
24
|
let lines = data.split('\n');
|
|
25
25
|
let modified = false;
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// Handle specific functionality for `[[def:` lines
|
|
28
28
|
for (let i = 0; i < lines.length; i++) {
|
|
29
|
-
// Check if the line starts with [[def:
|
|
30
29
|
if (lines[i].startsWith('[[def:')) {
|
|
31
|
-
//
|
|
30
|
+
// Ensure a blank line immediately follows `[[def:` lines
|
|
32
31
|
if (i + 1 < lines.length && lines[i + 1].trim() !== '') {
|
|
33
|
-
// Insert
|
|
34
|
-
lines.splice(i + 1, 0, '');
|
|
32
|
+
lines.splice(i + 1, 0, ''); // Insert blank line
|
|
35
33
|
modified = true;
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
// Ensure there is
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
lines.splice(i + 1, 0, '');
|
|
44
|
-
modified = true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
38
|
+
// Ensure there is exactly one blank line between paragraphs
|
|
39
|
+
let newLines = [];
|
|
40
|
+
let previousLineWasEmpty = false;
|
|
47
41
|
|
|
48
|
-
// Prepend `~ ` to lines that do not start with `[[def:` and are not blank lines, and do not already start with `~ `
|
|
49
42
|
for (let i = 0; i < lines.length; i++) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
const isCurrentLineEmpty = lines[i].trim() === '';
|
|
44
|
+
|
|
45
|
+
if (!isCurrentLineEmpty) {
|
|
46
|
+
newLines.push(lines[i]); // Add non-empty lines
|
|
47
|
+
previousLineWasEmpty = false;
|
|
48
|
+
} else if (!previousLineWasEmpty) {
|
|
49
|
+
newLines.push(''); // Add exactly one blank line
|
|
50
|
+
previousLineWasEmpty = true;
|
|
51
|
+
} else {
|
|
52
|
+
modified = true; // Skip additional blank lines
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
// Prepend `~ ` to lines that do not start with `[[def:` and are not blank, and do not already start with `~ `
|
|
57
|
+
for (let i = 0; i < newLines.length; i++) {
|
|
58
|
+
if (!newLines[i].startsWith('[[def:') && newLines[i].trim() !== '' && !newLines[i].startsWith('~ ')) {
|
|
59
|
+
newLines[i] = `~ ${newLines[i]}`;
|
|
60
|
+
modified = true;
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
// Ensure there is exactly one blank line at the end of the file
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
data = trimmedData;
|
|
65
|
+
if (newLines[newLines.length - 1] !== '') {
|
|
66
|
+
newLines.push('');
|
|
65
67
|
modified = true;
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
// Join the lines back into a single string
|
|
71
|
+
if (modified) {
|
|
72
|
+
data = newLines.join('\n');
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
// Write the modified content back to the file synchronously if there were any changes
|
|
69
76
|
if (modified) {
|
|
70
77
|
fs.writeFileSync(itemPath, data, 'utf8');
|
|
@@ -86,4 +93,4 @@ function processMarkdownFiles(directory) {
|
|
|
86
93
|
|
|
87
94
|
module.exports = {
|
|
88
95
|
processMarkdownFiles
|
|
89
|
-
};
|
|
96
|
+
};
|
package/src/get-xrefs-data.js
CHANGED
|
@@ -205,6 +205,7 @@ function getXrefsData(GITHUB_API_TOKEN) {
|
|
|
205
205
|
fs.writeFileSync(outputPathJS, stringReadyForFileWrite, 'utf8');
|
|
206
206
|
fs.writeFileSync(outputPathJSTimeStamped, stringReadyForFileWrite, 'utf8');
|
|
207
207
|
});
|
|
208
|
+
require('../index.js')({ nowatch: true });
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
// Function to remove a specific xref from the JSON file, based on term and externalSpec.
|
|
@@ -245,7 +246,10 @@ function removeXref(term, externalSpec) {
|
|
|
245
246
|
messages.push(`\n SPEC-UP-T: An error occurred - ${error.message}\n`);
|
|
246
247
|
}
|
|
247
248
|
|
|
249
|
+
require('../index.js')({ nowatch: true });
|
|
250
|
+
|
|
248
251
|
// TODO: messages are not used at the moment, since they apparently are not returned to the calling script. Fix this.
|
|
252
|
+
|
|
249
253
|
return messages;
|
|
250
254
|
}
|
|
251
255
|
|