I have noticed that in my DocFX output the syntax highlighting is not correct for the examples, meaning example code inside <example><code>...</code></example>
doc comments, even though the API signatures are highlighted correctly. It seems that the issue is due to the following difference in the HTML output:
For API signatures, html has something like this:
<pre><code class="lang-csharp hljs">public void foo()</code></pre>
.
But in the examples it is:
<pre><code>.....</pre><code>
.
The difference is that class
attribute in the code
tag is absent.
When i manually add class="lang-csharp hljs"
into the code
tags into the html output of the examples, this fixes the syntax highlighting.
The question is: how can I make DocFX generate correct html output for the examples (with class="lang-csharp hljs"
present in code
tags)?
tag has an unofficial optional attribute 'lang'. It's been used for years by various documentation tools. See https://www.helixoft.com/files/vsdocman/help/acodexml.html. You can try
– Peter Macej Jul 15 '23 at 06:51to see if it helps.