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

Redcarpet HTML_TOC renderer initialization error #222

Closed
chiarello opened this issue Feb 14, 2013 · 4 comments
Closed

Redcarpet HTML_TOC renderer initialization error #222

chiarello opened this issue Feb 14, 2013 · 4 comments

Comments

@chiarello
Copy link

The initialization of the HTML_TOC renderer in Redcarpet is wrong. It halts with the following error:

ArgumentError: wrong number of arguments(1 for 0)

The problem comes from the following line in redcarpet.rb

renderer = renderer_class.new(renderer_options)
 ::Redcarpet::Markdown.new(renderer, options).render(content)

It seems that the render ::Redcarpet::Render::HTML_TOC doesn't accept parameters, maybe it's a bug of the redcarpet library. The following code temporarily solves the problem:

if renderer_class == ::Redcarpet::Render::HTML_TOC
  renderer = renderer_class.new
else
  renderer = renderer_class.new(renderer_options)
end
::Redcarpet::Markdown.new(renderer, options).render(content)
@denisdefreyne
Copy link
Member

Would #200 be what you are looking for? From what I can tell, that pull request would solve your problems, am I right?

@chiarello
Copy link
Author

Not really. That patch constrains you to have the toc flowing togheter with the html. For instance, I'm using the HTML and HTML_TOC to build the page and its toc into different reps.
The solution presented in #200 is good, but it doesn't allow you to perform only the HTML_TOC pass alone.

@denisdefreyne
Copy link
Member

Ah yes… it is odd that the HTML_TOC does not accept any options, unlike other renderers. I’d suggest opening a ticket on the Redcarpet 2 issue tracker and ask them to resolve the inconsistency. I’ll change the nanoc filters so that it can handle HTML_TOC nicely.

@denisdefreyne
Copy link
Member

Fixed in #232!

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

No branches or pull requests

2 participants