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

Add option to preserve casing when generating links #301

Closed
thorsent opened this issue Mar 14, 2022 · 3 comments
Closed

Add option to preserve casing when generating links #301

thorsent opened this issue Mar 14, 2022 · 3 comments

Comments

@thorsent
Copy link

Request:
Add a new option preseveDeclarationCasing that, if set to true, will not convert declarations to lowercase.

Rationale:
typedoc-plugin-markdown automatically sets all id's and links to lowercase. This is in accordance with the spec for id tags, and in general how markdown works, but in so doing the original capitalization of declarations are lost. This is often undesirable when the markdown conversion is an interim step to converting to html (for instance, site generators such as Docusaurus and JSDocs are oriented around markdown as input but ultimately render their output as HTML where originally cased anchors are desirable).

Example, ListenerParam as output by Typedoc into html:
image

Output as listenerparam by markdown plugin:
image

Notes:
This appears to be a trivial change to this one line:
https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/typedoc-plugin-markdown/src/theme.ts#L162

I did attempt a PR but I found that in order to create a new option for the plugin it was also necessary to make that same change in Typedoc itself because it validates and strongly types all options. That increased the burden of effort for someone who isn't in the groove of working with this project.

This seems problematic if one desires a healthy plugin ecosystem. Perhaps I'm missing a nuance, but if not then I would like to suggest that providing an explicit any namespace in config for plugins would lower barriers to plugin development and prevent possible collisions, e.g.

   "plugins": {
       "typedoc-plugin-markdown" : {
            "hideBreadcrumbs": false
      }
   }
@tgreyuk
Copy link
Member

tgreyuk commented Apr 9, 2022

Apologies for delay on this been busy on other stuff. Have implemented, just tweaked the option name slightly to preserveAnchorCasing to make it a bit more explicit. Available in typedoc-plugin-markdown@3.12.0.

Point noted about the options - what is missing a contributing guide that will get around to at some point.

@thorsent
Copy link
Author

Thanks @tgreyuk !!!

@tgreyuk tgreyuk closed this as completed Apr 16, 2022
@thorsent
Copy link
Author

As a cookie crumb trail for anyone trying to use preserveAnchorCasing with docusaurus, after running typedoc (with this option enabled in your config) you then need to run a process that adds "explicit-id" tags to the markdown that typedoc generated. Docusaurus provides a utility to do this: write-heading-ids.

Here's the syntax:
docusaurus write-heading-ids ./your-typedoc-output/* --maintain-case true

So your package.json might look something like this:

"docs" : "typedoc --options typedoc-markdown.js && docusaurus write-heading-ids ./typedocs/* --maintain-case true && docusaurus start" 

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

No branches or pull requests

2 participants