CommonMark Html Mini Renderer only renders subset of commonmark. Should be good for stuff like user comments where minimal markup is required / desired
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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