1

I'm building an application which will be available on several platforms (web, iphone, android...). They all display data from the same database.

What's the best way of storing some decorated text in the database to easily display it on all platforms? By saying decorated text, I mean on decorations like bold, italic, underline...

One option might be writing a BB code parser for each platform and storing a BB Code decorated text in database, but it doesn't sound like the best solution to me.

Any opinions? :)

Nebojsa Veron
  • 1,545
  • 3
  • 19
  • 36

2 Answers2

0

I have not tried it yet, but this looks promising:

https://uncodin.github.io/bypass/

It uses the markdown language to send formatted text and display it.

Eric
  • 7,787
  • 5
  • 19
  • 34
0

Sounds like a fun question!

If you're deploying on multiple platforms, my recommendation is to do one of two strategies:

  1. store your text in "Text" formats across all databases (SQlite / CoreData for the Android / iOS), so you can use html-encoded text, as well as bold, italic, and other markdown / markup
  2. use a regex library to parse all the markup

For #2, you'll see strategies in this SO question with a custom regex library to parse the string tags.

You might want to decide to use markdown, which is daring fireball's specific markup language set and has a library to support it, or textile, which have equally excellent markup libraries and SO questions.

So pick a markup language, save your text in the database to handle those values, and setup parser libraries in every platform to handle it. Document your efforts, put the code on github, or contribute to existing parsing bases.

Hope this helps!

Community
  • 1
  • 1
Dominic Tancredi
  • 41,134
  • 7
  • 34
  • 50