Problems with Java syntax
See original GitHub issueMy intention is to use draft-js-prism for Java syntax highlighting.
This is what I got with draft-js-prism in Java syntax:
As I have marked, certain characters appear in unexpected colors.
Here are the two steps to reproduce this output:
1. Using the browser save the page at http://samypesse.github.io/draft-js-code/ to local disk
2. Edit dist.js
as follows:
Here is the snippet that I added:
Prism.languages.java=Prism.languages.extend("clike",{keyword:/\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,number:/\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,operator:{pattern:/(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,lookbehind:!0}}),Prism.languages.insertBefore("java","function",{annotation:{alias:"punctuation",pattern:/(^|[^.])@\w+/,lookbehind:!0}});
It was copied over from http://prismjs.com/download.html by checking “Java” as a supported language.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
@mxstbr awesome! I’ll clean some stuff up and try to get a PR out this weekend
@echenley ahh i see. I ended up doing something similar to what @jjkavalam did. which fixes the issue for most languages, but still have some problems with markup (the prismjs tokenize functions creates some pretty messy stuff for markup). Once that was fixed, got into even more issues with multi-lang syntax such as JSX, HTML PHP…etc.
Once i have a more complete implementation, will submit a pull request. Thanks a lot for the help! Bummer that the author moved on