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

HTML_TOC fails when encountering '#' as comment start flag within code blocks #451

Comments

@brxue
Copy link

brxue commented Jan 17, 2015

Hi,

I'm trying to use HTML_TOC as a render to generate TOC.

Looks like it will regard the fake '#' as headers when it is within code blocks. for example, "make some nice lexed html" in the following code pieces will be rendered as header.

# make some nice lexed html
source = File.read('/etc/bashrc')
formatter = Rouge::Formatters::HTML.new(css_class: 'highlight')
lexer = Rouge::Lexers::Shell.new
formatter.format(lexer.lex(source))

# Get some CSS
Rouge::Themes::Base16.mode(:light).render(scope: '.highlight')
# Or use Theme#find with string input
Rouge::Theme.find('base16.light').render(scope: '.highlight')
@robin850 robin850 added the bug label Jan 24, 2015
@robin850 robin850 removed the bug label Mar 3, 2015
@robin850
Copy link
Collaborator

robin850 commented Mar 3, 2015

Hi @brxue,

Actually this is something that may not seem obvious but when you're instantiating Redcarpet::Markdown with a HTML_TOC render object, you need to pass the fenced_code_blocks option as well. Unfortunately we can't really enable this by default as the render object and the Markdown one are kind of independent each other. I'm giving it a close but thanks for reporting anyway!

@robin850 robin850 closed this as completed Mar 3, 2015
@brxue
Copy link
Author

brxue commented Mar 28, 2015

Thanks robin850! It solved my problem!

@born4new
Copy link

We encountered the same problem....Do you think it would be worth mentioning it in the README? I believe it could help other people...

robin850 added a commit that referenced this issue Jan 28, 2017
Since some languages rely on the sharp to comment code, the output
may be unexpected as titles begin with a sharp in Markdown.

Refs #451.
@robin850
Copy link
Collaborator

@born4new : Actually the solution was fairly easy, we just need to enable the option by default passing a HTML_TOC object. This will be enabled by default in the next version of Redcarpet, thank you very much for the heads up ! 😀

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