Skip to content

Conversation

@RemyRylan
Copy link

This won't currently have any effect, but it will once this PR over at turndown is merged, so it's definitely worth prepping for:
mixmark-io/turndown#226

Once that PR is merged, I've confirmed locally that typedoc-plugin-markdown will correctly label fenced code examples that were generated from TypeDoc.

So if you have a TS file such as:

/**
 * Get file type settings
 *
 * ```typescript
 * const fileSettings = await getFileTypeSettings('path/to/some/file.md')
 * ```
 *
 * @public
 * @param filename - The file to get settings for.
 */
export const getFileTypeSettings = async (filename: Filename) => {/**/}

TypeDoc will output the HTML as such:

<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> fileSettings = <span class="hljs-keyword">await</span> getFileTypeSettings(<span class="hljs-string">'path/to/some/file.md'</span>)
</code></pre>

Currently, turndown doesn't process that, as it's specifically looking for a CSS class prefix of language- not the shorter version lang-. This paradigm is all based on highlight.js which supports "language-*", "lang-*" or even un-prefixed as just the name of the language itself such as "html".

Once that turndown PR lands, turndown will convert that HTML basically back into the original (ignore the extra space):

`` `typescript
const fileSettings = await getFileTypeSettings('path/to/some/file.md')
`` `

@tgreyuk tgreyuk merged commit 5937337 into typedoc2md:master May 8, 2018
@tgreyuk
Copy link
Member

tgreyuk commented May 8, 2018

Thanks @RemyRylan

@RemyRylan RemyRylan deleted the fenced-codeblocks branch May 8, 2018 11:39
@RemyRylan RemyRylan restored the fenced-codeblocks branch May 8, 2018 11:39
apolakipso pushed a commit to apolakipso/typedoc-plugin-markdown that referenced this pull request Jan 5, 2024
Make turndown default to using fenced code blocks
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

Successfully merging this pull request may close these issues.

2 participants