Show HN: Markdown page – Create a web page with just markdown
github.com
github.com
Along similar lines, I went back to LibreOffice recently and made a few web pages with it, just to try it out. It worked better than I expected.
After adding a simple PHP controller to the mix, injecting some CSS for responsiveness and other tags as needed, I have been impressed with how easy it makes publishing. If a single-pager is what's needed (or multi-pagers perhaps; I just haven't tried it yet), if what matters most is getting links and information public, it's a useful tool.
pandoc -s input.md -t html -o output.html
Scriptable Word to HTML sounds so useful.
markdown input.md > output.htmlI added a wiki page https://github.com/oscarmorrison/md-page/wiki explaining a couple of use cases, and some more details. Feel free to leave more feedback / open issues. Thanks Oscar!
[1] - http://strapdownjs.com/
I use <xmp> for html code commenting - see the source code at https://elementcss.neocities.org/
The one thing these markdown examples are missing is a way to do grids! I bet there's a clever way to make columns and rows work.
> Create a webpage by just writing markdown, nothing else!
The „nothing else” bit looks inaccurate, there’s a script tag at the very beginning.
Disclaimer: I am the author of it, and it is nowadays unmaintained.
Main use-case is when I want to share a markdown doc in a private GitHub repo, with a public url e.g http://oscarmorrison.com/md-page/oimasdoijasdmadeupurl-01231...
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
1. You are editing documents locally on your computer. This lets you double-click to view nice markdown in a web browser with a `file://` url.
2. You are editing a website, but don't have control over the server-side code.
3. You don't want to install a markdown rendering library on the server.
You don't have control over the server-side code, but it will let you inject <script> tags into the content? That seems a bit weird.
I take notes and write personal documentation in Markdown for tickets and projects. Nowadays I usually write in Visual Studio Code or Vim. I can see myself using this to share pages with people. Although I wonder how my syntax highlighting will work - I guess I'll have to write a shell script to copy the .md file to .html and insert the call to the md-page.js at the top.
And for other markup languages, e.g. Dr [2] for AsciiDoc.
[1] https://github.com/Xeoncross/jr [2] https://github.com/jonathonf/Dr
I did little but wruite in HTML from the late 1990s to mid 2010s. Markdown is my preferred route now.
Also conversant in LaTeX, formerly; nroff, DocBook, WP4.2, Wordstar (both with 'reveal codes' capabilities), and probably more. Pandoc is a game-changer.
The HTML5 specification also allows omitting most closing tags (except for the obvious ones, that you also need to close in markdown).
You are right about the <p> tag, still. It is the main source of annoyance when writing long documents in html by hand.
h[1-6], li, blockquote, pre, can all be specified via an opening-only syntax.
p, ul, ol, and dl can be omitted entirely.
Arguably anchors require closure, but the syntax is still briefer than HTML. Images likewise.
Header, footer, and aside don't exist (they can be supplied in a template). article, div, and span are also ignored.
Italic, bold, strikeout, code, subscript, and superscript require a lightweight closure, and are actually the main cause of grief in my Markup writing.
Tables are hugely more sane.
And footnotes automajickally exist. Swoon!
It's not that HTML is foreign or annoying to me. It's just .... more frictional.
And I have all kinds of nice words to say for HTML5. The base spec is quite good.
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.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)
};
});Sure we can add JavaScript and make the web work the way we want, like this example, but many more... but what about SEO?
For example, I had a page for my app, it was very minimalistic and pretty, I targeted the 400 msec cold loading time, instead of a screenshot, I had a very well encoded h.265 screen recording (it's okay, people who can run the app, can certainly see the video), that video didn't cost more than a well optimized JPEG.
But I had to drop the video, and only load it after the JPEG loaded because of SEO reasons. Google isn't smart enough to recognize the video unless it's a YouTube video.
I even disabled NoScript for the site. Thanks, I'd rather have plain HTML.
It looks like you wrote a script.js file, which calls showdown.js library (converting markdown to html). A uglified version called `md-page` is made pulling both resources
Basically, the script does following
1) wait for page to load
2) add css-styles via javascript
3) shove all the markdown in a variable "markdown", passing it as one giant string
4) Add settings for showdown.js
5) Rewrite entire markdown on page to HTML via showdown.js
6) Append to body and render
I could fork it and add breakpoints / run debugger but this is what I got from looking at source code
Line 43 to 48, I am not entirely sure what that hashlink does. What is the setTimeout function for? Could you expand on that?
As the element doesn't exist at time of first load this is a work around to focus on id once content is rendered in html
I don't know about dynamic webservers.
It works pretty well, but fairly bare bones and haven't updated it in a bit.
Here [1] is the list of "features" HN supports in the comment section.
A Markdown Web would look like the early Web.
Why don't they? Coordination is costly.
So they could but... why should they?
> Wouldn't that be a much simpler and more secure parser than HTML?
No, because Markdown allows for raw HTML, so a compliant Markdown parser must also include a complete HTML parser.
<div markup="markdown">Browser now _interprets_ content as markdown until end of div.</div>
It would make user-submitted content so much better since you could just directly embed bbcode, markdown, etc. without needing to parse it to html or validate that their submission is valid html/only using approved tags, etc.
gatsbyjs supports md, yaml and external graphql