bradleyscollins

bradleyscollins

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>

First Post!

LeamHall

LeamHall

Hey @bradleyscollins ! I just did this run this morning and blackfriday worked find for me. The “links” was marked up nicely.

Here’s the line from my go.mod file, if it helps diagnose the issue:

http://github.com/russross/blackfriday/v2  //indirect

Where Next?

Popular Pragmatic Bookshelf topics Top

jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
jimschubert
In Chapter 3, the source for index introduces Config on page 31, followed by more code including tests; Config isn’t introduced until pag...
New
jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
jgchristopher
“The ProductLive.Index template calls a helper function, live_component/3, that in turn calls on the modal component. ” Excerpt From: Br...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
dsmith42
Hey there, I’m enjoying this book and have learned a few things alredayd. However, in Chapter 4 I believe we are meant to see the “&gt;...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
axelson
I’ve been really enjoying obsidian.md: It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New

Sub Categories: