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>

Popular Prag Prog topics Top

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
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=&gt; (create-...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
tkhobbes
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
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
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
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
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
AstonJ
This is cool! DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON We just witnessed something incredible: the largest open-s...
New

Latest in PragProg

View all threads ❯