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

The author is lying. The source isn't actually a markdown document, the source is HTML (you can easily verify this by right-clicking and selecting "View Source")

It's actually quite easy to actually render markdown pages in a browser. Start with this:

    <!doctype html><meta charset="utf-8"><script src="notes-all.js"></script><textarea>
    ## MarkDown *HERE*!!!!!
and "notes-all.js" contains something like this:

    document.write('<link rel="stylesheet" href="css/style.css">'));
    document.addEventListener('DOMContentLoaded', (event) => {
      var m = markdownIt({'html': true, 'linkify': true});
      var t = document.querySelector('textarea');
      var d = document.createElement('div');
      d.setAttribute('id', 'content');
      d.innerHTML = m.render(t.value);
      t.replaceWith(d);
    });
followed by markdown-it source code


I think the author means that they wrote a markdown document, which then was transformed (by a CI/CD pipeline, for example) to the html you see when you inspect the source.

I like your "Serve markdown, transform through a client-side script" approach though, so upvoting nonetheless.




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

Search: