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

Left angle bracket not escaped, causes parsing error with mdx #252

Closed
cabljac opened this issue Sep 21, 2021 · 11 comments
Closed

Left angle bracket not escaped, causes parsing error with mdx #252

cabljac opened this issue Sep 21, 2021 · 11 comments
Labels
next Fix available in the '@next' release

Comments

@cabljac
Copy link

cabljac commented Sep 21, 2021

Hi!

I am trying to generate docs using an mdx compiler/bundler and typedoc-plugin-markdown

I noticed that when a return value is, for example Promise<void>, the left angled bracket is not escaped. Related to this issue ?

Here's a snippet of what is generated:

| Name | Type |
| :------ | :------ |
| `notificationIds?` | `string`[] |

#### Returns

`Promise`<`void`\>
@tgreyuk
Copy link
Member

tgreyuk commented Sep 21, 2021

Hello.. yeah i can't quite remember why it was done like that but most engines don't complain, however I can't think of a reason not to escape the left angle bracket. out of interest what mdx compiler are you using?

@cabljac
Copy link
Author

cabljac commented Sep 22, 2021

I'm using mdx-bundler, which uses xdm (and esbuild) :)

at the moment im doing a replaceAll with some regex as a workaround.

It works fine when i treat the markdown as a .md file, but in mdx i think it assumes it's the start of a component or something.

@tgreyuk
Copy link
Member

tgreyuk commented Sep 23, 2021

I did implement but docusaurus then double escapes the character. going to need to think about the best way handle this.

Screenshot 2021-09-23 at 22 25 05

@cabljac
Copy link
Author

cabljac commented Sep 24, 2021

The escape i'm currently doing in my code to work around this issue uses a negative lookbehind:

.replaceAll(/(?<!\\)</g, '\\<');

so if it has been escaped already, it doesn't try and escape it. I don't know if this helps or is relevant at all. Maybe docusaurus can do something like that

@tgreyuk
Copy link
Member

tgreyuk commented Sep 25, 2021

Thanks - yeah a negative lookbehind would be the nicest solution here, but as you say would require a fix on docusaurus. still not entirely sure what the 'correct' thing to do here is. Reluctant to complicate things by introducing escaping options.

@favna
Copy link

favna commented Oct 20, 2021

Hi there, I was looking for an issue that might be related to the issue I'm facing and I'm wondering if I found the right one. I'm using the Docusaurus plugin.

Specifically the problematic lines are all missing a \ before the > and are as follows:

  1. type arrayUnion = ArrayElementType<typeof sample>; (source: https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/utilityTypes.ts#L147)
  2. type BB = Mutable<Sample>; (source: https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/utilityTypes.ts#L127)
  3. type BB = StrictRequired<Sample>; (source: https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/utilityTypes.ts#L147)

Adding the extra \ has it all compile and display fine:

If this indeed about the same issue as this was made for, are there any known temporary bypasses other than adjusting the source TSDoc comments?

This is for the feat/docusaurus branch on this repo: https://github.com/sapphiredev/website/tree/feat/docusaurus-rewrite
(In case someone is going to clone it, be sure to clone recursively with submodules, you then also have to execute node scripts/remove-submodule-lockfiles.mjs && yarn && yarn build-all-projects before running yarn start to start the project)

Nevermind! Turns out the issue was that the TSDoc @example comment wasn't wrapped with a codeblock. Changing it one with fixed it.

@tgreyuk tgreyuk added the next Fix available in the '@next' release label Jan 22, 2023
This was referenced Jan 22, 2023
@asturur
Copy link

asturur commented Sep 19, 2023

I have the same issue and i m trying to use this with the mdx plugin for gatsby

@birkskyum
Copy link

@asturur does it help to use v3.17.1 of typedoc-plugin-markdown?

@asturur
Copy link

asturur commented Nov 8, 2023

3.17 didn't, but i m happy to try 3.17.1

@tgreyuk
Copy link
Member

tgreyuk commented Nov 8, 2023

3.17 didn't, but i m happy to try 3.17.1

@asturur Please do confirm if 3.17.1 fixes or not. If not I will try it with Gatsby to see if I can replicate.

@asturur
Copy link

asturur commented Nov 8, 2023

My error with 3.17 was some issue with the '#' not sure why.
I ll replicate 3.17 error, post it here, and then inform about 3.17.1

@tgreyuk tgreyuk closed this as completed Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next Fix available in the '@next' release
Projects
None yet
Development

No branches or pull requests

5 participants