The motivation for this pull request is the poor (non-existing) support for code language in <code> sections by the XML documentation specification: D.3.3 <code>. Oftentimes it is necessary to include code fragments in the documentation which are not CSHARP. Typical examples include XML, HTML, Javascript , or mermaid diagram code. To support these use cases the other tools such as the Sandcastle help file build allow
additional lang or language attributes on the <code> tag.
Example:
<code lang="Javascript">
if (/\S+@\S+\.\S+/.test('david@codeshack.io')) {
console.log('Email is valid!');
} else {
console.log('Email is invalid!');
}
</code>
would be converted to this Markdown fenced block:
``` Javascript
if (/\S+@\S+\.\S+/.test('david@codeshack.io')) {
console.log('Email is valid!');
} else {
console.log('Email is invalid!');
}
```
In the code changes provided in this pull request I have:
added support for lang or language attributes to generate Markdown output as shown in the example above.
improved the TrimCode method to be smarter about finding the optimal indent length of a code block.
The motivation for this pull request is the poor (non-existing) support for code language in
<code>
sections by the XML documentation specification: D.3.3<code>
. Oftentimes it is necessary to include code fragments in the documentation which are not CSHARP. Typical examples include XML, HTML, Javascript , or mermaid diagram code. To support these use cases the other tools such as the Sandcastle help file build allow additionallang
orlanguage
attributes on the<code>
tag.Example:
would be converted to this Markdown fenced block:
In the code changes provided in this pull request I have:
lang
orlanguage
attributes to generate Markdown output as shown in the example above.TrimCode
method to be smarter about finding the optimal indent length of a code block.I hope you find this contribution useful.
WetHat