Powerful Command-Line Applications in Go: blackfriday Library Not Working? (pp. 50, 52)

@rgerardi

Problem

As I am working my way through the book today in August of 2024, it appears that blackfriday (v2.1.0) no longer works. In particular, even configuring it explicitly with the common set of extensions, it does not produce an HTML list from either a bulleted or numbered markdown list.

Case in point, given the content of test1.md (p. 52):

# Test Markdown File

Just a test

## Bullets:

* Links [Link1](https://example.com)

## Code Block

```
some code
```

… it renders the Bullets section of the markdown this way:

<h2>Bullets:
</h2>

<p>
* Links <a href="https://example.com" rel="nofollow">Link1</a>

</p>

… when it should be something more like this:

<h2>Bullets:
</h2>

<ol>
<li>Links <a href="https://example.com" rel="nofollow">Link1</a></li>
</ol>

Solution

I have replaced blackfriday with markdown (v0.0.0-20240730141124-034f12af3bf6 as of this writing), and it is working like a charm. It requires just a one-line change to the parseContent function (p. 50):

# output := blackfriday.Run(input) # replace with the line below
output := markdown.ToHTML(input, nil, nil)

It produces the expected output:

<h2>Bullets:</h2>

<ul>
<li>Links <a href="https://example.com" rel="nofollow">Link1</a></li>
</ul>