Skip to content

Instantly share code, notes, and snippets.

@rustamli
Created January 24, 2013 10:25
Show Gist options
  • Save rustamli/14b18a74c4ee83f34c58 to your computer and use it in GitHub Desktop.
Save rustamli/14b18a74c4ee83f34c58 to your computer and use it in GitHub Desktop.

#6:15 pm

Started working on the project. I decided to implement it in JavaScript so that it would be easy to see HTML results.

#6:18 pm

I already have a simple UI, textarea for Java source input, button "To HTML" and output area. Time to get these components working! I thought it will make sense to start with getting Java keywords (public, final, catch, while) highlighted.

I googled "java keywords", got their list from Oracle web site. First idea was to tokenize everything using space character as a separator. Then go through the tokens and if any of them match just surround them with .

#6:31 pm

After few fails, keywords are being successfully processed now.

#6:45 pm

Next step: Strings. As we know that Java code will always be valid, it could be easily implemented with regex.

#6:50

Done! got keywords and strings highlighted. Next: detect annotations, classes, constants (mostly using Java code style convention).

#7:20 Great! Everything seems working! Testing Time!

#7:31

Comments.. are really tricky.. /* foo / int i; / bar */

#7:31 - 8:20 Some RegEx magic and comments are also working!

#8:20 - 8:45 More testing minor fixes

@Rahim16
Copy link

Rahim16 commented Feb 25, 2018

Haha, epic! Vspomnil SAPM perechital daje slaydi :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment