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 all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
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
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
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
Expand Up @@ -722,6 +722,7 @@ def liquid(template, options = {}, locals = {}, &block)
end

def markdown(template, options = {}, locals = {})
options[:exclude_outvar] = true
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
exclude_outvar = options.delete(:exclude_outvar)
options.delete(:layout)

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

# compile and render template
Expand Down