Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Back in 2013 I did a similar thing for a client with a popular code library.

Their documentation was written in markdown and the site was hosted on static hosting, so no server-side conversion.

Although the web page chrome (navigation, etc) was in HTML, they wanted the documentation to be in markdown under the hood after upload. They didn’t want to use any kind of conversion prior to uploading because they needed to make on-the-fly changes to the documentation after upload without writing in HTML.

So we opted to go with client-side markdown to html conversion on pageload. complete with a clickable legend and tabs to switch between language implementations for code examples.

Putting the markdown inside regular page formatting tags wasn’t reliable, as different browsers did different things to the content (for example some browsers converted “&” to “&” and the indentations for code was not respected). So we had to store the markdown in some sort of preformatted tag block.

However <pre> required special escaping of code characters ( <, >, &, etc).

So we opted to go with using a little-known <xmp> tag to store the markdown as search-engine indexable code. Since content inside <xmp> will be read as plaintext instead of being formatted by the browser, it was also great for being the input of a client-side markdown-to-html converter.

It worked quite well. If you want to see it in action it’s at https://www.genivia.com/dev.html



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: