Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a colorized HTML code snippet in Sandcastle documentation?

I am using the Sandcastle Help File Builder and would like to include colorized HTML code snippets in the "Conceptual Content". Is this possible and if so, how?

I have tried <code>, <codeExample>, and <sampleCode language="HTML" />.

The best result so far is to HTML-encode the sample HTML and place it in a .snippets file like so.

<?xml version="1.0" encoding="utf-8" ?>
<examples>
   <item id="htmlSnippet">
      <sampleCode language="HTML">
         &lt;span&gt;My Html&lt;/span&gt;
      </sampleCode>
   </item>
</examples>

Then reference it in the .aml file.

<codeReference>htmlSnippet</codeReference>

I would prefer to have it colorized, but I can't figure out a way to add the formatting.

like image 462
jedatu Avatar asked Jan 27 '26 06:01

jedatu


1 Answers

According to the MAML Guide, the proper way of doing this is to use a <code> tag with a CDATA section:

<code language="xml" title="Example Configuration">
<![CDATA[
    <span>My Html</span>]]>
</code>

The contents of the CDATA section will be treated as a literal string, and indentation will be preserved.

like image 122
dcastro Avatar answered Jan 29 '26 01:01

dcastro