I'm using Markdown with Liquid tags to mark up some code for a Jekyll-generated site and would like to include some code that is both in-line (in a paragraph) and has coloured syntax (with Pygments), but it does not appear to work.
The markup
Lorem ipsum dolor {% highlight javascript %} var sit = "amet"; {% endhighlight %} consectetur adipiscing elit.
results in
<p>Lorem ipsum dolor <div class='highlight'><pre><code class='javascript'> <span class='kd'>var</span> <span class='nx'>sit</span> <span class='o'>=</span> <span class='s2'>"amet"</span><span class='p'>;</span></code></pre></div> consectetur adipiscing elit.</p>
I would very much like highlighted text not be wrapped in <div class='highlight'>
, or at least have it be a <span class='highlight'>
.
Using {% highlight javascript nowrap %}
does not work, as suggested elsewhere. (Perhaps this is an issue with my setup—which is Ruby 2.0, Jekyll 0.12.1, pygments.rb 0.3.7?)
I would like to host this page on GitHub, which means I cannot rely on a plugin. Bummer, right?
Addendum: Line numbering (ie. {% highlight javascript linenos %}
) does not appear to work either. Man.
The easiest way to do this is to use Github Flavoured Markdown and use their default inline code.
in your _config.yml
file, change your markdown to redcarpet. You're now ready to go with GFM.
markdown: redcarpet
Now you can follow all the GitHub Markdown. To do inline code as follow:
Here is some `inline code` in the middle of sencence
You can add a CSS class to any object you put in a post.
If you define a CSS entry like this:
.inlined { display:inline; }
You can then add this class to the generated <div>
doing this:
Lorem ipsum dolor
{% highlight javascript %}var sit="amet"; {% endhighlight %}{: .inlined }
consectetur adipiscing elit.
This works with all kind of objects (tables, images, etc). I can not test it right now, but I think this will solve the issue.
When you test it, look at the output HTML. You will then find that your <div>
now has the class=inlined
attribute set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With