eleweek / WatchPeopleCode

http://WatchPeopleCode.com
MIT License
198 stars 16 forks source link

Basic chat formatting. (Markdown bold and italic) #30

Open gkbrk opened 9 years ago

gkbrk commented 9 years ago

Tested on Firefox.

eleweek commented 9 years ago

Hm, that's quite non-standard, e.g. bold could be done using two underscores. I think it'd be better to use some lib, e.g. this one: https://github.com/chjj/marked

gkbrk commented 9 years ago

I made it so it matches **this** and __this__ for bold, *this* and _this_ for italic. This seems to be how most implementations work. I was going to use the library but adding a 1285 line library for what can be done with 2 lines of code seemed like a waste.

Since we store the markdown in the database before converting to html, we can always switch to the library if we want more markdown features.

Here's the library code in case we need the relevant lines for bold and italic text.