~yujiri/sanemark

(Abandoned) Crystal library for a makdown variant
update readme
add abandonment notice
c29a7d27 — Ryan Westlund 2 years ago
tag v0.3.0

clone

read-only
https://git.sr.ht/~yujiri/sanemark
read/write
git@git.sr.ht:~yujiri/sanemark

You can also use your local clone with git send-email.

A Crystal implementation of Sanemark. Forked from markd, an implementation of Commonmark.

This project has since been abandoned due to my changing belief about Markdown. Markdown is just a bad format at its root, and I was misguided to try to fork it. A proper rich text format would not be a variant of Markdown. (I've also stopped hosting the Sanemark spec on my website, but you can still find it in spec/fixtures/spec.md.)

#Quick start

require "sanemark"

html = Sanemark.to_html(markdown)

# With options
options = Sanemark::Options.new(safe: true)
Sanemark.to_html(markdown, options)

#Options

Name Type Default value Description
allow_html Bool false let HTML through according to the Sanemark spec. By default, all HTML is escaped. This option also turns off sanitization of dangerous link protocols.
spoilers Bool false Enable spoilers, delimited by >! and !<. They are inline elements that have the same precedence as asterisks.
heading_ids Bool false Add id attributes to heading elements consisting of a slug of their plaintext.
time Bool false render time spent during block parsing, inline parsing, and rendering.

#Advanced

If you want to use a custom renderer, it can!

class CustomRenderer < Sanemark::Renderer

  def open_strong(node)
  end

  # more methods following in render.
end

options = Sanemark::Options.new(time: true)
document = Sanemark::Parser.parse(markdown, options)
renderer = CustomRenderer.new(options)

html = renderer.render(document)

This should be better documented, but for now it isn't.

My cashapp tag is $yujiri.