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: Detector order #4124

Merged
merged 5 commits into from
Feb 28, 2023
Merged

fix: Detector order #4124

merged 5 commits into from
Feb 28, 2023

Conversation

sidharthv96
Copy link
Member

@sidharthv96 sidharthv96 commented Feb 21, 2023

📑 Summary

Rearrange detectors so that diagrams are properly detected.

Resolves flowchart-elk not being detected

📏 Design Decisions

Diagrams with more specific detectors should come on top of the list.

eg, when matching flowchart-elk from diagram text, if flowchart detector is checked before flowchart-elk's detector, the diagram would incorrectly be detected as flowchart.

So, we need to check flowchart-elk first. Same case with -v2 diagrams.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added unit/e2e tests (if appropriate)
  • 📓 have added documentation (if appropriate)
  • 🔖 targeted develop branch

@sidharthv96 sidharthv96 self-assigned this Feb 21, 2023
Copy link
Member

@aloisklink aloisklink left a comment

Choose a reason for hiding this comment

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

I'm not super experienced with the whole registerLazyLoadedDiagrams code, but so far, it looks good to me!

By the way, is it also worth making the detectors for flowchart and stateDiagram stricter (maybe all other diagrams too)?

E.g. checking for /flowchart\s/ (must end with a white-space character)

I'm guessing that:

```mermaid
stateDiagram-blah-blah-blah
    [*] --> Still
    Still --> [*]

    Still --> Moving
    Moving --> Still
    Moving --> Crash
    Crash --> [*]
```

should probably throw a unrecognized diagram error, instead of the current error.

After all, somebody might make a custom flowchart-v100 diagram type as a plugin, and I believe that then their external usage of registerLazyLoadedDiagrams() would be called after we've already called registerLazyLoadedDiagrams() internally.

@sidharthv96 sidharthv96 added this to the 10.0.1 milestone Feb 24, 2023
sidharthv96 and others added 3 commits February 24, 2023 17:27
* develop:
  Update docs
  fix Lint
  Update CHANGELOG.md
  Update CHANGELOG.md
  fix: fix exports
  Doc (typo): remove duplicate "be"
  Fix readme link
  Regenerate mermaid docs
  Add deepdwn to cspell
  Add Deepdwn to native integrations list
@sidharthv96
Copy link
Member Author

By the way, is it also worth making the detectors for flowchart and stateDiagram stricter (maybe all other diagrams too)?

Making it stricter now might break many existing diagrams. So I'd prefer we don't mess with that.

@aloisklink
Copy link
Member

aloisklink commented Feb 25, 2023

Making it stricter now might break many existing diagrams.

It won't for the stateDiagram diagrams at least, since right now, trying to render a diagram that starts with stateDiagram-blah-blah-blah means that the stateDiagram jison parser throws an error, so it's not too big of a deal if we change it to a no diagrams detected error.

It's probably something that's low priority, so it shouldn't go in this PR.

Copy link

@MermaidChart MermaidChart left a comment

Choose a reason for hiding this comment

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

Look great, thanks @sidharthv96 !

@knsv knsv merged commit 1b56071 into develop Feb 28, 2023
@Yokozuna59 Yokozuna59 deleted the sidv/fixDetectorOrder branch August 11, 2023 19:59
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.

4 participants