hugo: Code blocks not rendered correctly in lists

This markdown:

- Hello<br>
  bla bla
- Example<br>
  ```javascript
  var message = 'hello';
  console.log(message);
  ```

The <br> is also needed in Hugo for a line break in the list item, which differs from other generators.

Renders as:

  • Hello bla bla
  • Example javascript var message = 'hello'; console.log(message);

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Did the update from BlackFriday ever get merged into Hugo? I’m still seeing weird code-block stuff.

Screen Shot 2019-05-28 at 12 55 07 PM

Here’s my Markdown for the image above:

#### Run the Installation

1. Connect to your machine via SSH or open a terminal if you are working on a local installation.
2. Change to your root `~` directory and update your system:

    ```bash
    cd ~
    sudo apt update -y && sudo apt upgrade -y
    ```

3. Download the latest [package](https://github.com/exampleproject/releases) to your computer if you haven't already. You can also use `wget` if you'd prefer:

    ```bash
    wget https://github.com/exampleproject/release.tar.bz2
    ```

4. Unzip the package and move the directory to your home `~` directory:

I see. If you put a newline after the code block but not before it, the numbering is maintained.

If you put an empty line before the code block as well as after, the numbering is not maintained. I don’t know if that is expected behavior, but it is certainly surprising to me.

The hack mentioned above breaks the ordering in an ordered list, so it doesn’t really work.

??

Works fine for me: image


HTML

	<ol>
		<li>
			<p>awk</p>
			<div class="highlight">
				<pre><code class="language-sh" data-lang="sh"><span></span><span class="nb">pwd</span> <span class="p">|</span> awk -F/ <span class="s1">&#39;{print $NF}&#39;</span>
</code></pre>
			</div>
		</li>
		<li>
			<p>rev and cut</p>
			<div class="highlight">
				<pre><code class="language-sh" data-lang="sh"><span></span><span class="nb">pwd</span> <span class="p">|</span> rev <span class="p">|</span> cut -d/ -f <span class="m">1</span> <span class="p">|</span> rev
</code></pre>
			</div>
		</li>
		<li>
			<p>basename</p>
			<div class="highlight">
				<pre><code class="language-sh" data-lang="sh"><span></span>basename <span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>
</code></pre>
			</div>
		</li>
	</ol>