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

Inline code formatting issues with newlines, template literals #742

Closed
lukekarrys opened this issue Dec 20, 2024 · 3 comments
Closed

Inline code formatting issues with newlines, template literals #742

lukekarrys opened this issue Dec 20, 2024 · 3 comments
Labels
bug Issue raised as a bug.

Comments

@lukekarrys
Copy link

lukekarrys commented Dec 20, 2024

What package is the bug related to?

typedoc-plugin-markdown

Describe the issue

I found a few cases where inline code doesn't get rendered properly. I think they are related but might be separate issues. The two cases are:

  • The output contains newlines (seen in index signatures and constructor overrides)
  • The output contains a template literal type

I created an example repository with the TypeScript code that causes these cases as well as a custom theme I hacked together that overrides some partials to produce output that renders correctly (at least on GitHub): https://github.com/lukekarrys/typedoc-markdown-hacks

The readme shows a diff of the original vs modified markdown output as well as a script that can be run to generate it.

Here are the specific cases as well:

template literals

#### Returns

\`sha512-$\{string\}\`

#### Returns

asserts i is \`sha512-$\{string\}\`

#### Returns

i is \`sha512-$\{string\}\`

constructor overrides

###### Overrides

`LRUCache<
  CacheFetchContext,
  CacheFetchContext,
  CacheFetchContext
>.constructor`

index signatures

#### Index Signature

 \[`key`: 
  \| \`git·$\{string\}·$\{string\} $\{string\}\`
  \| \`remote·$\{string\}·$\{string\} $\{string\}\`\]: 
  \| \`dev git·$\{string\}·$\{string\}\`
  \| \`dev remote·$\{string\}·$\{string\}\`
  \| \`prod git·$\{string\}·$\{string\}\`
  \| \`prod remote·$\{string\}·$\{string\}\`

TypeDoc configuration

{
  "entryPoints": ["./src/*"],
  "name": "Example",
  "outputFileStrategy": "modules",
  "mergeReadme": false,
  "entryFileName": "index.md",
  "disableSources": true,
  "excludeScopesInPaths": true,
  "useCodeBlocks": true,
  "hideBreadcrumbs": true,
  "hidePageHeader": true,
  "hidePageTitle": true,
  "readme": "none",
  "plugin": ["typedoc-plugin-markdown"]
}

Expected behavior

Here is the markdown output I expect in the cases above:

template literals

#### Returns

`` `sha512-${string}` ``

#### Returns

`` asserts i is `sha512-${string}` ``

#### Returns

`` i is `sha512-${string}` ``

constructor overrides

###### Overrides

```ts
LRUCache<
  CacheFetchContext,
  CacheFetchContext,
  CacheFetchContext
>.constructor
```

index signatures

#### Index Signature

```ts
 [key: 
  | `git·${string}·${string} ${string}`
  | `remote·${string}·${string} ${string}`]: 
  | `dev git·${string}·${string}`
  | `dev remote·${string}·${string}`
  | `prod git·${string}·${string}`
  | `prod remote·${string}·${string}`
```
@lukekarrys lukekarrys added the bug Issue raised as a bug. label Dec 20, 2024
@tgreyuk
Copy link
Member

tgreyuk commented Dec 23, 2024

thank you @lukekarrys this is super useful. I am working through the use cases.

@tgreyuk
Copy link
Member

tgreyuk commented Dec 30, 2024

@lukekarrys fixes in [email protected].

Here is a diff on the example repository lukekarrys/typedoc-markdown-hacks@main...tgreyuk:typedoc-fixes

I think things are looking pretty good.

Let me know if you find more use-cases.

Thanks again

@lukekarrys
Copy link
Author

Thanks @tgreyuk! I updated to the latest version and everything looks great without any manual theming now, so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue raised as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants