3 ms·
I have spent a lot of time writing HTML. I stood up my entire personal website in raw HTML and about 20 lines of CSS. Frankly, I don't get the appeal. It doesn
by syndicatedjelly 3y ago
I have spent a lot of time writing HTML. I stood up my entire personal website in raw HTML and about 20 lines of CSS.
Frankly, I don't get the appeal. It doesn't make me feel nostalgic. Rather, I just feel the weight of old technologies slowing my writing process, preventing me from getting in a writing flow. It's really, really hard to write sentences when you have to constantly remember to close out tags. Debugging style in an HTML file is one of the most thoroughly uninteresting experiences a developer will have, in my opinion.
Markdown has been my favorite markup language for the last several years. A raw Markdown file is very human-readable, compared to the tag detritus scattered about the standard HTML file. In Markdown, there are few formatting rules that must be followed.
Additionally, HTML can be embedded in Markdown. So if one really does need custom styling, raw HTML is still available as a fallback. I do not know the extent to which the full HTML spec is supported, but anytime I've been in a bind in Markdown,
Of course, Markdown can't be published directly as a static page. One would think that this necessitates the use of complex React plug-ins - but no! A simple bash script and a handy tool called pandoc is all you need:
mdToHtml {
files=$(find blog -name "*.md")
for f in $files; do
pandoc -f markdown $f > blog/compiled/$(basename "${f%.*}").html
done
}
What about templates?
mdToHtml2() {
files=$(find blog -name "*.md")
for f in $files; do
pandoc -f markdown $f > blog/$(basename "${f%.*}").html
head=$(head -n10 templates/blogTemplate.txt) # first n = 10 lines, header up to <body>
tail=$(tail -n2 templates/blogTemplate.txt) # last n = 2 lines, </body></html>
echo $head | cat - blog/$(basename "${f%.*}").html > temp && mv temp blog/$(basename "${f%.*}").html
echo $tail >> blog/$(basename "${f%.*}").html
done
echo "Markdown files converted to HTML"
}
That script is excessively verbose, and not optimized for organization. I don't know remember why it writes to a temp file first. But it gets the job done.
To summarize:
1) Markdown to HTML conversion is dead simple.
2) Writing in markdown reduces cognitive load by a significant amount, allowing a writer to remain "in flow" much more easily.
- wangw469 3y agoThanks a lot for sharing your thought and those scripts. Pandoc looks really great, and the script was so simple. I'll try to add it in my ci configure. Thanks a lot!
- syndicatedjelly 3y agoAbsolutely, I love that you're trying to write things in raw HTML for the record. As promised, here's my website that I rewrote in raw HTML a year ago - https://ashwinsundar.com/ https://ashwinsundar.com/ I had originally written it using GatsbyJS, which I had been told was all the rage in web dev these days. I hated the experience. I migrated to a pure HTML + CSS approach, throwing away 99.9% of the bloatware. The articles are now written in Markdown, and converted back to HTML with that bash script I shared above. So I totally get why you'd want to just write stuff in HTML instead of flavor-of-the-week web framework. In all honestly, HTML is all you need. And yeah that article at the top of my site "Prefer Markdown" was inspired by your article :)