markdown (client-side)

javajosh 2023

Intro

This kata is about markdown. This kata demonstrates converting markdown to html in the browser. I will be using showdown as the markdown library. It has no dependencies, but I am unhappy with its enormous size and complexity (5k lines, 156KB unprocessed).

Some good markdown resources include google's markdown style guide. Showdown's interactive demo.

Note that github renders markdown very capably. It's a chore to replicate all of that functionality. In particular we're missing syntax highlighting. And writing about code is THE big reason to support markdown: writing about code in raw HTML is a terrible experience! And people want to see code. And honestly, I want to write about code. So markdown it is!

Server-side Markdown

See the Reflector docs

Client-side Markdown

In theory, client-side markdown is the best because you've deferred creation of the high entropy representation (html) until the last moment. We don't do this because the size of the markdown library is considerable. To reuse the same library across markdown resources invites an SPA approach, even for simple browsing, which I resist. (And in the worst-design case, it might be downloaded with every markdown resource) Here is the simplest thing that works, creating an HTML string from markdown and displaying it:

# Heading 1
With a new paragraph
  1. apple
  2. orange