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

TOC alignment issue with macros (which contain links) and typeset #5590

Closed
4 tasks done
Vasperous opened this issue Jun 6, 2023 · 3 comments
Closed
4 tasks done

TOC alignment issue with macros (which contain links) and typeset #5590

Vasperous opened this issue Jun 6, 2023 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@Vasperous
Copy link
Sponsor

Context

I have been really looking forward to using the typeset plugin with my documentation as many of my headers are referring to code or objects. Showing them in the TOC as <code> makes it much easier to read.

Bug description

When enabling macros and typeset the TOC seems to not correctly align, specifically when the header is set to be bold and the macros replacement text is a URL.

While putting together this description I started deleting items like extensions etc. in my mkdocs.yml file. I saw various changes in the rendering of what I outlined below. My 'issue' went away when I removed the toc_depth option from the toc extension. I am not sure if that is a bug with the TOC extension or with the way macros/URLs are being handled. Could use some direction on that and since I am not sure I left my bug report as is.

In my .md file I have the following:

### {{rq_host}}

The host object that is not bold.

### **{{rq_host}}**

The host object that is bold...

### **{{rq_test}}**

This is a test of the macros with a non-link/url feature

If I only include the ### {{rq_host}} which is a URL but not bold then everything is displayed without issue:

image

If we only include ### **{{rq_test}}** which is just plain text and bold then everything is displayed without issue:

image

Only when we use the combination of a link and the bold do we see an issue with the TOC alignment ### **{{rq_host}}**:

image

Note: it looks like the whole page is also bold (in previous examples it was not).

For reference, contents of the external yaml file used by macros:

rq_host: "[`host`](#test)"
rq_test: "Test information"

I tried reducing down the number of features in my mkdocs.yml and after deleting all of the content and navigation features I got the below which is what I am seeing in my other documentation (it was at this moment that I started playing around with the extensions and added the second paragraph at the top):

image

Related links

Reproduction

example.zip

The example.zip didn't include the external macros folder so I unzipped it, added it and then re-zipped the files.

Steps to reproduce

  1. Create site
  2. Use macros, typeset and toc features/plugins
  3. Create macros page which references a URL
  4. include the macros link in the documentation and make the text bold
  5. Build documentation

Browser

Other

Before submitting

@squidfunk squidfunk added the needs investigation Issue must be investigated by the maintainers label Jun 6, 2023
@squidfunk
Copy link
Owner

Thanks for reporting, and for the excellent reproduction! Confirmed, it's definitely related to the typeset plugin.

@squidfunk squidfunk added bug Issue reports a bug and removed needs investigation Issue must be investigated by the maintainers labels Jun 6, 2023
@squidfunk
Copy link
Owner

Fixed in 2a1023da4. Thanks again for the excellent reproduction. There were two problems:

  1. The regular expression to find the permalink at the end of the headline was too greedy. If an author provided a custom link as part of the headline, the opening tag of that link was matched with the closing tag of the permalink. Thus all content from the opening link was lost, leaving only the <strong> opening tag, which explains the bold text.

  2. Author-provided anchor links were not removed at all. This is now fixed by inverting order and not limiting anchor link removal to the link at the start. This problem was also fixed in the commit.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Jun 7, 2023
@squidfunk
Copy link
Owner

Released as part of 9.1.16+insiders-4.36.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants