Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pandoc support #1533

Merged
merged 2 commits into from
Aug 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add pandoc support
Here I try to fix an another warning from tests.
```
cannot load such file -- pandoc-ruby: skipping markdown tests with
Tilt::PandocTemplate
```

`pandoc-ruby` is not defined in Gemfile, so I add it there.
This gem has a prerequisite dependency `pandoc` application that can be
installed via homebrew. That's why I update travis.yml to make it
available during a test run.

The final step to make it work is to exclude `outvar` from the option's
list provided to the template. When `pandoc` application is called
with unsupported parameters it stops the execution and returns an
error.
  • Loading branch information
304 committed Jun 25, 2019
commit c1743256b4a8773eec774f3e3cf00a7c7352a9b3
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ addons:
- ubuntu-toolchain-r-test
packages:
- g++-4.8

- pandoc
rvm:
- 2.2.10
- 2.3.8
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ if RUBY_ENGINE == "ruby"
gem 'reel-rack'
gem 'celluloid', '~> 0.16.0'
gem 'commonmarker', '~> 0.20.0'
gem 'pandoc-ruby', '~> 2.0.2'
gem 'simplecov', require: false
end

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ template, you almost always want to pass locals to it.
<a href="https://github.com/ged/bluecloth" title="BlueCloth">BlueCloth</a>,
<a href="https://kramdown.gettalong.org/" title="kramdown">kramdown</a>,
<a href="https://github.com/bhollis/maruku" title="maruku">maruku</a>
<a href="https://github.com/gjtorikian/commonmarker" title="commonmarker">commonmarker</a>
<a href="https://github.com/alphabetum/pandoc-ruby" title="pandoc">pandoc</a>
</td>
</tr>
<tr>
Expand Down
4 changes: 3 additions & 1 deletion lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ def liquid(template, options = {}, locals = {}, &block)
end

def markdown(template, options = {}, locals = {})
options[:default_outvar] = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_outvar makes me confusing a bit. How about exclude_outvar ?

render :markdown, template, options, locals
end

Expand Down Expand Up @@ -818,10 +819,11 @@ def render(engine, data, options = {}, locals = {}, &block)
content_type = options.delete(:content_type) || content_type
layout_engine = options.delete(:layout_engine) || engine
scope = options.delete(:scope) || self
default_outvar = options.delete(:default_outvar) != false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this expression. I would like to use the value directly.

options.delete(:layout)

# set some defaults
options[:outvar] ||= '@_out_buf'
options[:outvar] ||= '@_out_buf' if default_outvar
options[:default_encoding] ||= settings.default_encoding

# compile and render template
Expand Down