typedoc-plugin-markdown icon indicating copy to clipboard operation
typedoc-plugin-markdown copied to clipboard

Left angle bracket not escaped, causes parsing error with mdx

Open cabljac opened this issue 4 years ago • 11 comments
trafficstars

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`\>

cabljac avatar Sep 21 '21 13:09 cabljac

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?

tgreyuk avatar Sep 21 '21 21:09 tgreyuk

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.

cabljac avatar Sep 22 '21 07:09 cabljac

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

tgreyuk avatar Sep 23 '21 21:09 tgreyuk

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

cabljac avatar Sep 24 '21 07:09 cabljac

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.

tgreyuk avatar Sep 25 '21 14:09 tgreyuk

~~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.

favna avatar Oct 20 '21 16:10 favna

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

asturur avatar Sep 19 '23 11:09 asturur

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

birkskyum avatar Nov 08 '23 00:11 birkskyum

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

asturur avatar Nov 08 '23 08:11 asturur

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.

tgreyuk avatar Nov 08 '23 10:11 tgreyuk

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

asturur avatar Nov 08 '23 11:11 asturur