Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

code decorator tags?  RSS feed

 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would like to investigate code decorator tags that take code and decorate it (like it's displayed in an IDE).

Basically, hilite all the keywords, comments, parenthesis, strings, boolean and number literals.

You would use the tag like this:



And the result would be:

Anyone know one?

[ May 19, 2007: Message edited by: Garrett Smith ]
[ May 19, 2007: Message edited by: Garrett Smith ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, but it doesn't sound that hard to write.
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. Well, it does to me.

Consider that comments are special, you don't want to parse anything inside a comment. Well, except for doc comments like JavaDoc or JSDoc, which might have special @something.

Strings are special. You don't want parse anything (including comments) in strings, until you get to end of string (either " or ', depending what it started with). The end of string can be escaped with \, which itself can be escaped with \.

I'm thinking POJOs for this. Tag later. Maybe one to parse, one to deal with decorating. Maybe an XML to configure decoration.

Then there's annotations.

Are there classes that Eclipse uses to do its parsing for JSEclipse and Aptana renderers? Are they open source?

How much time do you think it would take to write and test?
[ May 19, 2007: Message edited by: Garrett Smith ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tag part is easy. The parsing is the hard part, and there are sure to be such packages out there, but I haven't looked.

Your approach of writing all the actual logic as re-usable POJOs is a good one.
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still looking:

I found:
javascript: code Prettify
php: GeSHi
Java: java2HTML - looks complex. Only supports Java language. Does show line numbers (good). Uses old font tags.

GeSHi is the best, but it is written in PHP and I don't have php available.

I am still looking for a code parser/beautifier that I can use.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!