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

Syntax error in Mindmap when '-' is included in multiline text #173

Closed
rolandchee opened this issue Oct 10, 2023 · 3 comments
Closed

Syntax error in Mindmap when '-' is included in multiline text #173

rolandchee opened this issue Oct 10, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@rolandchee
Copy link

The mind map syntax concept is wonderful and just what I have been looking for!
However, it has a small glitch -- the multiline text does not accept a hyphen character (ie '-').
I am afraid I do not know enough of Javascript, let alone Typescript to fix this.

The following code:

mindmap
+ Animals
++ Cat
++ Prairie-dog
++ :Jack-rabbit,
    Jack-russell;

Using pintora CLI, generated the following:

onError Error: Syntax error at line 5 col 9:

  ++ :Jack-
          ^
Unexpected MINUS token: "-". Instead, I was expecting to see one of the following:

A VALID_TEXT token based on:
    multilineText$ebnf$1$subexpression$1 →  ● %VALID_TEXT
    multilineText$ebnf$1 → multilineText$ebnf$1 ● multilineText$ebnf$1$subexpression$1
    multilineText →  ● multilineText$ebnf$1
    statement → levelNotation %WS %COLON ● multilineText %SEMICOLON statement$ebnf$1 %NL
    line → line$ebnf$1 ● statement
    document → document ● line
    start → "mindmap" ● document
A WS token based on:
    multilineText$ebnf$1$subexpression$1 →  ● %WS
    multilineText$ebnf$1 → multilineText$ebnf$1 ● multilineText$ebnf$1$subexpression$1
    multilineText →  ● multilineText$ebnf$1
    statement → levelNotation %WS %COLON ● multilineText %SEMICOLON statement$ebnf$1 %NL
    line → line$ebnf$1 ● statement
    document → document ● line
    start → "mindmap" ● document
A NL token based on:
    multilineText$ebnf$1$subexpression$1 →  ● %NL
    multilineText$ebnf$1 → multilineText$ebnf$1 ● multilineText$ebnf$1$subexpression$1
    multilineText →  ● multilineText$ebnf$1
    statement → levelNotation %WS %COLON ● multilineText %SEMICOLON statement$ebnf$1 %NL
    line → line$ebnf$1 ● statement
    document → document ● line
    start → "mindmap" ● document
A SEMICOLON token based on:
    statement → levelNotation %WS %COLON multilineText ● %SEMICOLON statement$ebnf$1 %NL
    line → line$ebnf$1 ● statement
    document → document ● line
    start → "mindmap" ● document

    at i.feed (/usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:107678)
    at /usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:110646
    at Object.parse (/usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:347408)
    at ae (/usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:40697)
    at Object.renderTo (/usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:535757)
    at /usr/local/lib/node_modules/@pintora/cli/lib/render.js:34:48
    at new Promise (<anonymous>)
    at pintorRender (/usr/local/lib/node_modules/@pintora/cli/lib/render.js:33:20)
    at /usr/local/lib/node_modules/@pintora/cli/lib/render.js:67:17
    at new Promise (<anonymous>) {
  offset: 20,
  token: {
    type: 'MINUS',
    value: '-',
    text: '-',
    toString: [Function: d],
    offset: 48,
    lineBreaks: 0,
    line: 5,
    col: 9
  }
}
pintora render

Render DSL to diagram image

Options:
      --version           Show version number                          [boolean]
      --help              Show help                                    [boolean]
  -i, --input             Input file path                             [required]
  -o, --output            Output file path
  -p, --pixel-ratio       Pixel ratio                               [default: 2]
  -b, --background-color  Background color
  -t, --theme             Pintora theme                     [default: "default"]
  -w, --width             Width of output image

Error: Syntax error at line 5 col 9:

  ++ :Jack-
          ^
Unexpected MINUS token: "-". Instead, I was expecting to see one of the following:

A VALID_TEXT token based on:
    multilineText$ebnf$1$subexpression$1 →  ● %VALID_TEXT
    multilineText$ebnf$1 → multilineText$ebnf$1 ● multilineText$ebnf$1$subexpression$1
    multilineText →  ● multilineText$ebnf$1
    statement → levelNotation %WS %COLON ● multilineText %SEMICOLON statement$ebnf$1 %NL
    line → line$ebnf$1 ● statement
    document → document ● line
    start → "mindmap" ● document
