typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
725 stars 177 forks source link

Unexpected character `\` (U+005C) in name #679

Closed DavidBal closed 3 months ago

DavidBal commented 3 months ago

What package is the bug related to?

docusaurus-plugin-typedoc

Describe the issue

Hi,

when we try to create the markdown for docusaurus, the markdown files are created but some of them create the following error:

ERROR in ./docs/api/SDK/C.S.S.ADO/classes/ADORecord.md
Module build failed (from ./node_modules/@docusaurus/mdx-loader/lib/index.js):
Error: MDX compilation failed for file "C:\Temp\Docusaurus\my-website\docs\api\SDK\C.S.S.ADO\classes\ADORecord.md"
Cause: Unexpected character `\` (U+005C) in name, expected a name character such as letters, digits, `$`, or `_`; whitespace before attributes; or the end of the tag
Details:
{
  "column": 22,
  "message": "Unexpected character `\\` (U+005C) in name, expected a name character such as letters, digits, `$`, or `_`; whitespace before attributes; or the end of the tag",
  "line": 244,
  "name": "244:22",
  "place": {
    "line": 244,
    "column": 22,
    "offset": 5044,
    "_index": 0,
    "_bufferIndex": 21
  },
  "reason": "Unexpected character `\\` (U+005C) in name, expected a name character such as letters, digits, `$`, or `_`; whitespace before attributes; or the end of the tag",
  "ruleId": "unexpected-character",
  "source": "micromark-extension-mdx-jsx",
  "url": "https://github.com/micromark/micromark-extension-mdx-jsx#unexpected-character-at-expected-expect"
}

    at Object.mdxLoader (C:\Temp\Docusaurus\my-website\node_modules\@docusaurus\mdx-loader\lib\loader.js:130:25)

This ist the created markdown:

***

### TryGetContentsValueByName()

> **TryGetContentsValueByName**\<`T`\>(`t`, `fieldName`): [`TryResult`](../../C.S.S.Shared/classes/TryResult.md)\<`T`\>

Versucht den Wert des übergebenen Feldes auszulesen. Ist das Feld nicht vorhanden oder kann nicht konvertiert werden `false` zurückgegeben.  
Das [LastError](ADOHelper.md#lasterror) Objekt wird im Falle eines Fehlers ausgelöst

#### Type Parameters

• **T** *extends* `string` \| `number` \| `boolean` \| `Date`

#### Parameters

• **t**: [`CLType`](../../C.S.S.Shared/classes/CLType.md)\<`T`\>

Generischer Parameter. Der Wert muss einem Wert von [CLType](../../C.S.S.Shared/classes/CLType.md) entsprechen

• **fieldName**: `string`

Feldname

#### Returns

[`TryResult`](../../C.S.S.Shared/classes/TryResult.md)\<`T`\>

Gibt ein [TryResult<T\>](../../C.S.S.Shared/classes/TryResult.md) zurück.

#### Defined in

SDK/C.S.S.ADO.ts:1571

***

The function looks like this:

    /**
    * Versucht den Wert des übergebenen Feldes auszulesen. Ist das Feld nicht vorhanden oder kann nicht konvertiert werden `false` zurückgegeben.  
    * Das {@link ADOHelper.LastError | LastError} Objekt wird im Falle eines Fehlers ausgelöst
    *
    * @param t - Generischer Parameter. Der Wert muss einem Wert von {@link CLType} entsprechen
    * @param fieldName - Feldname
    * @returns Gibt ein {@link TryResult | TryResult<T\>} zurück.
    *
    */
    public TryGetContentsValueByName<T extends string | number | Date | boolean>(t: CLType<T>, fieldName: string): TryResult<T> 

TypeDoc configuration

plugins: [
    [
      'docusaurus-plugin-typedoc',

      // Options
      {
        entryPoints: ["../SDK/*.ts", "../lib/*.ts"],
        tsconfig: '../tsconfig.json',
        exclude: 'src/**/*.tsx'
      },
    ],
  ],

Expected behavior

The created markdown file should work with docusaurus.

tgreyuk commented 3 months ago

hi @DavidBal . You are seeing this behaviour because of this line in your doc comments:

@returns Gibt ein {@link TryResult | TryResult<T\>} zurück.

TryResult<T\> is not valid MDX.

You have 2 options to fix this:

1) Additionally escape the opening bracket

 TryResult\<T\>

2) Add siteConfig.markdown.format: 'detect' to docusaurus.config which will parse as commonMark,

DavidBal commented 3 months ago

Hi @tgreyuk,

thanks for the answer adding the \ in front of the < fixed this problem.

Kind regards, David