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

Variable binding in Markdown causes anchor links to fail #2637

Open
kaceo opened this issue May 15, 2024 · 1 comment
Open

Variable binding in Markdown causes anchor links to fail #2637

kaceo opened this issue May 15, 2024 · 1 comment

Comments

@kaceo
Copy link

kaceo commented May 15, 2024

Environment

  • Operating System: Linux
  • Node Version: v18.17.1
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6

Reproduction

See below

Describe the bug

In a markdown file, if an anchor link contains a variable substition, it does not become a link

e.g.

---
mypath: /geography
---
Mypath is {{ $doc.mypath }}
[Go there]({{ $doc.mypath }}/welcome)

After nuxt runs, line 1 creates a line of text correctly substituted.

Line 2 creates the substitution correctly but Markdown does not change it into an anchor:

My path is /geography
[Go there](/geography/welcome)

Additional context

No response

Logs

No response

@kaceo
Copy link
Author

kaceo commented May 15, 2024

My analysis is that the sequence of conversion inside Markdown is incorrect.

  • if the variable substition is done at the end (after the entire page is converted to a Vue page), it will not be recognised by Anchor.

  • on the other hand, if the variable substitution is done early, it will allow the correct text replacement to appear inside the Markdown text, and be recognised by Anchor.

In Vitepress there is also a similar feature of embedding frontmatter variables inside content, and it uses the early binding strategy. Embedded Vue components are processed at the end. This work flow creates the correct conversion of Markdown with embedded variables and components without breaking any Markdown syntax.

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

No branches or pull requests

1 participant