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

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

Open
joallard opened this issue Jun 29, 2020 · 2 comments
Open

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

joallard opened this issue Jun 29, 2020 · 2 comments

Comments

@joallard
Copy link

joallard commented Jun 29, 2020

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
@xwmx
Copy link
Owner

xwmx commented Jul 2, 2020

Hi @joallard! Thanks for this. I'm looking into all of this to try to understand the scope of the issue.

@joallard
Copy link
Author

joallard commented Jul 2, 2020

To help with repro:

On a tight scope:

Whenever options includes "outvar" or "context", exception.

On a wide scope:

Given a Middleman app, a source/document.md file, and in config.rb: set :markdown_engine, :pandoc
When I visit /document.html
Then I get the exception

(Maybe an allow list would fit better, I'm not sure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants