Jekyll Kramdown code in ordered list - number reset
Asked Answered
R

2

7

I have the following code which resets the numbered list after adding a liquid code block:

...
6. Install the Ruby Google API client with `gem install google-api-client`, or if you prefer in a Gemfile:
    {% highlight ruby lineanchors %}
    source 'https://rubygems.org'
    gem 'google-api-client', '~> 0.9.1'
    {% endhighlight %}
(If you've never used [Bundler](http://bundler.io) before, you should start!)

7. Let's get a quick script set up to post a Google Calendar event to...

The problem is that the following renders as:


fail


The ordered list is reset, which is obviously a problem. I've looked at many posts that detail the markdown ordered list reset problem but none of them discuss liquid tags. I found another post here discussing the issue to no avail.

Here is the HTML output just in case it is necessary. The <ol> tag is clearly being broken by a <div> element produced by the liquid tag engine... and I don't know how to embed the pre block in the <ol> block...

<ol>
  ...
  <li>Install the Ruby Google API client with <code>gem install google-api-client</code>, or if you prefer in a Gemfile:</li>
</ol>
<div class="highlight"><pre><code class="language-ruby" data-lang="ruby"><a name="True-1"></a><span class="n">source</span> <span class="s1">'https://rubygems.org'</span>
<a name="True-2"></a><span class="n">gem</span> <span class="s1">'google-api-client'</span><span class="p">,</span> <span class="s1">'~&gt; 0.9.1'</span></code></pre></div>
<p>(If you’ve never used <a href="http://bundler.io">Bundler</a> before, you should start!)</p>
<ol>
  <li>Let’s get a quick script set up to post a Google Calendar event to</li>
  <li>Let’s get a quick script set up to post a Google Calendar event to</li>
</ol>

I want to be able to put a liquid tag in an ordered list without it breaking the <ol> HTML element and resetting the numbering. Is there a way to do this?

Romanaromanas answered 8/3, 2016 at 4:0 Comment(3)
You're out of luck. github.com/jekyll/jekyll/issues/588Illustration
Some imperfect workarounds: #17995967Illustration
Do you leave a space before and after the number?Confabulate
D
10

For those with this issue, adding extra info in front of the next number helped me.

6. Install the Ruby Google API client with `gem install google-api-client`, or if you prefer in a Gemfile:
    {% highlight ruby lineanchors %}
    source 'https://rubygems.org'
    gem 'google-api-client', '~> 0.9.1'
    {% endhighlight %}
(If you've never used [Bundler](http://bundler.io) before, you should start!)

{:start="7"}
7. Let's get a quick 
Diazotize answered 29/1, 2017 at 4:37 Comment(3)
This solution worked! It's kind of annoying to have to do, but it gets the job done. Thanks for your answer!Romanaromanas
The problem with this is that "(If you've never..." is not indented.Hemphill
That problem can be fixed like this: {:style="list-style-type: none;"} 100. (If you've...Hemphill
C
0
6. Install the Ruby Google API client with `gem install google-api-client`, or if you prefer in a Gemfile:
    {% highlight ruby lineanchors %}
    source 'https://rubygems.org'
    gem 'google-api-client', '~> 0.9.1'
    {% endhighlight %}

    (If you've never used [Bundler](http://bundler.io) before, you should start!)

7. Let's get a quick 

As @Joshua Meyers Suggests in the comments, the problem is in the last line. If you indent the line "(If you've never used Bundler before, you should start!)" the list numbers will continue.

Confabulate answered 11/7, 2020 at 23:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.