Skip to content

Length limit for cross reference targets #181

Closed

Description

@asmeurer

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.

Activity

  1. added
    bug
    on Jul 7, 2020
  2. chrisjsewell commented on Jul 8, 2020

    @chrisjsewell
    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 😬

  3. asmeurer commented on Jul 8, 2020

    @asmeurer
    ContributorAuthor

    Does the performance really suffer if you leave it unlimited?

  4. chrisjsewell commented on Jul 8, 2020

    @chrisjsewell
    Member

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

  5. choldgraf commented on Jul 8, 2020

    @choldgraf
    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?

  6. asmeurer commented on Jul 8, 2020

    @asmeurer
    ContributorAuthor

    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.

  7. chrisjsewell commented on Jul 13, 2020

    @chrisjsewell
    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 😄

  8. added
    enhancement
    and removed
    bug
    on Jul 20, 2020
  9. chrisjsewell commented on Dec 3, 2021

    @chrisjsewell
    Member

    closed by #449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions