Is there any way to generate <mark></mark> tags?


I couldn’t find a way to do this. It seems that the blackfriday markdown renderer dos not support generating this html tag at all, so I’m stuck.

I’m used to another markdown generator called “redcarpet” from ruby land, that allows the following syntax:

Please ==read this!==

Turns into:

Please <mark>read this!</mark>

Which I find incredibly useful.

Am I missing something?

Create a shortcode and use it as replacement to generate those tags. From what I know, it is not (yet) supported by blackfriday but I haven’t checked the feature set of both Hugo and blackfriday in detail for some months now so I am pretty outdated whether there are plans to extend the features.
I know that Hugo is/was supposed to upgrade to blackfriday 2 but I don’t know the state and whether that feature will be then supported so a shortcode is the best way to implement it

Thanks for your feedback.

Custom shortcodes seem really useful.

But in this case, the resulting syntax is more complicated.

And I don’t feel this:

Please {{< mark "read this!">}}

Is an improvement over this:

Please <mark>read this!</mark>

With this shortcode definition:

<mark>{{ .Get 0 }}</mark>

Another way to achieve this while using the syntax you already know is regular expressions. For this you would need to edit your used theme so when the content get rendered, you replace all occurrences of that “tag” with the real tag while preserving the content through the use of regular expression groups.
Still not as good as with a native implementation but probably better than shortcodes because it feels more natural that way. One disadvantage is that you need to verify that your edits still work whenever the theme gets updated, should you not use a selfmade theme.

Is this a more feasible way for you?

For now I’d just use <mark> as is, in your markdown. Not as easy as ==, but a lot easier than a shortcode.

@internetfreak, I’m not sure what you have in mind exactly, but hacking something with regexes is not really what I was looking for.

@maiki, I don’t mind injecting html here and there in my markdown markup.

I was more curious if hugo had a solution for this somewhat popular syntax.

Having in mind setting up a hugo stack for a non technical user.

you could use any other Emphasis:

use CSS to look like you want

Do non-technical users use mark? I’d certainly like them to! :slight_smile:

Here’s what I keep in mind when writing markdown: would I write this in an email?

Since markdown is a superset of HTML, if it isn’t one of those elements I’d use in an email, I consider: how often do I use this, and how many characters is it? For mark, in my case (though I might start using it more often!) it is very rare, and about the same characters as a shortcode.

Fortunately for you, if this scenario ever changes with mark and BlackFriday, someone will post about it here. :slight_smile: