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

flowchart doesn't support double percetage (%%) comment syntax between attribute blocks #4137

Closed
alexeyval opened this issue Feb 23, 2023 · 3 comments · Fixed by #4247 or #4257
Closed
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@alexeyval
Copy link

alexeyval commented Feb 23, 2023

Description

When attempting to use the double percentage sign comment syntax (%%) between attribute blocks of flowchart, the following error is thrown:

Error: Parse error on line 3:
... A --> %%B --> C --> .[ en
----------------------^
Expecting 'AMP', 'ALPHA', 'COLON', 'PIPE', 'TESTSTR', 'DOWN', 'DEFAULT', 'NUM', 'COMMA', 'MINUS', 'BRKT', 'DOT', 'PUNCTUATION', 'UNICODE_TEXT', 'PLUS', 'EQUALS', 'MULT', 'UNDERSCORE', got 'NEWLINE'

Steps to reproduce

  1. Create a new flowchart mermaid document.
  2. Use double percentage comment syntax between attribute blocks.
  3. Owl done.

Screenshots

Screenshot from 2023-02-23 17-51-46
Screenshot from 2023-02-23 17-54-10
Screenshot from 2023-02-23 17-55-26

Code Sample

OK:
flowchart LR
    %%B -->
    A --> 
    C -->
    .[ end ]

FAIL:
flowchart LR
    A --> 
    %%B -->
    C -->
    .[ end ]

Setup

Desktop

  • OS and Version: Linux
  • Browser and Version: Chrome

Additional Context

The error doesn't occur when commenting at the beginning and at the end.
I have to move comments to the beginning or to the end each time for this to work.
Is there a way to ignore comments in the middle?

@alexeyval alexeyval added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Feb 23, 2023
@sidharthv96
Copy link
Member

Related #4128

@kshitijsaksena
Copy link
Contributor

@sidharthv96 I see that the comment syntax breaks a lot of charts. I have 2 suggestions on this we can discuss on which to go for:

  • Review all charts grammar for comment sytnax.
  • Create docs for correct usage of comments in charts so we can specify how comments should be without breaking the chart.

@sidharthv96
Copy link
Member

sidharthv96 commented Feb 28, 2023

Or, we could strip out the comments using regex before rendering the diagram, just like how we remove frontmatter.
We just have to make sure the init directives aren't removed.

knsv added a commit that referenced this issue Mar 31, 2023
fix(#4137): Cleanup comments before parsing
sidharthv96 added a commit that referenced this issue Apr 5, 2023
* develop: (81 commits)
  revert pnpm changes
  doc update
  auto generated from pnpm run
  auto generated from pnpm run
  linting
  added example of Bar chart
  Update docs
  Adding rendering tests and unit tests
  Syntax for markdown strings is a single backtick.
  updated labels in the chart
  Update docs
  updated example data smaller
  Bar chart
  fix: Remove comment line completely
  fix: trimStart to text
  test: add space before init
  fix uncaughexception in tests
  fix(#4256): Keep error diagram on screen
  fix(#4137): Cleanup comments before parsing
  Update docs
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
3 participants