Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support mermaid diagrams with frontmatter directives #52

Merged

Conversation

johanhammar
Copy link

Support diagrams containing frontmatter directive. Might fix #48

Possibly a bit naive solution that seems to work, perhaps even the codeSplitByDirectiveStart block can be removed to with this fix?

@@ -15,7 +15,7 @@
*/

const mermaidStart =
/^(\s*)(graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|journey|gantt|pie|requirementDiagram|gitGraph|C4Context|C4Container|C4Component|C4Dynamic|C4Deployment|timeline)/;
/^(\s*)(graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|journey|gantt|pie|requirementDiagram|gitGraph|C4Context|C4Container|C4Component|C4Dynamic|C4Deployment|timeline)/gm;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@johanhammar
Copy link
Author

This fixes #46 as well. Do you want me to add a test for this as well?

it("mermaid code exists with comment", () => {
      const mermaidCode = `%% mermaid code with comment
graph LR
A-->B`;

      const result = isMermaidCode(mermaidCode);

      expect(result).toBe(true);
    });

@johanneswuerbach
Copy link
Owner

Do you want me to add a test for this as well?

I think it can't hurt as those quickly running unit tests. Thank you 🙇

@johanhammar
Copy link
Author

Anything else I can do to get this merged? 🤔

@johanneswuerbach johanneswuerbach merged commit 21d5b7f into johanneswuerbach:main Jun 28, 2024
1 check passed
@johanneswuerbach
Copy link
Owner

Thanks for the bump and contribution ❤️ , released as backstage-plugin-techdocs-addon-mermaid@0.12.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Titles in diagrams breaks rendering
2 participants