HiDeoo / starlight-versions

Starlight plugin to version documentation pages
https://starlight-versions.vercel.app
MIT License
24 stars 1 forks source link

Unable to version docs with characters < and > #5

Open eddyv opened 4 months ago

eddyv commented 4 months ago

Describe the bug

Hiya, thanks for the plugin! There may be an issue somewhere where we aren't properly escaping characters within markdown . For example, if you have a markdown file named test.md and contents

---
title: Test
sidebar:
  badge:
    text: New
---

<->blah

You'd get the following error

[AstroUserError] Expected a closing tag for `<>` (8:1-8:3) before the end of `paragraph`

If you have multiple occurrences of it

...
<->blah
<->blah

you'd get a less useful error like

[AstroUserError] Unexpected character `-` (U+002D) before name, expected a character that can start a name, such as a letter, `$`, or `_`

To Reproduce

  1. Create a file temp.md
  2. Add occurrences of <->
  3. Run starlight in dev mode

Expected behavior

The plugin should be able to escape special characters when creating versions in starlight dev mode

How often does this bug happen?

Every time

System Info

Additional Context

A workaround is to escape the occurrences of it using inline codeblocks

HiDeoo commented 4 months ago

Thanks for the report :raised_hands:

I would assume that the issue is due to the plugin always relying on remark-mdx at the moment and this specific syntax being invalid MDX. I guess we would need to branch out based on if the file is Markdown or MDX but my assumption is this would involve quite a bit of work that I did not get into yet.

A workaround should be to escape the < and > characters:

\<-\>blah