I have a shortcode named ‘q.html’ that looks like this:
<blockquote>
{{ .Inner }}
</blockquote>
and the markdown content is:
[test][testlink]
{{%q%}}This is a [test][testlink].{{%/q%}}
[testlink]: https://google.com
It renders incorrectly as
<p><a href="https://google.com">test</a></p>
<blockquote>
This is a [test][testlink].
</blockquote>
If I change the shortcode to:
<blockquote>
{{ markdownify (delimit (slice .Inner "[testlink]: https://google.com") "\n") }}
</blockquote>
Then it renders correctly:
<p><a href="https://google.com">test</a></p>
<blockquote>
This is a <a href="https://google.com">test</a>.
</blockquote>
Which seems to indicate that when processing shortcodes reference-style links defined in the content markdown aren’t being passed to the Blackfriday processor.
Is there a way to make the defined reference links available to shortcodes rendered separately by Blackfriday?
The workaround I’m currently looking at is to define the links in the front matter and then use a shortcode to retrieve the link when needed.
Workaround shortcode (link.html):
{{ index .Page.Params.links (.Get 0) }}
Invoking the shortcode:
---
links:
testlink: http://google.com
---
[test]({{<link testlink>}})
{{%q%}}This is a [test]({{<link testlink>}}).{{%/q%}}
Which renders correctly.
Is there a better workaround (assuming there’s no way to pass the reference links to Blackfriday)?