Class: MarkdownToTeX::Renderer
- Inherits:
-
Redcarpet::Render::Base
- Object
- Redcarpet::Render::Base
- MarkdownToTeX::Renderer
- Defined in:
- lib/markdown_to_tex/renderer.rb
Instance Method Summary collapse
-
#autolink(link, link_type) ⇒ Object
Span-level calls A return value of ‘nil` will not output any data If the method for a document element is not implemented, the contents of the span will be copied verbatim.
-
#block_code(code, language) ⇒ Object
Block-level calls If the return value of the method is ‘nil`, the block will be skipped.
- #codespan(code) ⇒ Object
-
#doc_footer ⇒ Object
Footer of the document Rendered after all the other elements.
-
#doc_header ⇒ Object
Header of the document Rendered before any another elements.
-
#header(text, header_level) ⇒ Object
block_quote(quote) block_html(raw_html).
-
#linebreak ⇒ Object
double_emphasis(text) emphasis(text) image(link, title, alt_text).
- #link(link, title, content) ⇒ Object
-
#list(contents, list_type) ⇒ Object
hrule().
- #list_item(text, list_type) ⇒ Object
- #paragraph(text) ⇒ Object
- #raw_html(raw_html) ⇒ Object
Instance Method Details
#autolink(link, link_type) ⇒ Object
Span-level calls A return value of ‘nil` will not output any data If the method for a document element is not implemented, the contents of the span will be copied verbatim
69 70 71 |
# File 'lib/markdown_to_tex/renderer.rb', line 69 def autolink(link, link_type) "{{autolink:<#{link}>, title:<#{title}>, content:<#{content}>}}" end |
#block_code(code, language) ⇒ Object
Block-level calls If the return value of the method is ‘nil`, the block will be skipped. If the method for a document element is not implemented, the block will be skipped.
Example:
class RenderWithoutCode < Redcarpet::Render::HTML
def block_code(code, language)
nil
end
end
33 34 35 |
# File 'lib/markdown_to_tex/renderer.rb', line 33 def block_code(code, language) wrap_environment("verbatim", code) end |
#codespan(code) ⇒ Object
73 74 75 76 |
# File 'lib/markdown_to_tex/renderer.rb', line 73 def codespan(code) qchar = if code =~ /\+/ then "!" else "+" end "\\verb#{qchar}#{code}#{qchar}" end |
#doc_footer ⇒ Object
Footer of the document Rendered after all the other elements
108 109 110 |
# File 'lib/markdown_to_tex/renderer.rb', line 108 def () "\n% end-of-output" end |
#doc_header ⇒ Object
Header of the document Rendered before any another elements
102 103 104 |
# File 'lib/markdown_to_tex/renderer.rb', line 102 def doc_header() "% start-of-output\n" end |
#header(text, header_level) ⇒ Object
block_quote(quote) block_html(raw_html)
39 40 41 |
# File 'lib/markdown_to_tex/renderer.rb', line 39 def header(text, header_level) TextProcessor.process_header(text, header_level) end |
#linebreak ⇒ Object
double_emphasis(text) emphasis(text) image(link, title, alt_text)
80 81 82 |
# File 'lib/markdown_to_tex/renderer.rb', line 80 def linebreak() "\n%\n" end |
#link(link, title, content) ⇒ Object
84 85 86 |
# File 'lib/markdown_to_tex/renderer.rb', line 84 def link(link, title, content) "#{content}\\nobreak\\footnote{\\url{#{link}}}" end |
#list(contents, list_type) ⇒ Object
hrule()
45 46 47 48 49 50 51 |
# File 'lib/markdown_to_tex/renderer.rb', line 45 def list(contents, list_type) environment = case list_type when "ordered" then "enumerated" when "unordered" then "itemize" end wrap_environment("itemize", contents) end |
#list_item(text, list_type) ⇒ Object
53 54 55 |
# File 'lib/markdown_to_tex/renderer.rb', line 53 def list_item(text, list_type) "\\item #{text}\n" end |
#paragraph(text) ⇒ Object
57 58 59 |
# File 'lib/markdown_to_tex/renderer.rb', line 57 def paragraph(text) TextProcessor.process_paragraph(text)+"\n\n" end |
#raw_html(raw_html) ⇒ Object
88 89 90 |
# File 'lib/markdown_to_tex/renderer.rb', line 88 def raw_html(raw_html) raw_html end |