mkdnflow.nvim icon indicating copy to clipboard operation
mkdnflow.nvim copied to clipboard

Feature: Support for Pandoc-flavored Markdown header attributes

Open fullstopslash opened this issue 3 years ago • 11 comments

This one is possibly a bit fiddly, but seems very similar to span links

So some flavors of markdown are able to use header attributes which are very similar to span links, but with an important distinction. Here's a quote from the pandoc documentation.

Headings can be assigned attributes using this syntax at the end of the line containing the heading text:

{#identifier .class .class key=value key=value}

Thus, for example, the following headings will all be assigned the identifier foo:

# My heading {#foo}

## My heading ##    {#foo}

My other heading   {#foo}

So essentially span links get formatted with square brackets then curly's like so: [link-text]{#custom-attribute}

While Header attributes look like any various number of header styles with a space following, then the curly's:

# Header {#custom-attribute}

Anyway, thanks for the incredibly fantastic plugin! I'd love if this were implemented because I'm continually using span links to link to headers with custom attributes for a choose-your-own-adventure book I'm working on.

fullstopslash avatar Feb 02 '23 02:02 fullstopslash

What's the functionality you want specifically? Is it that you want the follow links function to accommodate this style of link?

m-faith avatar Feb 06 '23 23:02 m-faith

Yep! A follow link should jump to a header that's marked with a custom attribute.

fullstopslash avatar Feb 06 '23 23:02 fullstopslash

That'd be cool. This syntax # Header {#custom-attribute} is used by the markdown-it npm packages too.

m-faith avatar Feb 06 '23 23:02 m-faith

I believe it works here on github as well!

fullstopslash avatar Feb 06 '23 23:02 fullstopslash

Related issue https://github.com/jakewvincent/mkdnflow.nvim/issues/89

m-faith avatar Feb 07 '23 04:02 m-faith

Oh... wait not quite as related as I thought... that's about autocomplete of the link whereas this is explicitly about following the link; both are about links to headers.

m-faith avatar Feb 07 '23 04:02 m-faith

@fullstopslash bracketed spans/span links (like [text]{#id}) are already supported, but I think support for linking to headers with explicitly defined ID attributes (following the pandoc syntax) would be a worthy addition.

jakewvincent avatar Apr 02 '23 22:04 jakewvincent

@fullstopslash if you're interested in testing it out, I've pushed an implementation of this to the dev branch. Will merge it to main after a bit more testing.

jakewvincent avatar Apr 05 '23 11:04 jakewvincent

So Not entirely certain what's going on, but the dev branch freezes neovim for me anytime I try to follow a link, or any link really. The work around I've been using until now has been to format my headers as if they're links, and then append the attribute for pandoc to pick up, like so:

[Header]{#custom-attribute} {#custom-attribute}

fullstopslash avatar Apr 06 '23 23:04 fullstopslash

@fullstopslash sorry about that! Should be fixed now if you pull the latest.

jakewvincent avatar Apr 07 '23 14:04 jakewvincent

Seems solid from my end!

fullstopslash avatar Apr 07 '23 15:04 fullstopslash