X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fxml.cpp;h=7ee8d9137a754749b08134bdc39dcfb29431113c;hb=c69da75dfca389b219e269f9d5668215f398c24b;hp=dda39a4f3f6088e12da2e5a948071aa782c706b1;hpb=968f7e8cacac366fe86466c1ed74a3cd5fe3387c;p=features.git diff --git a/src/xml.cpp b/src/xml.cpp index dda39a4f3f..7ee8d9137a 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -17,12 +17,12 @@ #include "BufferParams.h" #include "Counters.h" #include "Layout.h" -#include "OutputParams.h" #include "Paragraph.h" #include "Text.h" #include "TextClass.h" #include "support/convert.h" +#include "support/debug.h" #include "support/docstream.h" #include "support/lassert.h" #include "support/lstrings.h" @@ -143,7 +143,7 @@ docstring CompTag::writeTag() const // automatically. docstring attributes = escapeString(attr_, XMLStream::ESCAPE_NONE); attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(), - [](int c) {return !std::isspace(c);})); + [](char_type c) {return !isSpace(c);})); if (!attributes.empty()) { output += ' ' + attributes; } @@ -166,7 +166,7 @@ bool FontTag::operator==(StartTag const & tag) const void XMLStream::writeError(std::string const &s) { - LYXERR0(s); + LYXERR(Debug::OUTFILE, s); *this << ESCAPE_NONE << from_utf8(""); *this << xml::CR(); } @@ -174,7 +174,7 @@ void XMLStream::writeError(std::string const &s) void XMLStream::writeError(docstring const &s) { - LYXERR0(s); + LYXERR(Debug::OUTFILE, s); *this << ESCAPE_NONE << from_utf8(""); @@ -686,9 +686,9 @@ void xml::openTag(odocstream & os, string const & name, string const & attribute string param = subst(attribute, "<", "\""); param = subst(param, ">", "\""); - // Note: we ignore the name if it empty or if it is a comment "" or + // Note: we ignore the name if it is empty or if it is a comment "" or // if the name is *dummy*. - // We ignore dummy because dummy is not a valid docbook element and it is + // We ignore dummy because dummy is not a valid DocBook element and it is // the internal name given to single paragraphs in the latex output. // This allow us to simplify the code a lot and is a reasonable compromise. if (!name.empty() && name != "!-- --" && name != "dummy") { @@ -753,4 +753,146 @@ void xml::closeTag(odocstream & os, Paragraph const & par) } +void openInlineTag(XMLStream & xs, const docstring & tag, const docstring & attr) +{ + xs << xml::StartTag(tag, attr); +} + + +void closeInlineTag(XMLStream & xs, const docstring & tag) +{ + xs << xml::EndTag(tag); +} + + +void openParTag(XMLStream & xs, const docstring & tag, const docstring & attr) +{ + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::StartTag(tag, attr); +} + + +void closeParTag(XMLStream & xs, const docstring & tag) +{ + xs << xml::EndTag(tag); + xs << xml::CR(); +} + + +void openBlockTag(XMLStream & xs, const docstring & tag, const docstring & attr) +{ + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::StartTag(tag, attr); + xs << xml::CR(); +} + + +void closeBlockTag(XMLStream & xs, const docstring & tag) +{ + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::EndTag(tag); + xs << xml::CR(); +} + + +void xml::openTag(XMLStream & xs, const docstring & tag, const docstring & 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 : 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 if (tagtype == "none") + xs << xml::StartTag(tag, attr); + else + xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + to_utf8(tag) + " " + to_utf8(attr) + "'"); +} + + +void xml::openTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype) +{ + xml::openTag(xs, from_utf8(tag), from_utf8(attr), tagtype); +} + + +void xml::openTag(XMLStream & xs, const docstring & tag, const std::string & attr, const std::string & tagtype) +{ + xml::openTag(xs, tag, from_utf8(attr), tagtype); +} + + +void xml::openTag(XMLStream & xs, const std::string & tag, const docstring & attr, const std::string & tagtype) +{ + xml::openTag(xs, from_utf8(tag), attr, tagtype); +} + + +void xml::closeTag(XMLStream & xs, const docstring & tag, const std::string & tagtype) +{ + if (tag.empty() || tag == "NONE" || tag == "IGNORE") + return; + + if (tag == "para" || tagtype == "paragraph") // Special case for : always considered as a paragraph. + closeParTag(xs, tag); + else if (tagtype == "block") + closeBlockTag(xs, tag); + else if (tagtype == "inline") + closeInlineTag(xs, tag); + else if (tagtype == "none") + xs << xml::EndTag(tag); + else + xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + to_utf8(tag) + "'"); +} + + +void xml::closeTag(XMLStream & xs, const std::string & tag, const std::string & tagtype) +{ + xml::closeTag(xs, from_utf8(tag), tagtype); +} + + +void xml::compTag(XMLStream & xs, const docstring & tag, const docstring & attr, const std::string & tagtype) +{ + if (tag.empty() || tag == from_ascii("NONE")) + return; + + // Special case for : always considered as a paragraph. + if (tag == from_ascii("para") || tagtype == "paragraph" || tagtype == "block") { + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::CompTag(tag, attr); + xs << xml::CR(); + } else if (tagtype == "inline") { + xs << xml::CompTag(tag, attr); + } else { + xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + to_utf8(tag) + "'"); + } +} + + +void xml::compTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype) +{ + xml::compTag(xs, from_utf8(tag), from_utf8(attr), tagtype); +} + + +void xml::compTag(XMLStream & xs, const docstring & tag, const std::string & attr, const std::string & tagtype) +{ + xml::compTag(xs, tag, from_utf8(attr), tagtype); +} + + +void xml::compTag(XMLStream & xs, const std::string & tag, const docstring & attr, const std::string & tagtype) +{ + xml::compTag(xs, from_utf8(tag), attr, tagtype); +} + + } // namespace lyx