Project

pandoc_rb

0.0
No commit activity in last 3 years
No release in over 3 years
Fast bindings to Pandoc through Ruby's C FFI gem and Haskell's C FFI
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Build Status

Gem Version

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)
  ..
end

The 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 writers

And 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_')
end

Contributing

  1. Fork it ( https://github.com/michaeljklein/pandoc_rb/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request