• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

code decorator tags?

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic