oscarmorrison / md-page

📝 create a webpage with just markdown
https://oscarmorrison.github.io/md-page/
MIT License
1.29k stars 98 forks source link

~Optionally~ use <pre> (or any element) with specific id instead of <noscript> #49

Closed samruddhag1 closed 4 years ago

samruddhag1 commented 4 years ago

Blank page is shown if javascript is enabled but md-page script fails to load for some reason (for example if the linked script is unavailable). This happens because html isnt generated when md-page.js fails and browsers won't show the fallback <noscript> content if JS is enabled.

<noscript> content is also seen garbled in browsers as formatting including newlines and multiple spaces is ignored in html.

By using <pre> instead, we can guarantee display of md content and also that formatting is preserved. An md-page specific element id can be used to indicate exactly which element to parse. For backwards compatibility <noscript> tag is also allowed. The first match found of either an element with id="md-page-markdown-text" or <noscript> will be used.

Co-Authored-By: harsgak harsgak@users.noreply.github.com

p1ho commented 4 years ago

Hello, thanks for opening this PR! @oscarmorrison Was there a design decision to use <noscript> instead of <pre>? nit, If we're going ahead with this, I'd prefer the id to be shorter though

oscarmorrison commented 4 years ago

Yeah. No script ignores scripts. I don't like this PR change. Think it's better to stay as a fork, seems specific to a use care