How can I put a Liquid tag highlight in an ordered list?

前端 未结 2 1274
天涯浪人
天涯浪人 2021-01-07 10:57

This is what I want the page to be:

  1. first
  2. second
相关标签:
2条回答
  • 2021-01-07 11:39

    I haven't been able to figure out how to use the "Pygments" highlighting for code blocks inside of lists. It is possible to do a basic code block without highlighting with the following:

    1. first
    2. second
    
            code here
    
    3. third
    

    The white space placement here is important. The way that snippet of code works, there is a a blank line between 2. second and the code here line. Additionally, there are two tabs before the code here text (Eight spaces should also work).

    The output from the above using jekyll 1.0.3 with markdown: kramdown set in the _config.yml file produces:

    <ol>
      <li>first</li>
      <li>
        <p>second</p>
    
        <pre><code> code here
    </code></pre>
      </li>
      <li>third</li>
    </ol> 
    
    0 讨论(0)
  • 2021-01-07 11:40

    I figured out a way:

    1. first
    2. second
     : {% highlight ruby %}
    code
    code
    code
    {% endhighlight %}
    3. third
    

    This renders as a definition list though (<dt> and <dd> tags) which is probably technically incorrect use of that markup so if you're super strict about that kind of thing you might not like it, but I haven't been able to find another way without writing your own plugin to generate lists which will completely change the way you write them.

    0 讨论(0)
提交回复
热议问题