How is the Hugo Doc site showing shortcodes in code blocks?

Note to self: Magic phrase: “Thx, done:” :stuck_out_tongue:

1 Like

No, that will not generally work.

But the feature request is in an area where it is easy to change stuff.

I rewrote the shortcode handling many moons ago. The original version was a big set of tightly coupled strings.Replace and strings.IndexOf … Which was both fragile and slow.

The current parser is inspired by Rob Pike’s talk:

http://cuddle.googlecode.com/hg/talk/lex.html

I have since removed the channel construct in favour of a faster slice, but the concept is the same. It may look verbose, but it is plenty worth it in the long run.

In this particular case I could update the method that handles comments only + tests:

With this high cohesion, I feel really confident that I have not broken anything. And if I should do something really stupid, it would only be messing with this particular small part of the shortcode handling.