• Post Reply Bookmark Topic Watch Topic
  • New Topic

Some help or insight for creating a comment functionality that highlights code  RSS feed

 
Stamin Adrian
Ranch Hand
Posts: 34
Chrome Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm making a comments section on a web app and I have the following problems.

As you know, when writting into a text area you can shift+enter to jump to a new row. If for instance I do this on my web app and insert the comment into the database into a longText data type, I can see if the user did actually use shift+enter.

The problem is, when I get the data back, it's just a string. How would I process it in java so I can display it in HTML with their respective rows. Also, how would I go about creating a functionality that can insert code and highlight it. Any help highly apreciated. Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean "it's just a string"? What else would you expect the text to be?

As far as code highlighting, that's likely a huge ball of wax. You'll need a syntax analyzer that can identify the parts of the code and then use that info to create the proper HTML structure and CSS for display.

I would not be surprised if there were already implementations that you could use.
 
Stamin Adrian
Ranch Hand
Posts: 34
Chrome Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Yes it's always a string. Didn't realize I can't really see the '\n' char. Just delete this post because what I said was stupid.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The syntax highlighter used in these forums -visible in your second post- is http://alexgorbatchev.com/SyntaxHighlighter/
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!