-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add pandoc support #1533
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly lgtm, with a few nits.
lib/sinatra/base.rb
Outdated
@@ -722,6 +722,7 @@ def liquid(template, options = {}, locals = {}, &block) | |||
end | |||
|
|||
def markdown(template, options = {}, locals = {}) | |||
options[:default_outvar] = false |
There was a problem hiding this comment.
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
?
lib/sinatra/base.rb
Outdated
@@ -825,10 +826,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 |
There was a problem hiding this comment.
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.
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.
@namusyaka, I've made changes according to your suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response. But LGTM.
While reviewing this, I found a bug around bluecloth. So I sent a patch for it: ged/bluecloth#1
However, we don't need to wait the progress for the patch. Our next patch version will contain this change.
Thanks so much for your contribution.
Update ruby-sinatra to 2.0.8.1. ## 2.0.8.1 / 2020-01-02 * Allow multiple hashes to be passed in `merge` and `merge!` for `Sinatra::IndifferentHash` [#1572](sinatra/sinatra#1572) by Shota Iguchi ## 2.0.8 / 2020-01-01 * Lookup Tilt class for template engine without loading files [#1558](sinatra/sinatra#1558). Fixes [#1172](sinatra/sinatra#1172) by Jordan Owens * Add request info in NotFound exception [#1566](sinatra/sinatra#1566) by Stefan Sundin * Add `.yaml` support in `Sinatra::Contrib::ConfigFile` [#1564](sinatra/sinatra#1564). Fixes [#1563](sinatra/sinatra#1563) by Emerson Manabu Araki * Remove only routing parameters from @params hash [#1569](sinatra/sinatra#1569). Fixes [#1567](sinatra/sinatra#1567) by Jordan Owens, Horacio * Support `capture` and `content_for` with Hamlit [#1580](sinatra/sinatra#1580) by Takashi Kokubun * Eliminate warnings of keyword parameter for Ruby 2.7.0 [#1581](sinatra/sinatra#1581) by Osamtimizer ## 2.0.7 / 2019-08-22 * Fix a regression [#1560](sinatra/sinatra#1560) by Kunpei Sakai ## 2.0.6 / 2019-08-21 * Fix an issue setting environment from command line option [#1547](sinatra/sinatra#1547), [#1554](sinatra/sinatra#1554) by Jordan Owens, Kunpei Sakai * Support pandoc as a new markdown renderer [#1533](sinatra/sinatra#1533) by Vasiliy * Remove outdated code for tilt 1.x [#1532](sinatra/sinatra#1532) by Vasiliy * Remove an extra logic for `force_encoding` [#1527](sinatra/sinatra#1527) by Jordan Owens * Avoid multiple errors even if `params` contains special values [#1526](sinatra/sinatra#1527) by Kunpei Sakai * Support `bundler/inline` with `require 'sinatra'` integration [#1520](sinatra/sinatra#1520) by Kunpei Sakai * Avoid `TypeError` when params contain a key without a value on Ruby < 2.4 [#1516](sinatra/sinatra#1516) by Samuel Giddins * Improve development support and documentation and source code by Olle Jonsson, Basavanagowda Kanur, Yuki MINAMIYA
Here I try to fix an another warning from tests.
pandoc-ruby
is not defined in Gemfile, so I add it there. This gem has a prerequisite dependencypandoc
(a CLI application) that can be installed via apt. 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. Whenpandoc
application is called with unsupported parameters it stops the execution and returns an error.I'm not really sure why
outvar
parameter is defined by default and what it supposed to do. It seems that it was used before by several templates engines, but looks like it is not supported by all of them. I managed to find a old commit that introduces it f8e0a34.I've added a setting to exclude and disable it for markdown engines, but I have doubts if it is a safe option. What do you think?