• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

best way to markup text in java web app

 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm writing a webapp that allows users to enter comments in certain areas. Right now the app only allows plain text with no markup. I'm wondering about how to add a richer text experience.
Currently, I'm thinking of using markdown, and including markdownj. (never tried it, just saw it was there after some googling)

I've seen some of the other php type forums, for example in this forum if you want to make a phrase italic, it will be wrapped in bracketed tags ([ i ] ... [ /i ])
so....what does this do to the text in the db? Do the brackets go into the db along with the text? or is it stripped out? Two tables? text/formatted_text? One for searching, one for display?

Markdown looks pretty cool, and looks to be a growing standard, but unsure about the db aspect.

the other possibility is to use an xml datatype. I'm experimenting w/that in another app, but for this I'm mainly concerned w/the display

thanks!
bp
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps a JavaScript Rich Text Editor is the approach you want?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To do either Markdown or BBCode (the brackets, like we use here) you need to store the original source, so that posts can be edited in their original form. You can either process a post when it is posted, and store both the source and rendered versions (this would be faster when the posts are viewed, but use more storage) or you can store just the original, and render it whenever it is viewed (this uses less storage, but takes more total compute time, assuming a post is viewed more than once.)

One advantage of the second approach is that you can change how the markup is rendered over time. This is actually what JForum does -- it stores just the source of a post in the database, and renders it as HTML when it's loaded back in
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic