Giter VIP home page Giter VIP logo

pandoc-ruby's Introduction

PandocRuby

Build Status Gem Version Gem Downloads

PandocRuby is a wrapper for Pandoc, a Haskell library with command line tools for converting one markup format to another.

Pandoc can convert documents from a variety of formats including markdown, reStructuredText, textile, HTML, DocBook, LaTeX, and MediaWiki markup to a variety of other formats, including markdown, reStructuredText, HTML, LaTeX, ConTeXt, PDF, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, groff man pages, HTML slide shows, EPUB, Microsoft Word docx, and more.

Installation

First, install Pandoc.

PandocRuby is available on RubyGems:

gem install pandoc-ruby

To install with Bundler, add the following to your Gemfile:

gem 'pandoc-ruby'

Then run bundle install

Usage

require 'pandoc-ruby'
@converter = PandocRuby.new('# Markdown Title', from: :markdown, to: :rst)
puts @converter.convert

This takes the Markdown formatted string and converts it to reStructuredText.

You can also use the #convert class method:

puts PandocRuby.convert('# Markdown Title', from: :markdown, to: :html)

Other arguments are simply converted into command line options, accepting symbols and strings for options and hashes for options with arguments.

PandocRuby.convert('# Markdown Title', :s, {f: :markdown, to: :rst}, '--wrap=none', :table_of_contents)

is equivalent to

echo "# Markdown Title" | pandoc -s -f markdown --to=rst --wrap=none --table-of-contents

Also provided are #to_[writer] instance methods for each of the writers, and these can also accept options:

PandocRuby.new('# Example').to_html(:ascii)
# => "<h1 id="example">Example</h1>"
# or
PandocRuby.new("# Example").to_rst
# => "Example
#     ======="

Similarly, there are class methods for each of the readers, so readers and writers can be specified like this:

PandocRuby.html("<h1>hello</h1>").to_latex
# => "\\section{hello}"

Available readers and writers are can be found in the following variables:

PandocRuby assumes the pandoc executable is in your environment's $PATH variable. If you'd like to set an explicit path to the pandoc executable, you can do so with PandocRuby.pandoc_path = '/path/to/pandoc'

Converting Files

PandocRuby can also take an array of one or more file paths as the first argument. The files will be concatenated together with a blank line between each and used as input.

# One file path as a single-element array.
PandocRuby.new(['/path/to/file1.docx'], from: 'docx').to_html
# Multiple file paths as an array.
PandocRuby.new(['/path/to/file1.docx', '/path/to/file1.docx'], from: 'docx').to_html

If you are trying to generate a standalone file with full file headers rather than just a marked up fragment, remember to pass the :standalone option so the correct header and footer are added.

PandocRuby.new("# Some title", :standalone).to_rtf

Extensions

Pandoc extensions can be used to modify the behavior of readers and writers. To use an extension, add the extension with a + or - after the reader or writer name:

# Without extension:
PandocRuby.new("Line 1\n# Heading", from: 'markdown_strict').to_html
# => "<p>Line 1</p>\n<h1>Heading</h1>\n"

# With `+blank_before_header` extension:
PandocRuby.new("Line 1\n# Heading", from: 'markdown_strict+blank_before_header').to_html
# => "<p>Line 1 # Heading</p>\n

More Information

For more information on Pandoc, see the Pandoc documentation or run man pandoc (also available here).

If you'd prefer a pure-Ruby extended markdown interpreter that can output a few different formats, take a look at kramdown. If you want to use the full reStructuredText syntax from within Ruby, check out RbST, a docutils wrapper.

This gem was inspired by Albino. For a slightly different approach to using Pandoc with Ruby, see Pandoku.

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

pandoc-ruby's People

Contributors

candlerb avatar changecase avatar dalehamel avatar dependabot[bot] avatar dginev avatar dkharrat avatar dsanson avatar felixonmars avatar offbyone avatar wiegand avatar xwmx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pandoc-ruby's Issues

Ignore equations.

Thanks a ton for making this! When converting LaTeX -> HTML, is there a way to ignore questions?

So that pandoc wouldn't convert any LaTeX between:

\begin{equation}
... ignored ...
\end{equation}

