Reocin / obsidian-markdown-formatting-assistant-plugin

This Plugin provides a simple WYSIWYG Editor for Markdown and in addition a command line interface. The command line interface facilitate a faster workflow.
251 stars 28 forks source link

Error parsing Mermaid diagram #17

Closed AytoMaximo closed 3 years ago

AytoMaximo commented 3 years ago

Describe the bug The plugin can't parse any of mermaid examples besides the simplest one from the documentation or Mermaid live editor

To Reproduce Steps to reproduce the behavior:

  1. Insert mermaid block
  2. Copy any example from the links above and paste it in the mermaid block in Obsidian
  3. Switch to preview mode
  4. See error

Example block of code

graph TD
    A[Christmas] -->|Get money| B(Go shopping)
    B --> C{Let me think}
    C -->|One| D[Laptop]
    C -->|Two| E[iPhone]
    C -->|Three| F[fa:fa-car Car]

The error message

Error parsing Mermaid diagram!

Parse error on line 3:
...ph TD A\[Christmas\] \-->|Get mon
---------------------^
Expecting 'SPACE', 'GRAPH', 'DIR', 'subgraph', 'SQE', 'end', 'AMP', 'TAGEND', 'START_LINK', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'DOWN', 'UP', 'DEFAULT', 'NUM', 'COMMA', 'ALPHA', 'COLON', 'MINUS', 'BRKT', 'DOT', 'PCT', 'TAGSTART', 'PUNCTUATION', 'UNICODE_TEXT', 'PLUS', 'EQUALS', 'MULT', 'UNDERSCORE', got 'TRAPEND'

Expected behavior I'm expecting to see the same picture as in the examples or get some mermaid syntax and its features documentation of the plugin.

Reocin commented 3 years ago

@AytoMaximo Hello and thanks for your response.

Actually i have no clue about this topic, because this was a pull request from the other user @AlexMikhalev. Do you know more about this ?

AlexMikhalev commented 3 years ago

The example above works for me, see code in raw gist

Reocin commented 3 years ago

@AlexMikhalev Thanks for your help i just tested it in my obsidian, and it worked too (see image). Probably you have a copy and paste issue? I see in your error backslashes which could happen when copy with normal ctrl-V try it with ctrl-shift-v.

Regards daniel

image

AlexMikhalev commented 3 years ago

My guess GraphTD was on the same line as mermaid with ticks and was ignored.

AytoMaximo commented 3 years ago

I've pasted the raw example from @AlexMikhalev , it's NOT working for me with CTRL+V

image image

But Ctrl+Shift+V works fine indeed image image

Thanks!

AlexMikhalev commented 3 years ago

See previous comment, you are escaping brackets.

On Thu, 22 Apr 2021 at 11:49, Marianna Alpatova @.***> wrote:

I've pasted the raw example from @AlexMikhalev https://github.com/AlexMikhalev , it's NOT working for me

[image: image] https://user-images.githubusercontent.com/14392087/115702395-8dc40d80-a371-11eb-9a42-84307295a5b6.png [image: image] https://user-images.githubusercontent.com/14392087/115702408-9288c180-a371-11eb-9d47-665f5e109c51.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Reocin/obsidian-markdown-formatting-assistant-plugin/issues/17#issuecomment-824736250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAML7MIRITYCYOPM26FS2DTJ75NJANCNFSM425EDEYQ .

Reocin commented 3 years ago

@AytoMaximo you are welcome, have fun with obsidian :-)

That is a behaviour of Obsidian, with the normal copy and past it tries to convert the copied data to obsidian syntax. And as you don't want any parsing you have to use the ctrl+shift+V.