Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CommonMark Html Mini Renderer only renders subset of commonmark. Should be good for stuff like user comments where minimal markup is required / desired
# Proof of concept to use CommonMarker to only render a subset of CommanMark language
# Good if you only want links, em, strong, etc where minimal markup is desired.
# Example: HtmlMiniRenderer.new.render(CommonMarker.render_doc("# Test"))
class HtmlMiniRenderer < CommonMarker::HtmlRenderer
[
:header,
:list,
:list_item,
:blockquote,
:hrule,
:code_block,
:image,
:code,
:table,
:table_header,
:table_row,
:table_cell
].each do |method|
define_method method do |node|
block do
out(node.to_commonmark)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment