Class: PandocRuby
- Inherits:
-
Object
- Object
- PandocRuby
- Defined in:
- lib/pandoc-ruby.rb
Constant Summary collapse
- READERS =
The available readers and their corresponding names. The keys are used to generate methods and specify options to Pandoc.
{ 'commonmark' => 'CommonMark Markdown', 'creole' => 'Creole 1.0', 'csv' => 'CSV table', 'docbook' => 'DocBook', 'docx' => 'Word docx', 'dokuwiki' => 'DokuWiki markup', 'epub' => 'EPUB', 'fb2' => 'FictionBook2 e-book', 'gfm' => 'GitHub-Flavored Markdown', 'haddock' => 'Haddock markup', 'html' => 'HTML', 'ipynb' => 'Jupyter notebook', 'jats' => 'JATS XML', 'jira' => 'Jira wiki markup', 'json' => 'JSON version of native AST', 'latex' => 'LaTex', 'man' => 'roff man', 'markdown' => "Pandoc's Markdown", 'markdown_mmd' => 'MultiMarkdown', 'markdown_phpextra' => 'PHP Markdown Extra', 'markdown_strict' => 'original unextended Markdown', 'mediawiki' => 'MediaWiki markup', 'muse' => 'Muse', 'native' => 'native Haskell', 'odt' => 'ODT', 'opml' => 'OPML', 'org' => 'Emacs Org mode', 'rst' => 'reStructuredText', 't2t' => 'txt2tags', 'textile' => 'Textile', 'tikiwiki' => 'TikiWiki markup', 'twiki' => 'TWiki markup', 'vimwiki' => 'Vimwiki' }.freeze
- STRING_WRITERS =
The available string writers and their corresponding names. The keys are used to generate methods and specify options to Pandoc.
{ 'asciidoc' => 'AsciiDoc', 'asciidoctor' => 'AsciiDoctor', 'beamer' => 'LaTeX beamer slide show', 'commonmark' => 'CommonMark Markdown', 'context' => 'ConTeXt', 'docbook' => 'DocBook 4', 'docbook4' => 'DocBook 4', 'docbook5' => 'DocBook 5', 'dokuwiki' => 'DokuWiki markup', 'fb2' => 'FictionBook2 e-book', 'gfm' => 'GitHub-Flavored Markdown', 'haddock' => 'Haddock markup', 'html' => 'HTML, i.e. HTML5/XHTML polyglot markup', 'html5' => 'HTML, i.e. HTML5/XHTML polyglot markup', 'html4' => 'XHTML 1.0 Transitional', 'icml' => 'InDesign ICML', 'ipynb' => 'Jupyter notebook', 'jats_archiving' => 'JATS XML, Archiving and Interchange Tag Set', 'jats_articleauthoring' => 'JATS XML, Article Authoring Tag Set', 'jats_publishing' => 'JATS XML, Journal Publishing Tag Set', 'jats' => 'alias for jats_archiving', 'jira' => 'Jira wiki markup', 'json' => 'JSON version of native AST', 'latex' => 'LaTex', 'man' => 'roff man', 'markdown' => "Pandoc's Markdown", 'markdown_mmd' => 'MultiMarkdown', 'markdown_phpextra' => 'PHP Markdown Extra', 'markdown_strict' => 'original unextended Markdown', 'mediawiki' => 'MediaWiki markup', 'ms' => 'roff ms', 'muse' => 'Muse', 'native' => 'native Haskell', 'opml' => 'OPML', 'opendocument' => 'OpenDocument', 'org' => 'Emacs Org mode', 'pdf' => 'PDF', 'plain' => 'plain text', 'pptx' => 'PowerPoint slide show', 'rst' => 'reStructuredText', 'rtf' => 'Rich Text Format', 'texinfo' => 'GNU Texinfo', 'textile' => 'Textile', 'slideous' => 'Slideous HTML and JavaScript slide show', 'slidy' => 'Slidy HTML and JavaScript slide show', 'dzslides' => 'DZSlides HTML5 + JavaScript slide show', 'revealjs' => 'reveal.js HTML5 + JavaScript slide show', 's5' => 'S5 HTML and JavaScript slide show', 'tei' => 'TEI Simple', 'xwiki' => 'XWiki markup', 'zimwiki' => 'ZimWiki markup' }.freeze
- BINARY_WRITERS =
The available binary writers and their corresponding names. The keys are used to generate methods and specify options to Pandoc.
{ 'odt' => 'OpenOffice text document', 'docx' => 'Word docx', 'epub' => 'EPUB v2', 'epub2' => 'EPUB v2', 'epub3' => 'EPUB v3' }.freeze
- WRITERS =
All of the available Writers.
STRING_WRITERS.merge(BINARY_WRITERS)
Class Attribute Summary collapse
-
.pandoc_path ⇒ Object
Returns the value of attribute pandoc_path.
Instance Attribute Summary collapse
- #binary_output ⇒ Object
-
#input_files ⇒ Object
Returns the value of attribute input_files.
-
#input_string ⇒ Object
Returns the value of attribute input_string.
- #option_string ⇒ Object
- #options ⇒ Object
- #writer ⇒ Object
Class Method Summary collapse
-
.convert(*args) ⇒ Object
A shortcut method that creates a new PandocRuby object and immediately calls ‘#convert`.
Instance Method Summary collapse
-
#convert(*args) ⇒ Object
(also: #to_s)
Run the conversion.
-
#initialize(*args) ⇒ PandocRuby
constructor
Create a new PandocRuby converter object.
Constructor Details
#initialize(*args) ⇒ PandocRuby
Create a new PandocRuby converter object. The first argument contains the input either as string or as an array of filenames.
Any other arguments will be converted to pandoc options.
Usage:
new("# A String", :option1 => :value, :option2)
new(["/path/to/file.md"], :option1 => :value, :option2)
new(["/to/file1.html", "/to/file2.html"], :option1 => :value)
163 164 165 166 167 168 169 170 171 172 |
# File 'lib/pandoc-ruby.rb', line 163 def initialize(*args) case args[0] when String self.input_string = args.shift when Array self.input_files = args.shift.join(' ') end self. = args end |
Class Attribute Details
.pandoc_path ⇒ Object
Returns the value of attribute pandoc_path.
9 10 11 |
# File 'lib/pandoc-ruby.rb', line 9 def pandoc_path @pandoc_path end |
Instance Attribute Details
#binary_output ⇒ Object
129 130 131 |
# File 'lib/pandoc-ruby.rb', line 129 def binary_output @binary_output ||= false end |
#input_files ⇒ Object
Returns the value of attribute input_files.
151 152 153 |
# File 'lib/pandoc-ruby.rb', line 151 def input_files @input_files end |
#input_string ⇒ Object
Returns the value of attribute input_string.
152 153 154 |
# File 'lib/pandoc-ruby.rb', line 152 def input_string @input_string end |
#option_string ⇒ Object
141 142 143 |
# File 'lib/pandoc-ruby.rb', line 141 def option_string @option_string ||= '' end |
#options ⇒ Object
135 136 137 |
# File 'lib/pandoc-ruby.rb', line 135 def @options ||= [] end |
#writer ⇒ Object
147 148 149 |
# File 'lib/pandoc-ruby.rb', line 147 def writer @writer ||= 'html' end |
Class Method Details
.convert(*args) ⇒ Object
A shortcut method that creates a new PandocRuby object and immediately calls ‘#convert`. Options passed to this method are passed directly to `#new` and treated the same as if they were passed directly to the initializer.
123 124 125 |
# File 'lib/pandoc-ruby.rb', line 123 def self.convert(*args) new(*args).convert end |
Instance Method Details
#convert(*args) ⇒ Object Also known as: to_s
Run the conversion. The convert method can take any number of arguments, which will be converted to pandoc options. If options were already specified in an initializer or reader method, they will be combined with any that are passed to this method.
Returns a string with the converted content.
Example:
PandocRuby.new("# text").convert
# => "<h1 id=\"text\">text</h1>\n"
185 186 187 188 189 190 191 192 193 194 |
# File 'lib/pandoc-ruby.rb', line 185 def convert(*args) self. += args if args self.option_string = (self.) if self.binary_output convert_binary else convert_string end end |