Such that equations could be rendered with something like MathJax?.

Thanks!

Syntax for serving converted file with Rails?

I'm trying to serve a converted file with Rails and I'm not sure what the syntax should be. I've run the command line and everything is installed correctly.

format.pdf  {
    html = render_to_string(
      :template => 'standards/show.pdf.erb',
      :layout => 'layouts/pdf.html.erb' )
    converter = PandocRuby.new(html, :from => :html, :to => :pdf)
    f = File.new("/tmp/#{@standard.title}_#{Time.now()}.pdf", "w")
    f.write(converter.convert)
    send_file f, :disposition => "attachment"
    f.close
}

It looks like the convert method returns nothing - the resulting pdf is totally empty (as in not even file headers). Changing to converter = PandocRuby.new(html, {:from => :html, :to => :pdf}, :standalone) gives a broken pipe error. Any help is greatly appreciated!

pandoc ruby new user error

I have just installed pandoc using gem install pandoc-ruby and have tried running this sample script:

require 'pandoc-ruby'
@converter = PandocRuby.new('# Markdown Title', :from => :markdown, :to => :rst)
puts @converter.convert

I get the following errors:

open3.rb:202: in spawn': No such file or directory - pandoc --from=markdown --to=rst (Errno::ENOENT) open3.rb:202: inpopen_run'
open3.rb:90: in popen3' pandoc-ruby.rb:101: inexecute'
pandoc-ruby.rb:77: in convert' pandoc test.rb:3: in

'

I assume that as the script is one of the ones given as an example that there must be something wrong with the installation. Does anyone know how to fix this?

Many thanks

Fails if there are spaces in the outfile

For example, this appears to fail:

  @converter = PandocRuby.new(
    "input.md", 
    :from => :markdown, 
    :output => "my output.pdf"
  )

It can be resolved by quoting the output file:

  @converter = PandocRuby.new(
    "input.md", 
    :from => :markdown, 
    :output => "'my output.pdf'"
  )

However, I wonder if it is worth creating a more general fix within pandoc-ruby?

I've tested this only in version 2.0.1 (apologies if this has already been fixed!)

Pandoc deprecated --chapter in favor of --top-level-division=chapter

