News for hackers. Stuff that matters.
Re:Show HN: Markdown page – Create a web page with just mark... by jchw on Saturday October 06, 2018 @11:20AM (#18155555)
The flicker when loading the page sucks. I guess displaying Markdown in case of failure is not the worst thing, but it would be nice if there was a possible way to allow getting rid of the flicker at the cost of not having a graceful fallback.

One way you could accomplish this is by supporting script tags for this, like wrapping the page in:

    <script type="text/markdown">...</script>
...as an optional way to use the library. Browsers won't (shouldn't?) try to render the contents of the script tag before you get to it, so it would act like a typical SPA.
Re:Show HN: Markdown page – Create a web page with just mark... by judofyr on Saturday October 06, 2018 @01:07PM (#18156087)
Yesss, finally a use-case for the `<noframes>`-hack! This is actually even better than the approach of OP since we're guaranteed to get a plain text representation of the text (instead of the browser parsing it as HTML).

example.html:

    <script src="mdpage.js"></script><noframes>

    # Header
    Welcome to my simplest site

    - A
    - awesome
    - list
mdpage.js:

    document.write("<div id=main></div>");

    document.addEventListener("DOMContentLoaded", function() {
      var script = document.createElement('script');
      script.src = "https://unpkg.com/showdown";
      document.head.appendChild(script);

      var noframes = document.querySelector('noframes');

      script.onload = function() {
        var converter = new showdown.Converter({
          emoji: true,
          underline: true,
        })
        converter.setFlavor('github')
        main.innerHTML = converter.makeHtml(noframes.textContent)
      };
    });
Re:Show HN: Markdown page – Create a web page with just mark... by oscargeorge on Saturday October 06, 2018 @11:53PM (#18158757)
Thanks @judofyr + @matt-tingen. I just updated it to use the 'noscript' opening tag. Good idea, and solved my normal html not working problem! Thanks a bunch!
Re:Show HN: Markdown page – Create a web page with just mark... by matt-tingen on Saturday October 06, 2018 @12:39PM (#18155943)
An option for the best of both worlds would be to wrap the markdown in a <noscript> tag.
Re:Show HN: Markdown page – Create a web page with just mark... by oscargeorge on Saturday October 06, 2018 @10:58PM (#18158617)
fixed the flicker, was a Cloudflare rocket script issue