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
70 71 72 |
# File 'lib/markdown_to_tex/renderer.rb', line 70 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
34 35 36 |
# File 'lib/markdown_to_tex/renderer.rb', line 34 def block_code(code, language) wrap_environment("verbatim", code) end |
#codespan(code) ⇒ Object
74 75 76 77 |
# File 'lib/markdown_to_tex/renderer.rb', line 74 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
109 110 111 |
# File 'lib/markdown_to_tex/renderer.rb', line 109 def () "\n% end-of-output" end |
#doc_header ⇒ Object
Header of the document Rendered before any another elements
103 104 105 |
# File 'lib/markdown_to_tex/renderer.rb', line 103 def doc_header() "% start-of-output\n" end |
#header(text, header_level) ⇒ Object
block_quote(quote) block_html(raw_html)
40 41 42 |
# File 'lib/markdown_to_tex/renderer.rb', line 40 def header(text, header_level) TextProcessor.process_header(text, header_level) end |
#linebreak ⇒ Object
double_emphasis(text) emphasis(text) image(link, title, alt_text)
81 82 83 |
# File 'lib/markdown_to_tex/renderer.rb', line 81 def linebreak() "\n%\n" end |
#link(link, title, content) ⇒ Object
85 86 87 |
# File 'lib/markdown_to_tex/renderer.rb', line 85 def link(link, title, content) "#{content}\\nobreak\\footnote{\\url{#{link}}}" end |
#list(contents, list_type) ⇒ Object
hrule()
46 47 48 49 50 51 52 |
# File 'lib/markdown_to_tex/renderer.rb', line 46 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
54 55 56 |
# File 'lib/markdown_to_tex/renderer.rb', line 54 def list_item(text, list_type) "\\item #{text}\n" end |
#paragraph(text) ⇒ Object
58 59 60 |
# File 'lib/markdown_to_tex/renderer.rb', line 58 def paragraph(text) TextProcessor.process_paragraph(text)+"\n\n" end |
#raw_html(raw_html) ⇒ Object
89 90 91 |
# File 'lib/markdown_to_tex/renderer.rb', line 89 def raw_html(raw_html) raw_html end |