mddd-cli 4.1.1 → 4.1.2
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 +15 -10
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.2');
|
|
21
21
|
|
|
22
22
|
// ==========================================
|
|
23
23
|
// COMMAND: md init
|
package/package.json
CHANGED
|
@@ -16,31 +16,36 @@ function extractMermaidBlocks(text) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Normaliza
|
|
19
|
+
* Normaliza quebras de linha, remove TODOS os tipos de espaços Unicode fantasmas
|
|
20
|
+
* e elimina comentários/linhas vazias do topo antes do tipo de diagrama.
|
|
20
21
|
* @param {string} code
|
|
21
22
|
* @returns {string}
|
|
22
23
|
*/
|
|
23
24
|
function cleanDiagramCode(code) {
|
|
24
|
-
// 1.
|
|
25
|
-
|
|
26
|
-
const normalizedCode = code
|
|
27
|
-
.replace(/\u00A0/g, ' ')
|
|
28
|
-
.replace(/\r/g, '');
|
|
25
|
+
// 1. Unifica todas as quebras de linha possíveis (\r\n ou \r isolado) para \n
|
|
26
|
+
const uniformLines = code.replace(/\r\n|\r/g, '\n');
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
// 2. Divide em linhas para processar o topo do arquivo
|
|
29
|
+
const lines = uniformLines.split('\n');
|
|
31
30
|
const cleanedLines = [];
|
|
32
31
|
let foundTypeDeclaration = false;
|
|
33
32
|
|
|
34
33
|
for (const line of lines) {
|
|
35
|
-
|
|
34
|
+
// Substitui todos os tipos conhecidos de espaços em branco Unicode invisíveis por espaços comuns
|
|
35
|
+
// (\u00A0 é o NBSP, \u2000-\u200A são variantes de espaçamento tipográfico)
|
|
36
|
+
let normalizedLine = line.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g, ' ');
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
const trimmed = normalizedLine.trim();
|
|
39
|
+
|
|
40
|
+
// Ignora linhas vazias ou comentários iniciais até achar a declaração do diagrama
|
|
38
41
|
if (!foundTypeDeclaration && (trimmed === '' || trimmed.startsWith('%%'))) {
|
|
39
42
|
continue;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
foundTypeDeclaration = true;
|
|
43
|
-
|
|
46
|
+
|
|
47
|
+
// Mantém a linha com os espaços normais restaurados (importante para a indentação dos blocos do Mermaid)
|
|
48
|
+
cleanedLines.push(normalizedLine);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
return cleanedLines.join('\n').trim();
|