Markdown link just with title, without href url

Hi,

Usually when a need a popup text box to define some initials, I use a blank href anchor tag, just using the title field like this:

<a href="" title="Content Delivery Network">CDN</a>

This is useful because it helps the reader to know the meaning of the initials used within the text.

Now, in Markdown I was using this without problems (note the white space after the first parenthesis):

[CDN]( "Content Delivery Network")

But now, with HUGO v0.74.3, the links are rendered just as text: [CDN]( “Content Delivery Network”), not as links with a blank href.

Is there an option to include in the config file to enable goldmark to use a blank href link?
is there another option to have popups text or hint boxes just like the anchor title field gives?

Thanks.

Wouldn’t it be more appropriate to use the abbr element anyway?

Also, have you tried to tinker with markdown render hooks?

2 Likes

Thanks for the abbr tag, I forgot it completely. But it forces me to use “unsafe: true” in the config file, although by now, is enough for me.

Regarding to markdown render hooks, I’m using it to implement target="_blank" in my content links, but I couldn’t rid off the extra space after the link. I’m using this template:

<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "https" }} target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>

Then, writing a link like this:

[MyText](https://someurl.com "Title Text"), additional text

It renders this (obviously with underline below MyText):

MyText , additional text

Do you know how to fix this behaviour?

Uh? You could simply create a shortcode like:

{{ $abbr    := .Get 0 }}
{{ $title   := .Get 1 }}

<abbr title="{{ $title }}">{{ $abbr }}</abbr>
1 Like

Sure, I can simply create a shortcode under layouts/shortcodes, with name abbr.html and with this content:

<abbr title="{{ .Get 1 }}">{{ .Get 0 }}</abbr>

And then in the .md file use it like this:

{{< abbr "SEO" "Search Engine Optimization" >}}

And with this I’m not forced to use unsafe for Goldmark, thanks for guide me to this.

It would have been great if Goldmark had extra features like “PHP Markdown Extra -> Abbreviation”:
https://michelf.ca/projects/php-markdown/extra/#abbr

But, it’s ok for now, thanks.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.