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

Special characters break parsing #54

Closed
TripleDogDare opened this issue Dec 12, 2014 · 14 comments
Closed

Special characters break parsing #54

TripleDogDare opened this issue Dec 12, 2014 · 14 comments
Labels
Type: Enhancement New feature or request

Comments

@TripleDogDare
Copy link

Currently Mermaid does not handle special characters inside elements.
Not only is it not allowed, but it also breaks the graph.

Building on a simple demo

graph LR;
    A[Object]-->B(Thing);

I'd like to use something with parenthesis in the text of an element.

graph LR;
    A[Object(foo,bar)]-->B(Thing);

I also attempted to use HTML character codes with no result.

graph LR;
    A[Object(foo,bar)]-->B(Thing);
@TripleDogDare TripleDogDare changed the title Special characters Special characters break parsing Dec 16, 2014
@knsv
Copy link
Collaborator

knsv commented Dec 16, 2014

I see the problem. Those characters are a bit tricky as they also are the elements that end the text in the node.

For instance in the simple example below the naïve parser will think the node has ended after the x) and will look after a link.

a(f(x))

I am sure it can be solved. You could count the number of parenthesis I guess or escape them somehow.
I'm open to someone submitting something like this as a pull request.

@knsv knsv added the Type: Enhancement New feature or request label Dec 16, 2014
@ABLsaurusRex
Copy link

It's not just special characters. I have a process called RTD in my software. When I try to make a node B(RTD) I get an error. B(R T D) works, B(R TD) does not work, B(RTD) does not work. Compare http://ABLsaurusRex.jsbin.com/qahofe/1 with
http://ABLsaurusRex.jsbin.com/lugucu/1 .

@knsv
Copy link
Collaborator

knsv commented Dec 18, 2014

I see you are running an older version in your example. That issue #8 has been fixed. You can run


mermaid.version();

In the javascript console to see the version. This issue was fixed in 0.2.14. I hope this solves your problem @ABLsaurusRex. No fix yet for the (,),[,] characters though.

@khai-tran
Copy link

Backslash ("") is another case of special character breaking the parser. Example:
graph LR;
A[Domain\User1]-->B(Thing);

@knsv
Copy link
Collaborator

knsv commented Dec 22, 2014

The problem with backslashes are fixes as of release 0.3.0

@khai-tran
Copy link

I just checked out the latest code and it fixed the backslash problem. Thanks :)

@timelyportfolio
Copy link

I believe this is related, so I'll file under this issue, but happy to separate into its own issue if that is better. So far, it seems style and % breaks the style parser, so here are some examples.

not working

graph TD;
     classDef exClass font-style:bold;
     a-->b;
     class a exClass;

graph TD;
     classDef exClass font-size:50%;
     a-->b;
     class a exClass;

working

graph TD;
     classDef exClass font-family:monospace;
     a-->b;
     class a exClass;

graph TD;
     classDef exClass font-size:10px;
     a-->b;
     class a exClass;

@knsv
Copy link
Collaborator

knsv commented Jan 8, 2015

Related it is! Will take a look.

@knsv
Copy link
Collaborator

knsv commented Jan 8, 2015

A fix is committed For the style/% problem. Will be included in the next release.
(This is now included in release 0.3.2)

@ctrellet
Copy link

Waiting special character implementation, I found this alternative to simulate bracket : "<." and ".>".

@chaseadamsio
Copy link

@knsv in the example:

graph TD
question1{Gas tank less than 1/8?}
action1[Fill tank to 100%]
question1-- Yes -->action1

An error is thrown, very similar to @TripleDogDare, maybe there should be parsing logic to handle html entities altogether?

Referenced from: http://stackoverflow.com/questions/28121525/mermaid-cli-how-do-you-escape-characters

@knsv
Copy link
Collaborator

knsv commented Jan 24, 2015

Hi Chase! Thanks for bringing this up. I expect there several other that are experiencing the same thing. I have added % as a valid text character so with the next release this will work. Perhaps we should sum thing up and do bigger fix for the characters. Right now its one at a time when they pop up.

Anyways, with 0.3.3 this will work

@chaseadamsio
Copy link

@knsv great turn around time! I agree, it'd be a really good idea to gather up all special characters that are processed as tags and make sure they're handled properly when it's appropriate.

This is a really cool product, nice work!

knsv added a commit that referenced this issue Jan 25, 2015
@knsv
Copy link
Collaborator

knsv commented Jun 7, 2015

I am going through issues and am closing this one. I think special characters are now much improved with the fix allowing any characters within quotes (#162).

@knsv knsv closed this as completed Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants