question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with Java syntax

See original GitHub issue

My intention is to use draft-js-prism for Java syntax highlighting.

This is what I got with draft-js-prism in Java syntax:

syntax-higlighting-examples-java

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:

dist_js_2 prism_java_2

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:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
mengfoobarcommented, Sep 22, 2017

@mxstbr awesome! I’ll clean some stuff up and try to get a PR out this weekend

1reaction
mengfoobarcommented, Nov 7, 2016

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Software Errors: How to Avoid 50 Code Issues in Java
We've rounded up 50 of the most common Java software errors, complete with code examples and tutorials to help you work around common...
Read more >
Exercise : Syntax errors - Washington
The following Java program has several errors. Can you find them all? Copy and paste the code into jGrasp and see if you...
Read more >
Lesson: Common Problems (and Their Solutions) (The Java ...
This beginner Java tutorial describes getting started with Java and setting up ... If you mistype part of a program, the compiler may...
Read more >
Types of Errors in Java with Examples - GeeksforGeeks
Compile Time Errors are sometimes also referred to as Syntax errors. These kind of errors are easy to spot and rectify because the...
Read more >
Top 8 Common Java Errors for Beginners - Replit - Blog
If you just started programming in Java, then syntax errors are the first problems you'll meet! You can think of syntax as grammer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found