Re: Code Examples in Documents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx                    | Washington,DC XML Users Grp
URL:  http://www.eccnet.com          | http://www.eccnet.com/xmlug
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
Member of XML Guild (www.xmlguild.org)
--
docs mailing list
docs@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe:
https://admin.fedoraproject.org/mailman/listinfo/docs




[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Red Hat 9]     [Yosemite News]     [KDE Users]

  Powered by Linux