typedoc-plugin-markdown
typedoc-plugin-markdown copied to clipboard
Left angle bracket not escaped, causes parsing error with mdx
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`\>
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?
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.
I did implement but docusaurus then double escapes the character. going to need to think about the best way handle this.
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
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.
~~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:~~
- ~~
type arrayUnion = ArrayElementType<typeof sample>;(source: https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/utilityTypes.ts#L147)~~ - ~~
type BB = Mutable<Sample>;(source: https://github.com/sapphiredev/utilities/blob/main/packages/utilities/src/lib/utilityTypes.ts#L127)~~ - ~~
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.
I have the same issue and i m trying to use this with the mdx plugin for gatsby
@asturur does it help to use v3.17.1 of typedoc-plugin-markdown?
3.17 didn't, but i m happy to try 3.17.1
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.
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