• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Syntax Highlighter for Java source code

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm currently looking for a Syntax Highlighter (http://alexgorbatchev.com/SyntaxHighlighter/) that would enable me to format Java source code while presenting it in the UI. But I doubt if the Syntax Highlighter that I mentioned would do this.

I have some source code stored in the database which could be in a single line like this:



I want a library or a tool that would format this. I in fact wrote a small logic that would do it for me. I guess I covered most of the cases, be it however complex or how many ever loops it has, it formats and prints the formatted code perfectly. But now I would need this to work for other programming languages as well (read Scala, Ruby etc). I'm now looking for a strategy that would help me to achieve this with little effort. Should I consider storing the formatting information along with the source code in the database like this?



Or should I use some CSS to get the formatting right? How is it done here at the ranch? When I use the code tags, is it formatted?
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What should this formatter do that the one you mentioned doesn't? (Which is, by the way, what is used in this forum software.)
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:What should this formatter do that the one you mentioned doesn't? (Which is, by the way, what is used in this forum software.)



I thought I mentioned this in my post above. The formatter that I'm looking for should take a line of String (which is the source code in a single line), format it with proper indents for it to be presented in the UI. I'm not sure if Syntax Highlighter does this. I'm just about to download it and try it for myself.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is what I tried with the Syntax Highlighter which made it clear to me that it is just a highlighter and not a formatter!



Here is the resultant output!



Screen-Shot-2013-12-18-at-9.21.32-PM.png
[Thumbnail for Screen-Shot-2013-12-18-at-9.21.32-PM.png]
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic