Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Length limit for cross reference targets #181

Closed
asmeurer opened this issue Jul 7, 2020 · 7 comments
Closed

Length limit for cross reference targets #181

asmeurer opened this issue Jul 7, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@asmeurer
Copy link
Contributor

asmeurer commented Jul 7, 2020

There seems to be an undocumented length limit for cross reference targets. If I have something like

(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)=
# Header

where there are 36 as, It works fine, but if I instead have

(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)=
# Header

(37 as). Then it silently doesn't read (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)= as a cross-reference target and just inserts it literally into the document.

Ideally I would prefer no length limit, since I like to make the cross reference target name match the header name, which can be longer than 36 characters, but if there is one, it ought to be documented somewhere, and ideally, give an error rather than just silently not parsing.

@asmeurer asmeurer added the bug Something isn't working label Jul 7, 2020
@chrisjsewell
Copy link
Member

This is the link to the actual regex used: https://github.com/executablebooks/markdown-it-py/blob/c5f46e4bd95415d3b8483b3fa55c06318b25da71/markdown_it/extensions/myst_blocks/index.py#L8

I put the 36 character limit it for performance reasons, but can certainly extend it and document. It will still "fail silently" though, because it's not a failure in the parsers eyes; it just didn't match the regex.

Would 72 be ok, surely not longer 😬

@asmeurer
Copy link
Contributor Author

asmeurer commented Jul 8, 2020

Does the performance really suffer if you leave it unlimited?

@chrisjsewell
Copy link
Member

Maybe not, but I'd prefer to keep a limit: 256 is my final offer 😉

@choldgraf
Copy link
Member

@asmeurer can you share the use-case you've got where you need such long refs? Are you including entire file paths in the ref or something?

@asmeurer
Copy link
Contributor Author

asmeurer commented Jul 8, 2020

With recommonmark I was using direct refs like page.html#anchor. The anchor by default would be the text of the header. I decided to keep using anchor as the cross-reference name for MyST, since that is the simplest. For headers that have longer text, this results in longer anchors.

@chrisjsewell
Copy link
Member

Ok so in markdown-it-py 0.4.8 (just released) I've increased the limit to 100, so hopefully that helps you out 😄

@chrisjsewell chrisjsewell added enhancement New feature or request and removed bug Something isn't working labels Jul 20, 2020
@chrisjsewell
Copy link
Member

chrisjsewell commented Dec 3, 2021

closed by #449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants