- } else {
- return "";
- }
-}
-
-
-// Convenience functions to open and close tags. First, very low-level ones to ensure a consistent new-line behaviour.
-// Block style:
-// Content before
-// <blocktag>
-// Contents of the block.
-// </blocktag>
-// Content after
-// Paragraph style:
-// Content before
-// <paratag>Contents of the paragraph.</paratag>
-// Content after
-// Inline style:
-// Content before<inlinetag>Contents of the paragraph.</inlinetag>Content after
-
-void openInlineTag(XMLStream & xs, const std::string & tag, const std::string & attr)
-{
- xs << xml::StartTag(tag, attr);
-}
-
-
-void closeInlineTag(XMLStream & xs, const std::string & tag)
-{
- xs << xml::EndTag(tag);
-}
-
-
-void openParTag(XMLStream & xs, const std::string & tag, const std::string & attr)
-{
- if (!xs.isLastTagCR())
- xs << xml::CR();
- xs << xml::StartTag(tag, attr);
-}
-
-
-void closeParTag(XMLStream & xs, const std::string & tag)
-{
- xs << xml::EndTag(tag);
- xs << xml::CR();
-}
-
-
-void openBlockTag(XMLStream & xs, const std::string & tag, const std::string & attr)
-{
- if (!xs.isLastTagCR())
- xs << xml::CR();
- xs << xml::StartTag(tag, attr);
- xs << xml::CR();
-}
-
-
-void closeBlockTag(XMLStream & xs, const std::string & tag)
-{
- if (!xs.isLastTagCR())
- xs << xml::CR();
- xs << xml::EndTag(tag);
- xs << xml::CR();
-}
-
-
-void openTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype)
-{
- if (tag.empty() || tag == "NONE") // Common check to be performed elsewhere, if it was not here.
- return;
-
- if (tag == "para" || tagtype == "paragraph") // Special case for <para>: always considered as a paragraph.
- openParTag(xs, tag, attr);
- else if (tagtype == "block")
- openBlockTag(xs, tag, attr);
- else if (tagtype == "inline")
- openInlineTag(xs, tag, attr);
- else
- xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + tag + " " + attr + "'");
-}
-
-
-void closeTag(XMLStream & xs, const std::string & tag, const std::string & tagtype)
-{
- if (tag.empty() || tag == "NONE")
- return;
-
- if (tag == "para" || tagtype == "paragraph") // Special case for <para>: always considered as a paragraph.
- closeParTag(xs, tag);
- else if (tagtype == "block")
- closeBlockTag(xs, tag);
- else if (tagtype == "inline")
- closeInlineTag(xs, tag);