PandocRb
Like PandocRuby, but its interface is more limited:
module PandocRb
def self.raise_exception(result)
..
def self.convert(in_format_str, out_format_str, input_str, extract_media_path='')
..
def self.reader_from_ext(extension)
..
endThe primary benefit is that instead of using system calls,
pandoc_rb directly uses the memory allocated for Ruby Strings
through the FFI.
The benchmark results indicate that both significant constant (from initialization) and linear (from streaming through bash pipes)
overhead for PandocRuby is eliminated in pandoc_rb.
Installation
Requires Haskell-stack
Add this line to your application's Gemfile:
gem 'pandoc_rb'And then execute:
$ bundle install
Or install it yourself as:
$ gem install pandoc_rb
Usage
pandoc_rb's main interface is contained in the PandocRb module.
The public interface consists of constants and a main conversion function
The constants include:
PandocRb::Version # The current version
PandocRb::Readers # A list of allowed readers
PandocRb::Writers # A list of allowed writersAnd the main conversion function is:
# General conversion function
PandocRb.convert input_format, output_format, input_string, (optional) extract_media_path
# Convert `markdown` to `latex`
PandocRb.convert 'markdown', 'latex', '_italic text_'
# Convert `docx` to `latex` from file
PandocRb.convert 'docx', 'latex', File.binread('some_doc.docx'), `extract/figures/dir`
# Convert `markdown` to `docx`, writing to a `docx` file
File.open 'some_doc.docx', 'wb' do |file|
file.write PandocRb.convert('markdown', 'docx', '_italic text_')
endContributing
- Fork it ( https://github.com/michaeljklein/pandoc_rb/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request