|
1require 'redcarpet/render_strip'
|
|
|
|
|
|
|
|
5 escape_html: false, filter_html: false,
|
|
6 hard_wrap: true, xhtml: true, safe_links_only: true,
|
|
7 no_styles: true, no_images: true, no_links: false,
|
|
8 with_toc_data: false, prettify: false, link_attributes: {}
|
|
|
|
|
|
|
|
12 no_intra_emphasis: true, tables: false, fenced_code_blocks: false,
|
|
13 autolink: true, disable_indented_code_blocks: false, strikethrough: true,
|
|
14 lax_spacing: false, space_after_headers: true, superscript: true,
|
|
15 underline: false, highlight: false, quote: false, footnotes: false
|
|
|
|
|
|
18 def markdown_to_html(markup, options = {})
|
|
19 markdown_parser(html_renderer(options), options).render(markup).html_safe
|
|
|
|
|
|
22 def markdown_to_text(markup, options = {})
|
|
23 markdown_parser(text_renderer, options).render(markup).html_safe
|
|
|
|
|
|
|
|
|
|
28 def html_renderer(options)
|
|
29 Redcarpet::Render::HTML.new(options_for_renderer(options))
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
|
|
33 Redcarpet::Render::StripDown.new
|
|
|
|
|
|
36 def markdown_parser(renderer, options)
|
|
37 Redcarpet::Markdown.new(renderer, options_for_parser(options))
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
40 def options_for_parser(options)
|
|
41 PARSER_DEFAULTS.merge(options.slice(*PARSER_DEFAULTS.keys))
|
|
|
|
|
- UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
- Complexity 1 » saikuro
|
44 def options_for_renderer(options)
|
|
45 HTML_DEFAULTS.merge(options.slice(*HTML_DEFAULTS.keys))
|
|
|
|
|