Code Examples in Documents

John J. McDonough wb8rcr at arrl.net
Sun Jun 21 18:42:06 UTC 2015


But now your <code> tag won't work.  Seems like a step backward to me.

On Sun, 2015-06-21 at 13:59 -0400, Betty Harvey wrote:
> You can put code into the XML document by using CDATA sections.  
> Anything in a CDATA section is ignored by the parser so you can put 
> characters that you normally cannot add to an XML document, i.e., less 
> than, greater than, etc.
> 
> Below is how a CDATA section is constructed for the Docbook example 
> element:
> 
> <example>
>          <title>My Code</title>
>          <para>
> <![CDATA[
> 
> <h1>CDATA Section</h1>
> 
>      <p>Anything in a CDATA section is ignored by the XML Parser.</p>
> ]]>
>          </para>
>      </example>
> 
> 
> The parser will also respect any white space in the CDATA section so 
> what you see will be what you get inside the section.
> 
> Hope this helps!
> 
> Betty
> 
> On 2015-06-21 12:16, David Ashley wrote:
> > All -
> > 
> > In the past when creating a new document that will contain code
> > examples in C/C++ or Python I always placed the examples in separate
> > files from the main XML. This way it would be easier to test those
> > examples to make sure that they work as intended. Being new to the
> > Fedora Docs team I have looked at some of the current documents and
> > they do not seem to separate the code from the document itself. So I
> > am wondering if I should follow that convention or separate the code
> > from the XML like I have done in the past?
> > 
> > Please provide some guidance.
> > 
> > David Ashley
> 
> -- 
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
> Betty Harvey                         | Phone:  410-787-9200  FAX: 9830
> Electronic Commerce Connection, Inc. |
> harvey at eccnet.com                    | Washington,DC XML Users Grp
> URL:  http://www.eccnet.com          | http://www.eccnet.com/xmlug
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
> Member of XML Guild (www.xmlguild.org)




More information about the docs mailing list