Class: Cadmus::Markdown::TextRenderer

Inherits:
Redcarpet::Render::Base
  • Object
show all
Defined in:
lib/cadmus/markdown.rb

Overview

A Redcarpet renderer that outputs formatted plain text (that looks quite similar to the Markdown input sent to it).

Instance Method Summary collapse

Instance Method Details

#block_code(text, language) ⇒ Object



19
20
21
# File 'lib/cadmus/markdown.rb', line 19

def block_code(text, language)
  normal_text(text)
end

#codespan(text) ⇒ Object



23
24
25
# File 'lib/cadmus/markdown.rb', line 23

def codespan(text)
  normal_text(text)
end

#double_emphasis(text) ⇒ Object



38
39
40
# File 'lib/cadmus/markdown.rb', line 38

def double_emphasis(text)
  "**#{text}**"
end

#emphasis(text) ⇒ Object



42
43
44
# File 'lib/cadmus/markdown.rb', line 42

def emphasis(text)
  "*#{text}*"
end

#header(title, level) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/cadmus/markdown.rb', line 27

def header(title, level)
  case level
  when 1
    "#{title.upcase}\n#{'=' * title.length}\n\n"
  when 2
    "#{title}\n#{'-' * title.length}\n\n"
  when 3
    "#{title.upcase}\n\n"
  end
end

#linebreakObject



46
47
48
# File 'lib/cadmus/markdown.rb', line 46

def linebreak
  "\n"
end

#list(content, list_type) ⇒ Object



54
55
56
# File 'lib/cadmus/markdown.rb', line 54

def list(content, list_type)
  "#{content}\n"
end

#list_item(content, list_type) ⇒ Object



58
59
60
# File 'lib/cadmus/markdown.rb', line 58

def list_item(content, list_type)
  "  * #{content}"
end

#normal_text(text) ⇒ Object



15
16
17
# File 'lib/cadmus/markdown.rb', line 15

def normal_text(text)
  text
end

#paragraph(text) ⇒ Object



50
51
52
# File 'lib/cadmus/markdown.rb', line 50

def paragraph(text)
  "#{text}\n\n"
end