Receiving an error just recently where --chapter has been deprecated by Pandoc in favor of --top-level-division=chapter. Changed in 2016 (http://pandoc.org/releases.html#pandoc-1.18-26-oct-2016)

(I had an old version of Pandoc)

RuntimeError: --chapters has been removed. Use --top-level-division=chapter instead.
Try pandoc --help for more information.
/Users/.../pandoc-ruby-2.0.2/lib/pandoc-ruby.rb:222:in `execute'
/Users/.../pandoc-ruby-2.0.2/lib/pandoc-ruby.rb:198:in `execute_pandoc'
/Users/.../pandoc-ruby-2.0.2/lib/pandoc-ruby.rb:190:in `convert_string'
/Users/.../pandoc-ruby-2.0.2/lib/pandoc-ruby.rb:132:in `convert'
/Users/.../pandoc-ruby-2.0.2/lib/pandoc-ruby.rb:166:in `block (2 levels) in <class:PandocRuby>'

BUG: after last update get error.

Hello.
I've got a Redmine system which use this staff.
After last update there is syntax error appeared.
image

For while I've installed previous version, but there will be awesome if i'll can getting updates later.

My system uses ruby 2.4.10p364 (2020-03-31 revision 67879) and

Support for Pandoc "extensions"?

The Pandoc CLI has support for "extensions" to reader and writer formats that can be specified as a suffix to the "from" or "to" format name. For instance, in order to disable the "markdown_in_html_blocks" extension (doc: http://pandoc.org/MANUAL.html#raw-html), you would invoke Pandoc as:

pandoc -f markdown-markdown_in_html_blocks <etc.>

Is this possible currently? If not, how difficult would it be to support? There's a clear use case for it, at least downstream in the Jekyll plugin: mfenner/jekyll-pandoc#10

In addition, Pandoc also has some pre-defined "styles" that gather up extensions into various Markdown flavors like GitHub and Multimarkdown: http://pandoc.org/MANUAL.html#markdown-variants. Could these also be added?

Textile text block with trailing space not converted only when using `pandoc-ruby`

Hi there, thanks for this extremely useful gem. I'm using it to convert a huge forum database from Textile to Markdown (GFM). I think I found a bug with this block of text:

I aqt sqbj 5Cs tqdny bnn nrj thjy nicj 

XbL 5C ----------------XbL 4k----------------XbL 3C------------------XbL 1n

!{width:100%}http://i1217.phqtqkuiujt.com/nlkubs/dd395/jrikkrjss/Picturj182-3.jpg! 

Notice that there is a trailing space at the very end. Directly converting this text from the command line works as expected:

~> pandoc --from textile --to gfm --wrap=preserve --no-highlight /shared/uploads/default/text.txt
I aqt sqbj 5Cs tqdny bnn nrj thjy nicj

XbL 5C ————————XbL 4k————————XbL 3C—————————XbL 1n

<img src="http://i1217.phqtqkuiujt.com/nlkubs/dd395/jrikkrjss/Picturj182-3.jpg" style="width:100.0%" alt="" />

But with this Rails command (which works fine for millions of other posts) it doesn't touch it:

new_raw = PandocRuby.textile(new_raw).to_gfm(:atx_headers,:wrap=>'preserve')
puts new_raw
I aqt sqbj 5Cs tqdny bnn nrj thjy nicj 

XbL 5C ----------------XbL 4k----------------XbL 3C------------------XbL 1n

!{width:100%}http://i1217.phqtqkuiujt.com/nlkubs/dd395/jrikkrjss/Picturj182-3.jpg!

Thanks a lot!

PandocRuby.convert returns empty under some conditions

'pandoc-ruby' gem has an annoying bug. It returns the empty string, under some conditions -- the one I've found is, given '--mathjax=true' flag.

Under the current latest version (I've tried 0.7.5)

irb(main):004:0> PandocRuby.convert('asdf', :from=>:markdown, :to=>:html, :mathjax=>true)
=> ""

It returns nothing.

With an older version 0.6.1,

irb(main):015:0> PandocRuby.convert('asdf', :from=>:markdown, :to=>:html, :mathjax=>true)
=> "<p>asdf</p>\n"

pandoc itself is working well:

$ pandoc --from markdown --to html --mathjax
asdf
<p>asdf</p>

Additional informations:

  • pandoc 1.10.1
  • pandoc is located at '/usr/bin/pandoc'
  • Ubuntu 13.04 x86_64
  • ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Converting HTML to Markdown strips anchor tag pairs without content on Ubuntu.

Consider the specs in this short vendor-verification spec file. The tests pass when run on Mac OS X 10.11.4 with Pandoc 1.17.0.3 installed and using pandoc-ruby 2.0.0 as bundled.

Run in an Ubuntu CI system (CodeShip) with Pandoc 1.17.0.3 and pandoc-ruby 2.0.0, and the tests die. Specifically, when the HTML

<p>This is <a id="contribution-27-begin"></a><a id="contribution-9-begin"></a>obviously <em>sample <a id="contribution-27-end"></a> and disposable</em> content.<a id="contribution-9-end"></a></p>

is converted to Markdown via PandocRuby.convert(html_content, from: :html, to: :markdown_github), the resulting Markdown is This is obviously *sample and disposable* content.\n. The tag pairs such as <a id="contribution-27-begin"></a> are simply removed completely.

Again, this happens in the Ubuntu build, but does not happen under OS X, where the converted Markdown appears as This is <a href="" id="contribution-27-begin"></a><a href="" id="contribution-9-begin"></a>obviously *sample <a href="" id="contribution-27-end"></a> and disposable* content.<a href="" id="contribution-9-end"></a>\n, which is as expected.

What gives with the Ubuntu?

How do you open a docx file?

If you pass a docx file into PandocRuby, e.g.:

PandocRuby.convert('./file.docx', :S, from: :docx, to: :html)

It errors with RuntimeError: pandoc: Cannot read archive from stdin

Images failing when convert happens asynchronously

I've narrowed down a bug in my app and found that everything is working as intended (including pandoc-ruby), except when executing in a Sidekiq background job. The export happens and produces the file but all images are missing. If I execute the same job with the same attributes in the foreground, the images are present. I doubt this is a pandoc-ruby issue but the issue's context seems most appropriate to mention here.

Has anyone else run into this? I'm playing around with the extract-media options and such and will report back if I can get PDF generation with images working in a background job.

Update: The export media flags and standalone options changed nothing. I've narrowed it down a bit further.

  Web server process Console process
Background Doesn’t work Doesn’t work
Foreground Doesn’t work Works

This is the most related issue I could find:
sidekiq/sidekiq#2044

It seems that someway the application is loaded is only making it work for foreground processes in the console. Images were working from the web in a background process previously. I believe this is most likely related to the upgrade to Rails 6.0 and zeitwerk (another update: opting out of zeitwerk did not change anything).

I need to know what's PandocRuby's path to pandoc

Hello

On my production server, the most current pandoc version is not the one in the standard path $ pandoc, but in $ /home/www-data/.local/bin/pandoc.

I managed to set PandocRuby to look at the correct place by setting it like so:

PandocRuby.pandoc_path = '/home/www-data/.local/bin/pandoc'

As I need to do some other stuff in my Rails app using Pandoc, I hoped that I could simply do something like this:

def pandoc_version
  matches = `#{PandocRuby.pandoc_path} -v`.match /\bpandoc ((\.?\d+)+)\b/
  pandoc_version = matches[1].to_f
end

But this results in:

undefined method `pandoc_path' for PandocRuby:Class

I managed to work around this now using a global variable:

PANDOC_PATH = '/home/www-data/.local/bin/pandoc'
PandocRuby.pandoc_path = PANDOC_PATH

So I can do:

def pandoc_version
  matches = `#{PANDOC_PATH} -v`.match /\bpandoc ((\.?\d+)+)\b/
  pandoc_version = matches[1].to_f
end

But I'm pretty sure there's an easier way to do this, right?

PandocRuby converts < and > in block codes to &lt; and &gt;

PandocRuby:

[5] irb »  PandocRuby.convert "Inline Code: `<asdf>`\n\n    Block code! <asdf>"
=> "<p>Inline Code: <code>&lt;asdf&gt;</code></p>\n<pre><code>Block code! &lt;asdf&gt;</code></pre>\n"

Pandoc:

$ pandoc
Inline Code: `<asdf>`

    Block code! <asdf>
--- Ctrl-D ---
<p>Inline Code: <code>&lt;asdf&gt;</code></p>
<pre><code>Block code! &lt;asdf&gt;</code></pre>

Input file names with spaces are not quoted

When running thusly:

input_file = "input/roam/Electronics Tools.md"
PandocRuby.new([input_file], from: 'org', wrap: 'none').to_gfm

The underlying pandoc command will look like this:

pandoc input/roam/Electronics Tools.md --from "org" --wrap "none" --to "gfm"

This fails, obviously, because the filename isn't quoted.

Using Pathname objects for file arguments is broken in 2.1.2 and 2.1.3

Commit b2c0e4d introduced a check if arguments contain whitespace. Before this change, any object supporting #to_s could be passed. Now, it has to support the =~ operator. This means passing Pathname objects for path-like arguments is not broken.

Casting these arguments to strings (after then nil check, of course) would fix this.

pandoc ruby should allow to read multiple files such as pandoc does

I t should be possible to specify

PandocRuby.allow_file_paths=true
PandocRuby.markdown(['../RS_Process/RS_Process.md','../RS_MarkdownEditor/RS_MarkdownEditor.md'])

This would allow to crate compile scripts in ruby using pandoc ruby.

Alternatively I could read the files in advance but i feel this is not very elegant.

Other approaches are also welcome.

Rails/PandocRuby: Exporting images results in “ERROR ThreadError: Attempt to unlock a mutex which is locked by another thread”

I'm exporting some markdown using PandocRuby. Everything works great, except when I'm trying to add images that reside in the public folder, Rails freezes:

ERROR ThreadError: Attempt to unlock a mutex which is locked by another thread
/Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/rack-1.6.4/lib/rack/lock.rb:22:in `unlock'
/Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/rack-1.6.4/lib/rack/lock.rb:22:in `ensure in call'
/Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/rack-1.6.4/lib/rack/lock.rb:23:in `call'
/Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'
/Users/josh/.rvm/gems/ruby-2.2.3@a4aa2/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service'
/Users/josh/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/Users/josh/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/Users/josh/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

When I'm using images from some other place (and not from my local Ruby app), the export works as expected.

How can this problem be solved or circumvented?

Here's how I do the export to Pandoc:

# config/initializers/action_controller.rb
require 'rack/test'
require 'action_controller'

Mime::Type.register 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', :docx

ActionController::Renderers.add :docx do |filename, options|
  # Converting works great except < and > are escaped in codes!
  # http://stackoverflow.com/questions/30916575/converting-markdown-to-docx-using-pandoc-and-signs-in-code-is-translated-to
  # https://github.com/alphabetum/pandoc-ruby/issues/14
  document = PandocRuby.convert render_to_string(options), to: :docx
  send_data document, filename:    "#{filename}.docx",
                      type:        Mime::DOCX,
                      disposition: 'attachment'
end

module ActionController
  # For respond_with default
  class Responder
    def to_docx
      if @default_response
        @default_response.call(options)
      else
        controller.render({ docx: controller.action_name }.merge(options))
      end
    end
  end
end

And here's my view that renders a markdown string:

... a lot of code
![<%= finding.class.human_attribute_name :screenshot %>](<%= finding.screenshot.url %>)
... a lot of code

As already pointed out, using some other place to get an image from works perfectly:

![<%= finding.class.human_attribute_name :screenshot %>](http://www.example.com/image.jpg)

It is not compatible with Pandoc's new way of adding/removing extensions

Calling: PandocRuby.new(content, :smart) will raise the following error:

--smart/-S has been removed.  Use +smart or -smart extension instead.
For example: pandoc -f markdown+smart -t markdown-smart.
Try pandoc --help for more information.
$ pandoc --version
pandoc 2.2.1
Compiled with pandoc-types 1.17.4.2, texmath 0.11, skylighting 0.7.1

multiple option 'epub-embed-font'

I wanted to add multiples fonts to a markdown -> epub convertion, according to pandoc document, I have to had severales times the same options (epub-embed-font) dynamically.

--epub-embed-font=FILE

Embed the specified font in the EPUB. This option can be repeated to embed multiple fonts.

(http://pandoc.org/README.html)

To perform that, I try to add and array like this:

[
{'epub-embed-font' => "font1.otf"},
{'epub-embed-font' => "font2.otf"}
]

But pandoc-ruby translate like this:

--{"epub-embed-font"=>"font1.otf"} {"epub-embed-font"=>"font2.otf"}

I don't know if there is a solution currently, so I'm thinking about change the 'convert' method but I prefer to ask before.

What do you think about it ?

DOCX to HTML

Is there any way to convert a docx file to a html or textile format. I know PANDOC can do it because i done it in Javascript.

However it is being a pain in Ruby. I do have pandoc-ruby in my gem file.
I saw in the pandoc-ruby documentation that you cannot convert docx to anything.

If pandoc-ruby is a wrapper for PANDOC, isn't there a way to convert docx to html. Because, again PANDOC can do it, but the wrapper, pandoc-ruby can't.

Any help would be nice and appreciated.

Improper handling of DOC file

Using pandoc directly I get this error when trying to convert a DOC file to HTML:

Pandoc can convert from DOCX, but not from DOC.
Try using Word to save your DOC file as DOCX, and convert that with pandoc.

Using pandoc-ruby I get this:

Errno::EPIPE: Broken pipe
from /usr/local/bundle/gems/pandoc-ruby-2.0.2/lib/pandoc-ruby.rb:209:in `write'

It would be handy to have a more detailed error to catch.

Outvar and context errors when used in Middleman (Patch included)

Related to #23, I took another approach, instead to remove extra options. I patched it on the fly in config.rb:

class ::PandocRuby
  module OptionPatch
    OPT_REMOVE_LIST = [:outvar, :context]

    # opts passed in. Recursively calls itself in order to handle hash options.
    def prepare_options(opts = [])
      opts.inject('') do |string, (option, value)|
        string + if value
                   create_option(option, value)
                 elsif option.respond_to?(:each_pair)
                   option = filter_option_hash(option)
                   prepare_options(option)

                 else
                   create_option(option)
                 end
      end
    end

    def filter_option_hash(hash)
      hash.reject do |k,v|
        OPT_REMOVE_LIST.include?(k)
      end
    end
  end
end

PandocRuby.prepend PandocRuby::OptionPatch

Basic error for new user

I'm trying to get pandoc-ruby to run the basic example provided in the documentation but am failing. Pandoc appears to be installed correctly and I have version 0.7.4 of pandoc-ruby. Any help appreciated.:

[dan ]$ pandoc --version
pandoc 1.9.4.1
...

irb(main):002:0> require 'rubygems'
=> true
irb(main):003:0> require 'pandoc-ruby'
=> true
irb(main):004:0> @converter = PandocRuby.new('# Markdown Title', :from => :markdown, :to => :rst)
=> #<PandocRuby:0x7f17d3dd88c0 @options=[{:to=>:rst, :from=>:markdown}], @target="# Markdown Title">
irb(main):005:0> puts @converter.convert
NoMethodError: undefined method length' for :to:Symbol from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:250:informat_flag'
from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:241:in create_option' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:225:inprepare_options'
from (irb):5:in inject' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:ineach'
from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in inject' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:inprepare_options'
from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:227:in prepare_options' from (irb):5:ininject'
from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in each' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:ininject'
from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:222:in prepare_options' from /usr/lib/ruby/gems/1.8/gems/pandoc-ruby-0.7.4/lib/pandoc-ruby.rb:131:inconvert'
from (irb):5
from �:0

Test suite failures

With the following GEM_PATH:
/gnu/store/8ql9jjzl8q291ghsxlkm1wn5bpdvgcqw-ruby-2.6.5/lib/ruby/vendor_ruby:/gnu/store/2cg77jha3hq8s497kr6g88q5mrba70sq-ruby-mocha-1.11.2/lib/ruby/vendor_ruby

And with ghc-pandoc 2.7.3, I get the following test suite failures:

starting phase `check'
/gnu/store/8ql9jjzl8q291ghsxlkm1wn5bpdvgcqw-ruby-2.6.5/bin/ruby -w -I"lib:lib:test" -I"/gnu/store/8ql9jjzl8q291ghsxlkm1wn5bpdvgcqw-ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib" "/gnu/store/8ql9jjzl8q291ghsxlkm1wn5bpdvgcqw-ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/rake_test_loader.rb" "test/test_conversions.rb" "test/test_pandoc_ruby.rb" 
Run options: --seed 2995

# Running:

F...................................S..................................................................................................F........................F..........F.F.......FF...F.......F......

Finished in 8.310657s, 24.1858 runs/s, 37.4218 assertions/s.

  1) Failure:
PandocRuby#test_0011_converts underscore symbol args to hyphenated long options [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/lib/pandoc-ruby.rb:253]:
unexpected invocation: #<PandocRuby:0xd36008>.execute("/gnu/store/qdqjmpbkk9majih7vws4avlwjz29ss1c-ghc-pandoc-2.7.3/bin/pandoc --email-obfuscation javascript --table-of-contents")
unsatisfied expectations:
- expected exactly once, invoked never: #<PandocRuby:0xd36008>.execute("pandoc --email-obfuscation javascript --table-of-contents")


  2) Failure:
Conversions#test_0073_converts latex to plain [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/test/test_conversions.rb:26]:
--- expected
+++ actual
@@ -1,4 +1,3 @@
-"THIS IS A TITLE
+"This is a Title
 
-
-Some _emphasized text_ and a link"
+Some emphasized text and a link"


  3) Failure:
Conversions#test_0013_converts markdown to plain [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/test/test_conversions.rb:26]:
--- expected
+++ actual
@@ -1,4 +1,3 @@
-"THIS IS A TITLE
+"This is a Title
 
-
-Some _emphasized text_ and a link"
+Some emphasized text and a link"


  4) Failure:
Conversions#test_0022_converts html to beamer [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/test/test_conversions.rb:26]:
--- expected
+++ actual
@@ -1,7 +1,5 @@
 "\\begin{frame}{This is a Title}
 \\protect\\hypertarget{this-is-a-title}{}
-
 Some \\emph{emphasized text} and
 \\href{http://daringfireball.net/projects/markdown/}{a link}
-
 \\end{frame}"


  5) Failure:
Conversions#test_0002_converts markdown to beamer [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/test/test_conversions.rb:26]:
--- expected
+++ actual
@@ -1,7 +1,5 @@
 "\\begin{frame}{This is a Title}
 \\protect\\hypertarget{this-is-a-title}{}
-
 Some \\emph{emphasized text} and
 \\href{http://daringfireball.net/projects/markdown/}{a link}
-
 \\end{frame}"


  6) Failure:
Conversions#test_0062_converts latex to beamer [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/test/test_conversions.rb:26]:
--- expected
+++ actual
@@ -1,7 +1,5 @@
 "\\begin{frame}{This is a Title}
 \\protect\\hypertarget{this-is-a-title}{}
-
 Some \\emph{emphasized text} and
 \\href{http://daringfireball.net/projects/markdown/}{a link}
-
 \\end{frame}"


  7) Failure:
Conversions#test_0033_converts html to plain [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/test/test_conversions.rb:26]:
--- expected
+++ actual
@@ -1,4 +1,3 @@
-"THIS IS A TITLE
+"This is a Title
 
-
-Some _emphasized text_ and a link"
+Some emphasized text and a link"


  8) Failure:
Conversions#test_0053_converts rst to plain [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/test/test_conversions.rb:26]:
--- expected
+++ actual
@@ -1,4 +1,3 @@
-"THIS IS A TITLE
+"This is a Title
 
-
-Some _emphasized text_ and a link"
+Some emphasized text and a link"


  9) Failure:
Conversions#test_0042_converts rst to beamer [/tmp/guix-build-ruby-pandoc-ruby-2.1.4.drv-0/source/test/test_conversions.rb:26]:
--- expected
+++ actual
@@ -1,7 +1,5 @@
 "\\begin{frame}{This is a Title}
 \\protect\\hypertarget{this-is-a-title}{}
-
 Some \\emph{emphasized text} and
 \\href{http://daringfireball.net/projects/markdown/}{a link}
-
 \\end{frame}"


201 runs, 311 assertions, 9 failures, 0 errors, 1 skips

You have skipped tests. Run with --verbose for details.
rake aborted!
Command failed with status (1): [ruby -w -I"lib:lib:test" -I"/gnu/store/8ql9jjzl8q291ghsxlkm1wn5bpdvgcqw-ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib" "/gnu/store/8ql9jjzl8q291ghsxlkm1wn5bpdvgcqw-ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/rake_test_loader.rb" "test/test_conversions.rb" "test/test_pandoc_ruby.rb" ]

Tasks: TOP => test
(See full trace by running task with --trace)
command "rake" "test" failed with status 1

pandoc ruby in ubuntu with jruby - nothing coming out

Hi,.

I am running jruby jruby 1.6.5 (ruby-1.9.2-p136) (2011-10-25 9dcd388) (OpenJDK Client VM 1.6.0_23) [linux-i386-java]

in

Linux vagrant-ubuntu-11 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:50:54 UTC 2012 i686 i686 i386 GNU/Linux

with pandoc-ruby (0.4.1) and pandoc 1.8.1.1

If I make a file tester1.txt with the text # Markdown Title in it
and run pandoc -o output.html tester1.txt
it gives me

Markdown Title

If I do the following script

!/usr/bin/env ruby

require 'pandoc-ruby'
puts "#######################################################"
@converter = PandocRuby.new('# Markdown Title', :from => :markdown, :to => :html)
puts @converter.convert
puts @converter.convert.inspect
puts "########################################################"

I get

""

Now the big reveal here is - none of the versions info previously given here should be affecting this because everyone has here has the same versions of things and their stuff works fine (we actually use pandoc ruby in rails to convert to rtf, and for everyone else they get correct rtf files while I get 0 bytes output...)

So anyone can think of any possible side effect that would be causing this on my system?

the pandoc-ruby with sinatra is not work

the pandoc-ruby with sinatra is not work in my environment.
How can this problem be solved or circumvented?

sinatra's error

[root@kimura test_app]# ruby app.rb
[2016-11-08 14:11:06] INFO  WEBrick 1.3.1
[2016-11-08 14:11:06] INFO  ruby 2.3.0 (2015-12-25) [x86_64-linux]
== Sinatra (v1.4.7) has taken the stage on 4567 for production with backup from WEBrick
[2016-11-08 14:11:06] INFO  WEBrick::HTTPServer#start: pid=25402 port=4567
2016-11-08 14:11:10 - Errno::ENOENT - No such file or directory - pandoc:
        /root/.rbenv/versions/2.3.0/lib/ruby/2.3.0/open3.rb:199:in `spawn'
        /root/.rbenv/versions/2.3.0/lib/ruby/2.3.0/open3.rb:199:in `popen_run'
        /root/.rbenv/versions/2.3.0/lib/ruby/2.3.0/open3.rb:95:in `popen3'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pandoc-ruby-2.0.1/lib/pandoc-ruby.rb:206:in `execute'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pandoc-ruby-2.0.1/lib/pandoc-ruby.rb:198:in `execute_pandoc'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pandoc-ruby-2.0.1/lib/pandoc-ruby.rb:190:in `convert_string'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pandoc-ruby-2.0.1/lib/pandoc-ruby.rb:132:in `convert'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/pandoc-ruby-2.0.1/lib/pandoc-ruby.rb:166:in `block (2 levels) in <class:PandocRuby>'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/tilt-2.0.5/lib/tilt/pandoc.rb:42:in `evaluate'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/tilt-2.0.5/lib/tilt/template.rb:102:in `render'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:823:in `render'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:710:in `markdown'
        app.rb:25:in `block in <main>'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1611:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1611:in `block in compile!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (3 levels) in route!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:994:in `route_eval'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (2 levels) in route!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1015:in `block in process_route'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1013:in `catch'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1013:in `process_route'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:973:in `block in route!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:972:in `each'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:972:in `route!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1085:in `block in dispatch!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `block in invoke'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `catch'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `invoke'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1082:in `dispatch!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:907:in `block in call!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `block in invoke'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `catch'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `invoke'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:907:in `call!'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:895:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/logger.rb:15:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/commonlogger.rb:33:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:219:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:212:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:182:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:2013:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1487:in `block in call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1787:in `synchronize'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1487:in `call'
        /root/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service'
        /root/.rbenv/versions/2.3.0/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
        /root/.rbenv/versions/2.3.0/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
        /root/.rbenv/versions/2.3.0/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'
172.16.50.20 - - [08/Nov/2016:14:11:10 +0900] "GET /markdown_template_page HTTP/1.1" 500 30 0.0103
172.16.50.20 - - [08/Nov/2016:14:11:10 JST] "GET /markdown_template_page HTTP/1.1" 500 30
- -> /markdown_template_page

app versions

pandoc 1.17.2
pandoc-ruby (2.0.1)
ruby 2.3.0p0
sinatra (1.4.7)
gem 2.5.1

gem lists

backports (3.6.8)
bigdecimal (1.2.8, 1.2.7)
bundle (0.0.1)
bundler (1.13.6)
did_you_mean (1.0.2, 1.0.0)
io-console (0.4.6, 0.4.5)
json (2.0.2, 1.8.3)
mail (2.6.4)
mime-types (3.1)
mime-types-data (3.2016.0521)
minitest (5.9.1, 5.8.3)
multi_json (1.12.1)
net-telnet (0.1.1)
pandoc-ruby (2.0.1, 1.0.0)
power_assert (0.3.1, 0.2.6)
psych (2.1.1, 2.0.17)
rack (2.0.1, 1.6.4)
rack-protection (1.5.3)
rack-test (0.6.3)
rake (11.3.0, 10.4.2)
rdoc (5.0.0, 4.2.1)
redcarpet (3.3.4)
rubygems-update (2.6.8)
sinatra (1.4.7)
sinatra-contrib (1.4.7)
sinatra-reloader (1.0)
test-unit (3.2.2, 3.1.5)
tilt (2.0.5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.