mddd-cli 4.1.0 → 4.1.1
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/bin/cli.js +1 -1
- package/package.json +1 -1
- package/src/commands/validator.js +18 -7
package/bin/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ const program = new Command();
|
|
|
17
17
|
program
|
|
18
18
|
.name('md')
|
|
19
19
|
.description('Manager for co-located specifications for Mermaid Diagram Driven Development (MDDD)')
|
|
20
|
-
.version('4.1.
|
|
20
|
+
.version('4.1.1');
|
|
21
21
|
|
|
22
22
|
// ==========================================
|
|
23
23
|
// COMMAND: md init
|
package/package.json
CHANGED
|
@@ -16,20 +16,25 @@ function extractMermaidBlocks(text) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Normaliza os espaços invisíveis, quebras de linha e remove comentários iniciais
|
|
20
20
|
* @param {string} code
|
|
21
21
|
* @returns {string}
|
|
22
22
|
*/
|
|
23
23
|
function cleanDiagramCode(code) {
|
|
24
|
-
//
|
|
25
|
-
|
|
24
|
+
// 1. Substitui espaços não-quebráveis (NBSP) por espaços normais
|
|
25
|
+
// 2. Remove possíveis retornos de carro (\r) de arquivos gerados no Windows
|
|
26
|
+
const normalizedCode = code
|
|
27
|
+
.replace(/\u00A0/g, ' ')
|
|
28
|
+
.replace(/\r/g, '');
|
|
29
|
+
|
|
30
|
+
const lines = normalizedCode.split('\n');
|
|
26
31
|
const cleanedLines = [];
|
|
27
32
|
let foundTypeDeclaration = false;
|
|
28
33
|
|
|
29
34
|
for (const line of lines) {
|
|
30
35
|
const trimmed = line.trim();
|
|
31
36
|
|
|
32
|
-
// Ignora linhas vazias ou comentários iniciais até achar a declaração do diagrama
|
|
37
|
+
// Ignora linhas vazias ou comentários iniciais até achar a declaração do tipo de diagrama
|
|
33
38
|
if (!foundTypeDeclaration && (trimmed === '' || trimmed.startsWith('%%'))) {
|
|
34
39
|
continue;
|
|
35
40
|
}
|
|
@@ -61,12 +66,18 @@ export async function validateMermaidSyntax(input) {
|
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
try {
|
|
69
|
+
const cleanedDiagrams = [];
|
|
70
|
+
|
|
64
71
|
for (const diagramCode of diagramsToValidate) {
|
|
65
|
-
// Aplica a limpeza antes de mandar para o parser em memória
|
|
66
72
|
const readyCode = cleanDiagramCode(diagramCode);
|
|
67
|
-
await parse(readyCode);
|
|
73
|
+
await parse(readyCode); // Se tiver espaço fantasma aqui, o parser agora aceita!
|
|
74
|
+
cleanedDiagrams.push(readyCode);
|
|
68
75
|
}
|
|
69
|
-
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
valid: true,
|
|
79
|
+
diagrams: cleanedDiagrams
|
|
80
|
+
};
|
|
70
81
|
} catch (error) {
|
|
71
82
|
return {
|
|
72
83
|
valid: false,
|