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

Syntax highlighting example in Readme not working #186

Closed
bradly opened this issue Mar 13, 2015 · 1 comment
Closed

Syntax highlighting example in Readme not working #186

bradly opened this issue Mar 13, 2015 · 1 comment

Comments

@bradly
Copy link
Contributor

bradly commented Mar 13, 2015

Hello,

I'm trying to get syntax highlighting working, but I'm having trouble.

Here is my irb output:

› irb
>> require 'html/pipeline'
=> true
>> require 'linguist'
=> true
>> require 'pygments'
=> false
>> pipeline = HTML::Pipeline.new [
?>       HTML::Pipeline::MarkdownFilter,
?>       HTML::Pipeline::SyntaxHighlightFilter
>>   ]
=> #<HTML::Pipeline:0x007f872b1a7d40 @filters=[HTML::Pipeline::MarkdownFilter, HTML::Pipeline::SyntaxHighlightFilter], @default_context={}, @result_class=Hash, @instrumentation_service=nil>
>> result = pipeline.call <<-CODE
This is *great*:

    some_code(:first)

CODE
=> {:output=>#<Nokogiri::HTML::DocumentFragment:0x3fc3958db18c name="#document-fragment" children=[#<Nokogiri::XML::Element:0x3fc3958dae1c name="p" children=[#<Nokogiri::XML::Text:0x3fc3958dff84 "This is ">, #<Nokogiri::XML::Element:0x3fc3958dfe94 name="em" children=[#<Nokogiri::XML::Text:0x3fc3958dfc00 "great">]>, #<Nokogiri::XML::Text:0x3fc3958dfa48 ":">]>, #<Nokogiri::XML::Text:0x3fc3958dada4 "\n\n">, #<Nokogiri::XML::Element:0x3fc3958dad2c name="pre" children=[#<Nokogiri::XML::Element:0x3fc3958df520 name="code" children=[#<Nokogiri::XML::Text:0x3fc3958df28c "some_code(:first)\n">]>]>]>}
>> result[:output].to_s
=> "<p>This is <em>great</em>:</p>\n\n<pre><code>some_code(:first)\n</code></pre>"

The Readme says this should output:

<p>This is <em>great</em>:</p>

<div class="highlight">
<pre><span class="n">some_code</span><span class="p">(</span><span class="ss">:first</span><span class="p">)</span>
</pre>
</div>

This is probably me just not understanding how this works, but I can't figure it out. Any help would be greatly appreciated. Thanks!

Ruby version: 2.0.0
html-pipeline version: 1.9.0
github/linguist version: 2.10.15
pygments.rb version: 0.6.0

@JuanitoFatas
Copy link
Contributor

Hello @bradly!

Your setup is working. Just the example in README.md is stale. I am going to update it.

When you use fenced code blocks and specify a language then you will have a <div> with class of highlight and many span elements wrap your code.

Thanks for reporting! 😊

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