ejball / XmlDocMarkdown

Generates Markdown from .NET XML documentation comments.
https://ejball.com/XmlDocMarkdown/
MIT License
102 stars 30 forks source link

<code> tag extension to support a 'lang' or 'language' attribute. #127

Open WetHat opened 1 year ago

WetHat commented 1 year ago

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:

I hope you find this contribution useful.

WetHat