A WS token based on:
    multilineText$ebnf$1$subexpression$1 →  ● %WS
    multilineText$ebnf$1 → multilineText$ebnf$1 ● multilineText$ebnf$1$subexpression$1
    multilineText →  ● multilineText$ebnf$1
    statement → levelNotation %WS %COLON ● multilineText %SEMICOLON statement$ebnf$1 %NL
    line → line$ebnf$1 ● statement
    document → document ● line
    start → "mindmap" ● document
A NL token based on:
    multilineText$ebnf$1$subexpression$1 →  ● %NL
    multilineText$ebnf$1 → multilineText$ebnf$1 ● multilineText$ebnf$1$subexpression$1
    multilineText →  ● multilineText$ebnf$1
    statement → levelNotation %WS %COLON ● multilineText %SEMICOLON statement$ebnf$1 %NL
    line → line$ebnf$1 ● statement
    document → document ● line
    start → "mindmap" ● document
A SEMICOLON token based on:
    statement → levelNotation %WS %COLON multilineText ● %SEMICOLON statement$ebnf$1 %NL
    line → line$ebnf$1 ● statement
    document → document ● line
    start → "mindmap" ● document

    at i.feed (/usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:107678)
    at /usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:110646
    at Object.parse (/usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:347408)
    at ae (/usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:40697)
    at Object.renderTo (/usr/local/lib/node_modules/@pintora/cli/node_modules/@pintora/standalone/lib/pintora-standalone.umd.js:1:535757)
    at /usr/local/lib/node_modules/@pintora/cli/lib/render.js:34:48
    at new Promise (<anonymous>)
    at pintorRender (/usr/local/lib/node_modules/@pintora/cli/lib/render.js:33:20)
    at /usr/local/lib/node_modules/@pintora/cli/lib/render.js:67:17
    at new Promise (<anonymous>) {
  offset: 20,
  token: {
    type: 'MINUS',
    value: '-',
    text: '-',
    toString: [Function: d],
    offset: 48,
    lineBreaks: 0,
    line: 5,
    col: 9
  }
}

I see a similar error when trying the same code in Pintora Live Editor:

@https://pintorajs.vercel.app/demo/assets/client.js:39:1070
@https://pintorajs.vercel.app/demo/assets/client.js:44:10
parse@https://pintorajs.vercel.app/demo/assets/client.js:47:37398
Vg@https://pintorajs.vercel.app/demo/assets/client.js:11:17577
renderTo@https://pintorajs.vercel.app/demo/assets/client.js:62:6493
@https://pintorajs.vercel.app/demo/assets/client.js:62:8540
vf@https://pintorajs.vercel.app/demo/assets/client.js:85:24435
Fi@https://pintorajs.vercel.app/demo/assets/client.js:85:42732
iR@https://pintorajs.vercel.app/demo/assets/client.js:85:41513
go@https://pintorajs.vercel.app/demo/assets/client.js:85:40539
tx@https://pintorajs.vercel.app/demo/assets/client.js:85:37120
tx@[native code]
so@https://pintorajs.vercel.app/demo/assets/client.js:83:3275
@https://pintorajs.vercel.app/demo/assets/client.js:85:34473
@hikerpig hikerpig added the bug Something isn't working label Oct 11, 2023
@hikerpig
Copy link
Owner

Thank you for the issue.

The - may not be the direct reason though.

  1. : and ; is not well supported in Mindmap. This is a bug that should be fixed. And I think it'd be better if we can quote the content with "".
  2. Multiline is not supported in Mindmap

The example below works but I doubt it may not suit your need if the bugs above are not fixed.

mindmap
+ Animals
++ Cat
++ Prairie-dog
++ Jack-rabbit, Jack-russell
image

@rolandchee
Copy link
Author

Thanks for looking into this so soon!

Multiline actually works! See below (I changed the '-' dashes to '_' underlines):
Screen Shot 2023-10-11 at 6 48 33 pm

I like the idea of using quotes, though. There's just the problem of what to do when the label itself has quote characters. May I suggest using triple quotes, like they do in python.

@hikerpig
Copy link
Owner

This case is fixed in v0.6.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants