4 ms·
Using Markdown as HTML
I had an idea a while ago. Instead of dealing with two sets of files, why not make a file that was Markdown and HTML at the same time?
I found this utility, which unfortunately seems to have been abandoned: https://github.com/showdownjs/showdown
All you need to do is add a few lines to the top of your Markdown file. Here's an example:
https://trivialcode.com/mdhtml_demo/demo.mdhtml
Take a look at the source of the .mdhtml file and you'll see what I mean.
If you're taking notes in Markdown this might make things a bit easier to keep organized. No need to update anything if you're exporting to HTML.
Thoughts? Is this a good idea? A bad one? I also wondered if generating Markdown via a web server and then converting it on the fly like this would be an interesting exercise. Seems like it'd be simpler than generating HTML.
I use Vim, so I've put this in my vimrc for editing:
autocmd BufNewFile,BufRead *.mdhtml set syntax=markdown
First time posting here. Let me know what you guys think.
- jmercouris 5y agoHave you tried using pandoc to convert markdown to HTML?
- trivialcode 5y agoThe whole point is removing the need to convert anything.
- jmercouris 5y agoI guess I didn’t get that :-(, sorry!
- trivialcode 5y agoAll good, I don't know if I explained the idea clearly. It looks like this is a far better version of the idea: https://github.com/susam/texme https://github.com/susam/texme
- detaro 5y agoSounds like a terrible idea. You loose the fallback, because Markdown treated as HTML instead of text is pretty much unreadable. (block the script to see what I mean: the rules about newlines etc in HTML do work differently)
- trivialcode 5y agoI realize that's an issue. But is the web even usable without JS these days anyway?
- theschmed 5y agoIsn’t texme doing what you suggest here? Or am I missing something? https://github.com/susam/texme https://github.com/susam/texme
- trivialcode 5y agoHadn't heard of that - that's way better. Cheers!
- tannhaeuser 5y agoI have taken a look at the .mdhtml file and don't know what you mean ;( I you mean having one file that can contain both markdown and HTML, that's what markdown is already, since you can fallback to inline or block-level HTML in markdown. If OTOH you want a HTML file that can also contain markdown (or other custom Wiki syntax, and text substitution variables, and a whole lot more), than that's available in SGML (on which HTML is based) via short references.
- cpach 5y agoIt’s an interesting concept. But for me personally I don’t see any practical benefits of using it. On my web pages I use Hugo. Conversation is done when the CI/CD system runs Hugo.[1] [1] I currently use AWS Amplify. But it’s not hard to build a small Bash script to replace it.
- _448 5y agoMarkdeep[0] could be an option for what you are looking for. [0] https://casual-effects.com/markdeep https://casual-effects.com/markdeep
- trivialcode 5y agoWow - that's really cool also. Cheers!
- approxim8ion 5y agoNot the same thing, but have a look at the Gemini [0] protocol. It uses a markup format called Gemtext which is similar to, although less featureful than Markdown. All pages are written in and served as gemtext. There's almost no rendering done, unless your client is configured to use custom stylesheets. [0]: http://gemini.circumlunar.space/ http://gemini.circumlunar.space/