jekyll-wikilinks icon indicating copy to clipboard operation
jekyll-wikilinks copied to clipboard

Strange embedding behaviour: Embeds following wikilinks to the same post do not render

Open hot-domme opened this issue 1 year ago • 0 comments

Embeds don't render if the embedded post has been previously referenced as a wikilink in the same post. So if you link to a post as a wikilink, a subsequent embed of the same post will not render.

For instance, the following markdown:

[[post-title]]

![[post-title]]

will render as:

post-title

!post-title

(with each post-title successfully linking to the post, but both are rendered as wikilink instead of a wikilink and an embed.)

However, the following markdown:

![[post-title]]

[[post-title]]

Renders with no problem (note that the embed comes before the wikilink) the first link successfully embeds the target post, and the second is styled as a wikilink.

Two embeds of the same post render just fine, and an embed followed by a wikilink to the same post also renders properly, but not a wikilink followed by an embed of the same post. This happens no matter how far back in the current post the embedded post was referenced, so there can be plenty of content in between.

Interestingly, if the previous wikilink points to a particular heading within a post, or is aliased, then subsequent embeds of the same post will also work fine. Basically, if an embed appears after a wikilink to the same post, and the content between the [[]] is not differentiated by either a # or a |, the embed will not render, but instead appear as a wikilink prepended by a !.

So, it looks like there's an issue with the regex/parsing(?) where it conflates the wikilink and the embed.

I've taken to the practice of aliasing my embeds, like this: ![[post-title|embed]] to differentiate them from any previous wikilinks. Obviously, aliasing an embed does nothing noticeable, but it prevents the embed from being conflated with a previous wikilink.

Thanks for your work on a great and sorely needed plugin.

hot-domme avatar Oct 20 '22 05:10 hot-domme