Link containing "?id=" is truncated when markdown is processed

hi.

I have the following problem when I copy this link to my website:
https://www.barks.jp/news/?id=1000203176

the markdown being processed truncates the link after “news/” and the generated html <a> tag gets an id attribute with ‘1000203176’.

resulting html:
<a href="https://www.barks.jp/news" id="1000203176">...</a>

I have tried to escape characters of the url, but it did not help.

I could eventually solve this issue by using html instead of markdown in my .md file, but I would still like to understand why this is happening…

@mathmax,

but I would still like to understand why this is happening…

It happens because that behaviour is designed to happen :slight_smile:

According the docs on Link Attributes

A great new feature you can take advantage of is providing link attributes directly via the markdown syntax. This allows you to easily add class , id , rel , and target HTML attributes without the need of Markdown Extra.

// markdown
[Unique Button](../some-page?id=important-button)
// html
<a href="/your/pages/some-page" id="important-button">Unique Button</a>
1 Like

That’s a bummer :joy: I guess it was not thought, that someone might want to have id or class as a query string instead of attributes :slight_smile:

Thank you! This is actually a useful feature. :slight_smile:

Adding the following allows me to skip processing attributes which is just what I needed:

&noprocess
1 Like

This is horrible behavior. That’s not how Markdown works. I just spent an hour debugging why I’m unable to link to Microsoft’s download pages (e.g. https://www.microsoft.com/en-us/download/details.aspx?id=8109).

You shouldn’t ever mangle a valid url for a custom extension of questionable usefulness. There’s no reason you should set the id of an anchor tag via query parameter. That’s insane. All Markdown elements should use the same syntax and that shouldn’t conflict with anything else.

I would suggest using kramdown’s syntax: `link{: #my-link}

For those interested, here is a discussion on Grav’s repo with the contribution from @mminer237