Reputation: 638
Need a guide line ....
I am trying to write a personal blog.
What is the standard structure for for input for the post.
I am trying the format like:
This is the simple text
And I am [b] bold text[/b].
This is the code part:
[code lang=java]
public static void main (String args[]) {
System.out.println("Hello World!");
}
[/code]
Is this the right way to store post in the database?
And What is the right method to parse this kind of post? Shall I use regular expression to parse this or there is another standard for this. If the above mentioned format is not the right way for storage, then what it could be?
Thanks
Upvotes: 0
Views: 179
Reputation: 4327
Have you considered using an existing dialect like markdown or textile? Both are feature rich in terms of supported markup, implementations are available in a plethora of languages, both for markdown and textile.
[1]: http://daringfireball.net/projects/markdown/
[2]: http://www.textism.com/tools/textile/
[3]: http://en.wikipedia.org/wiki/Markdown#Alternate_implementations
[4]: http://www.oreillynet.com/onlamp/blog/2007/05/praising_textile_1.html
Upvotes: 1
Reputation: 31243
Seems to me you are looking for something like BBCode
Take a look on the link, there are several libraries that do this. One example (from Wikipedia):
Disclaimer: Not tested myself
Also take a look on this question: Java BBCode library
Edit: Additional points
Upvotes: 2
Reputation: 8915
XML is probably the best format for storing the post body, and there are many standard libraries for parsing it.
Upvotes: 0