Class: LadyJosephine::Redcarpet::CustomMarkdownFormatter

Inherits:
Redcarpet::Render::SmartyHTML
  • Object
show all
Defined in:
lib/lady_josephine/redcarpet/custom_markdown_formatter.rb

Instance Method Summary collapse

Instance Method Details

#block_code(code, language) ⇒ Object



5
6
7
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 5

def block_code(code, language)
  "<p>" << code << "</p>"
end

#block_quote(text) ⇒ Object



13
14
15
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 13

def block_quote(text)
  text
end

#codespan(code) ⇒ Object



21
22
23
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 21

def codespan(code)
  code
end


38
39
40
41
42
43
44
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 38

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



17
18
19
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 17

def list(contents, list_type)
  contents
end

#paragraph(text) ⇒ Object



9
10
11
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 9

def paragraph(text)
  text
end

#postprocess(full_document) ⇒ Object



25
26
27
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 25

def postprocess(full_document)
  full_document.gsub(/&lt;br&gt;/, "<br>\n")
end

#preprocess(full_document) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/lady_josephine/redcarpet/custom_markdown_formatter.rb', line 29

def preprocess(full_document)
  sanitized_document = full_document.gsub(/\"(.*?)\"/) do
    "#{$1}"
  end
  sanitized_document.gsub!(/\./, "\\.")
  sanitized_document.gsub!(/\n/, "<br>\n")
  sanitized_document
end