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

Code blocks not rendered correctly in lists #2928

Closed
mobenar opened this issue Jan 11, 2017 · 16 comments
Closed

Code blocks not rendered correctly in lists #2928

mobenar opened this issue Jan 11, 2017 · 16 comments

Comments

@mobenar
Copy link

mobenar commented Jan 11, 2017

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);
@bep
Copy link
Member

bep commented Jan 11, 2017

Assuming you use Blackfriday, please post an issue here:

https://github.com/russross/blackfriday/issues

And link back to this issue.

@mobenar
Copy link
Author

mobenar commented Jan 11, 2017

@bep
Copy link
Member

bep commented Jan 11, 2017

You should post the entire description on the BF issue, not just a link back here.

@kaushalmodi
Copy link
Contributor

kaushalmodi commented Jan 11, 2017

This works

- Hello<br>
bla bla

- Example<br>
```javascript
var message = 'hello';
console.log(message);
\``` (remove that leading \ and this comment)

- Hello again!

Simply put an extra newline between each list item. I do not know if this is a hack, or if this is how it supposed to be done. But I have learned doing that by trial and error :)

https://scripter.co/get-current-directory-name-without-path/

@maueroats
Copy link

Reported a similar/same issue. The hack mentioned above breaks the ordering in an ordered list, so it doesn't really work. Linked issue includes a demo markdown file and says specifically what is wrong in the generated HTML.

russross/blackfriday#392

@kaushalmodi
Copy link
Contributor

kaushalmodi commented Sep 21, 2017

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>

@maueroats
Copy link

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.

@stale
Copy link

stale bot commented Jan 19, 2018

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the Stale label Jan 19, 2018
@kaushalmodi
Copy link
Contributor

I believe this issue can be closed as hugo itself has little to do with it. But the Blackfriday repo issue handling and maintenance is in a sad state .. there has been no activity on the issues posted related to this current issue: russross/blackfriday#326, russross/blackfriday#239, and also in general (I have noticed that for quite a few months)! 😞

@stale stale bot removed the Stale label Jan 19, 2018
@maueroats
Copy link

Workaround I currently use: 8 space indentation to get the code block. {{< highlight ... >}} to get syntax highlighting if I want it that badly.

Close it for hugo.

@aignas
Copy link

aignas commented Feb 11, 2019

This has been fixed recently in russross/blackfriday#476 and russross/blackfriday#521. It would be great to update the blackfriday dependence to include these fixes.

@johnnymatthews
Copy link

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:

@zilongshanren
Copy link

I'm also face this issue, it seems be fixed in the blackfriday, but in hugo this issue still exists.

arvindsv added a commit to arvindsv/docs.go.cd that referenced this issue Jun 17, 2019
@thomask
Copy link

thomask commented Jul 15, 2019

Yup, same issue here

@jmooring
Copy link
Member

No longer reproducible with v0.82 using default markdown renderer (Goldmark).

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants