Class: LadyJosephine::Redcarpet::CustomMarkdownFormatter
- Inherits:
-
Redcarpet::Render::SmartyHTML
- Object
- Redcarpet::Render::SmartyHTML
- LadyJosephine::Redcarpet::CustomMarkdownFormatter
- Defined in:
- lib/lady_josephine/redcarpet/custom_markdown_formatter.rb
Instance Method Summary collapse
- #block_code(code, language) ⇒ Object
- #block_quote(text) ⇒ Object
- #codespan(code) ⇒ Object
- #link(link, title, context) ⇒ Object
- #list(contents, list_type) ⇒ Object
- #paragraph(text) ⇒ Object
- #postprocess(full_document) ⇒ Object
- #preprocess(full_document) ⇒ Object
Instance Method Details
#block_code(code, language) ⇒ Object
8 9 10 |
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 8 def block_code(code, language) "<p>" << code << "</p>" end |
#block_quote(text) ⇒ Object
16 17 18 |
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 16 def block_quote(text) text end |
#codespan(code) ⇒ Object
24 25 26 |
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 24 def codespan(code) code end |
#link(link, title, context) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 41 def link(link, title, context) if is_internal_link?(link) "<a href=\"#{link}\">#{context}</a>" else "<a href=\"#{link}\" target=\"_blank\">#{context}</a>" end end |
#list(contents, list_type) ⇒ Object
20 21 22 |
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 20 def list(contents, list_type) contents end |
#paragraph(text) ⇒ Object
12 13 14 |
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 12 def paragraph(text) text end |
#postprocess(full_document) ⇒ Object
28 29 30 |
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 28 def postprocess(full_document) full_document.gsub(/<br>/, "<br>\n") end |
#preprocess(full_document) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 32 def preprocess(full_document) sanitized_document = full_document.gsub(/\"(.*?)\"/) do "„#{$1}“" end sanitized_document.gsub!(/\./, "\\.") sanitized_document.gsub!(/\n/, "<br>\n") sanitized_document end |