WIP: Adding support for more shapes

This commit is contained in:
Knut Sveidqvist
2025-04-28 13:24:55 +02:00
parent 7dd31dc7c9
commit 08048c39d7
3 changed files with 14 additions and 1 deletions

View File

@@ -67,6 +67,10 @@ terminal ROUNDED_STR_QUOTES: /\(\"([\s\S]*?)\"\)/;
terminal ROUNDED_STR: /\(([\s\S]*?)\)/; terminal ROUNDED_STR: /\(([\s\S]*?)\)/;
terminal SQUARE_STR_QUOTES: /\[\"([\s\S]*?)\"\]/; terminal SQUARE_STR_QUOTES: /\[\"([\s\S]*?)\"\]/;
terminal SQUARE_STR: /\[([\s\S]*?)\]/; terminal SQUARE_STR: /\[([\s\S]*?)\]/;
terminal BANG_STR_QUOTES: /\[\"([\s\S]*?)\"\]/;
terminal BANG_STR: /\[([\s\S]*?)\]/;
terminal CLOUD_STR_QUOTES: /\)\"([\s\S]*?)\"\(/;
terminal CLOUD_STR: /\)([\s\S]*?)\(/;
// terminal CIRCLE_STR: /(?!\(\()[\s\S]+?(?!\(\()/; // terminal CIRCLE_STR: /(?!\(\()[\s\S]+?(?!\(\()/;
terminal ID: /[a-zA-Z0-9_\-\.\/]+/; terminal ID: /[a-zA-Z0-9_\-\.\/]+/;
terminal STRING: /"[^"]*"|'[^']*'/; terminal STRING: /"[^"]*"|'[^']*'/;

View File

@@ -19,6 +19,14 @@ export class MindmapValueConverter extends AbstractMermaidValueConverter {
return input.replace('[', '').replace(']', '').trim(); return input.replace('[', '').replace(']', '').trim();
} else if (rule.name === 'SQUARE_STR_QUOTES') { } else if (rule.name === 'SQUARE_STR_QUOTES') {
return input.replace('["', '').replace('"]', '').trim(); return input.replace('["', '').replace('"]', '').trim();
} else if (rule.name === 'BANG_STR') {
return input.replace('))', '').replace('((', '').trim();
} else if (rule.name === 'BANG_STR_QUOTES') {
return input.replace('))"', '').replace('"((', '').trim();
} else if (rule.name === 'CLOUD_STR') {
return input.replace(')', '').replace('(', '').trim();
} else if (rule.name === 'CLOUD_STR_QUOTES') {
return input.replace(')"', '').replace('"(', '').trim();
} else if (rule.name === 'ARCH_TEXT_ICON') { } else if (rule.name === 'ARCH_TEXT_ICON') {
return input.replace(/["()]/g, ''); return input.replace(/["()]/g, '');
} else if (rule.name === 'ARCH_TITLE') { } else if (rule.name === 'ARCH_TITLE') {

View File

@@ -174,7 +174,7 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
expect(childNode.desc).toBe('child1'); expect(childNode.desc).toBe('child1');
}); });
it('MMP-9 should handle an id and type for a node definition', () => { it.only('MMP-9 should handle an id and type for a node definition', () => {
const result = parse('mindmap\nroot\n theId(child1)'); const result = parse('mindmap\nroot\n theId(child1)');
expect(result.lexerErrors).toHaveLength(0); expect(result.lexerErrors).toHaveLength(0);
expect(result.parserErrors).toHaveLength(0); expect(result.parserErrors).toHaveLength(0);
@@ -196,6 +196,7 @@ describe('Nodes (ported from mindmap.spec.ts)', () => {
it('MMP-11 multiple types (cloud)', () => { it('MMP-11 multiple types (cloud)', () => {
const result = parse('mindmap\nroot)the root('); const result = parse('mindmap\nroot)the root(');
console.debug('RESULT:', result.parserErrors);
expect(result.lexerErrors).toHaveLength(0); expect(result.lexerErrors).toHaveLength(0);
expect(result.parserErrors).toHaveLength(0); expect(result.parserErrors).toHaveLength(0);
const rootNode = result.value.MindmapRows[0].item as OtherComplex; const rootNode = result.value.MindmapRows[0].item as OtherComplex;