CommonMarker+Rouge
A CommonMarker wrapper with syntax highlight support by Rouge.
Installation
Add these lines to your application's Gemfile:
gem 'commonmarker-rouge'
Usage
# use default CommonMarker class and Rouge::Formatters::HTML formatter
CommonMarker::Rouge.render_html(content)
# get CommonMarker parsed AST
CommonMarker::Rouge.render_doc(content)
# pass options to CommonMarker
CommonMarker::Rouge.render_html(content, [:SAFE, :SOURCEPOS])
# use custom CommonMarker wrapper (must provide compatible render_doc)
CommonMarker::Rouge.render_html(content, cmark_class: CommonMarkerWrapper)
# use custom Rouge formatter
CommonMarker::Rouge.render_html(content, formatter: Rouge::Formatters::HTMLLinewise)
# pass some options to Rouge
CommonMarker::Rouge.render_html(content, options: { css_class: 'custom-class' })
License
The gem is available as open source under the terms of the MIT License.