Created
April 16, 2015 08:25
-
-
Save mba811/d0f508a90abcabc25757 to your computer and use it in GitHub Desktop.
Only support redcarpet with rouge as syntax highlighter.(kitabu)
This file contains hidden or 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
| module Kitabu | |
| module Markdown | |
| class Renderer < Redcarpet::Render::HTML | |
| include Redcarpet::Render::SmartyPants | |
| include Rouge::Plugins::Redcarpet | |
| end | |
| class << self | |
| # Set markdown renderer | |
| attr_accessor :processor | |
| end | |
| renderer = Renderer.new(hard_wrap: true, safe_links_only: true) | |
| self.processor = Redcarpet::Markdown.new(renderer, { | |
| tables: true, | |
| footnotes: true, | |
| space_after_headers: true, | |
| superscript: true, | |
| highlight: true, | |
| strikethrough: true, | |
| autolink: true, | |
| fenced_code_blocks: true, | |
| no_intra_emphasis: true | |
| }) | |
| def self.render(text) | |
| processor.render(text) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment