]> git.lyx.org Git - features.git/commitdiff
Rename XHTMLStream to XMLStream, move it to another file, and prepare for DocBook...
authorThibaut Cuvelier <cuvelier.thibaut@gmail.com>
Thu, 9 May 2019 23:35:40 +0000 (01:35 +0200)
committerPavel Sanda <sanda@lyx.org>
Mon, 15 Jun 2020 11:01:56 +0000 (13:01 +0200)
xml.cpp/h also merges functionalities from sgml.cpp/h.

97 files changed:
development/attic/qmake/lyx.pro
src/BiblioInfo.cpp
src/Buffer.cpp
src/CMakeLists.txt
src/Makefile.am
src/Paragraph.cpp
src/Paragraph.h
src/ParagraphMetrics.cpp
src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetArgument.h
src/insets/InsetBibitem.cpp
src/insets/InsetBibitem.h
src/insets/InsetBibtex.cpp
src/insets/InsetBibtex.h
src/insets/InsetBox.cpp
src/insets/InsetBox.h
src/insets/InsetBranch.cpp
src/insets/InsetBranch.h
src/insets/InsetCaption.cpp
src/insets/InsetCaption.h
src/insets/InsetCaptionable.cpp
src/insets/InsetCitation.cpp
src/insets/InsetCitation.h
src/insets/InsetCounter.cpp
src/insets/InsetCounter.h
src/insets/InsetERT.cpp
src/insets/InsetERT.h
src/insets/InsetExternal.cpp
src/insets/InsetExternal.h
src/insets/InsetFloat.cpp
src/insets/InsetFloat.h
src/insets/InsetFloatList.cpp
src/insets/InsetFloatList.h
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h
src/insets/InsetHyperlink.cpp
src/insets/InsetHyperlink.h
src/insets/InsetIPA.cpp
src/insets/InsetIPA.h
src/insets/InsetIPAMacro.cpp
src/insets/InsetIPAMacro.h
src/insets/InsetInclude.cpp
src/insets/InsetInclude.h
src/insets/InsetIndex.cpp
src/insets/InsetIndex.h
src/insets/InsetLabel.cpp
src/insets/InsetLabel.h
src/insets/InsetLine.cpp
src/insets/InsetLine.h
src/insets/InsetListings.cpp
src/insets/InsetListings.h
src/insets/InsetNewline.cpp
src/insets/InsetNewline.h
src/insets/InsetNewpage.cpp
src/insets/InsetNewpage.h
src/insets/InsetNomencl.cpp
src/insets/InsetNomencl.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h
src/insets/InsetPhantom.cpp
src/insets/InsetPhantom.h
src/insets/InsetQuotes.cpp
src/insets/InsetQuotes.h
src/insets/InsetRef.cpp
src/insets/InsetRef.h
src/insets/InsetSeparator.cpp
src/insets/InsetSeparator.h
src/insets/InsetSpace.cpp
src/insets/InsetSpace.h
src/insets/InsetSpecialChar.cpp
src/insets/InsetSpecialChar.h
src/insets/InsetTOC.cpp
src/insets/InsetTOC.h
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
src/insets/InsetText.cpp
src/insets/InsetText.h
src/insets/InsetVSpace.cpp
src/insets/InsetVSpace.h
src/insets/InsetWrap.cpp
src/insets/InsetWrap.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h
src/mathed/InsetMathMacroTemplate.cpp
src/mathed/InsetMathMacroTemplate.h
src/mathed/InsetMathRef.cpp
src/output_docbook.cpp
src/output_docbook.h
src/output_xhtml.cpp
src/output_xhtml.h
src/sgml.cpp [deleted file]
src/sgml.h [deleted file]
src/tests/dummy_functions.cpp
src/tex2lyx/dummy_impl.cpp
src/xml.cpp [new file with mode: 0644]
src/xml.h [new file with mode: 0644]

index de5624bcf7541c61b8efb10dcc6a482a9f9a02d2..0db456c44a5a0c23227148eef62fc55200263c23 100644 (file)
@@ -125,7 +125,7 @@ SOURCES += \
 ../../src/Server.cpp \
 ../../src/ServerSocket.cpp \
 ../../src/Session.cpp \
-../../src/sgml.cpp \
+../../src/xml.cpp \
 ../../src/Spacing.cpp \
 ../../src/TexRow.cpp \
 ../../src/TexStream.cpp \
@@ -476,7 +476,7 @@ HEADERS += \
 ../../src/Server.h \
 ../../src/ServerSocket.h \
 ../../src/Session.h \
-../../src/sgml.h \
+../../src/xml.h \
 ../../src/Spacing.h \
 ../../src/TexRow.h \
 ../../src/TexStream.h \
index bf7fb85ed6eaa71d98e7dd1a48cd3ec4a81bf34d..f43d4149ab5fa907e6417c4d7451d96af90bdd6d 100644 (file)
@@ -1159,7 +1159,7 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
        }
 
        if (cleanit)
-               ret = html::cleanAttr(ret);
+               ret = xml::cleanAttr(ret);
 
        // make sure it is not too big
        support::truncateWithEllipsis(ret, maxsize);
index c8941e3043d77f43cbceba39aa92095e0f9b708d..03368dc8762e2b6400482dd5da0a70da5da54c33 100644 (file)
@@ -57,7 +57,7 @@
 #include "PDFOptions.h"
 #include "Session.h"
 #include "SpellChecker.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "TexRow.h"
 #include "Text.h"
@@ -2195,13 +2195,13 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os, string const &
 
                params().documentClass().counters().reset();
 
-               sgml::openTag(os, top);
+               xml::openTag(os, top);
                os << '\n';
                try {
                        docbookParagraphs(text(), *this, os, runparams);
                }
                catch (ConversionException const &) { return ExportKilled; }
-               sgml::closeTag(os, top_element);
+               xml::closeTag(os, top_element);
        }
        return ExportSuccess;
 }
@@ -2259,7 +2259,7 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
                os << "<title>"
                   << (doctitle.empty() ?
                         from_ascii("LyX Document") :
-                        html::htmlize(doctitle, XHTMLStream::ESCAPE_ALL))
+                        xml::xmlize(doctitle, XMLStream::ESCAPE_ALL))
                   << "</title>\n";
 
                docstring styles = features.getTClassHTMLPreamble();
@@ -2325,7 +2325,7 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
                bool const output_body_tag = (output != IncludedFile);
                if (output_body_tag)
                        os << "<body dir=\"auto\">\n";
-               XHTMLStream xs(os);
+               XMLStream xs(os);
                if (output != IncludedFile)
                        // if we're an included file, the counters are in the master.
                        params().documentClass().counters().reset();
@@ -4123,7 +4123,7 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
                        par.write(ods, params(), dt);
                        os << from_utf8(ods.str());
                } else if (runparams.flavor == OutputParams::HTML) {
-                       XHTMLStream xs(os);
+                       XMLStream xs(os);
                        setMathFlavor(runparams);
                        xhtmlParagraphs(text(), *this, xs, runparams);
                } else if (runparams.flavor == OutputParams::TEXT) {
index 77931794319ad16dec83411c35f3b25929322391..d7cf9c7bc63683dfca246c7ee79203a37b773a01 100644 (file)
@@ -1,7 +1,7 @@
 # This file is part of LyX, the document processor.
 # Licence details can be found in the file COPYING.
 #
-# Copyright (c) 2006-2011 Peter Kümmel, <syntheticpp@gmx.net>
+# Copyright (c) 2006-2011 Peter K�mmel, <syntheticpp@gmx.net>
 #
 
 project(${_lyx})
index ddc82fb1da251adf328afa2077aecb20583c634b..f6a77dc0bd1e5597b541bfd9f3786e384392d676 100644 (file)
@@ -172,7 +172,7 @@ SOURCEFILESCORE = \
        RowPainter.cpp \
        Server.cpp \
        ServerSocket.cpp \
-       sgml.cpp \
+       xml.cpp \
        Session.cpp \
        Spacing.cpp \
        TexRow.cpp \
@@ -279,7 +279,7 @@ HEADERFILESCORE = \
        Server.h \
        ServerSocket.h \
        Session.h \
-       sgml.h \
+       xml.h \
        Spacing.h \
        SpellChecker.h \
        TexRow.h \
index 837dc0dd48a93937af2276aacb2af26f135f409d..10b6456adfd1e21449bc59cbec8923c10497c380 100644 (file)
 #include "OutputParams.h"
 #include "output_latex.h"
 #include "output_xhtml.h"
+#include "output_docbook.h"
 #include "ParagraphParameters.h"
 #include "SpellChecker.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "TextClass.h"
 #include "TexRow.h"
@@ -2930,7 +2931,7 @@ bool Paragraph::emptyTag() const
 }
 
 
-string Paragraph::getID(Buffer const & buf, OutputParams const & runparams)
+string Paragraph::getID(Buffer const &, OutputParams const &)
        const
 {
        for (pos_type i = 0; i < size(); ++i) {
@@ -2939,7 +2940,7 @@ string Paragraph::getID(Buffer const & buf, OutputParams const & runparams)
                        if (lyx_code == LABEL_CODE) {
                                InsetLabel const * const il = static_cast<InsetLabel const *>(inset);
                                docstring const & id = il->getParam("name");
-                               return "id='" + to_utf8(sgml::cleanID(buf, runparams, id)) + "'";
+                               return "id='" + to_utf8(xml::cleanID(id)) + "'";
                        }
                }
        }
@@ -2958,14 +2959,14 @@ pos_type Paragraph::firstWordDocBook(odocstream & os, OutputParams const & runpa
                        char_type c = d->text_[i];
                        if (c == ' ')
                                break;
-                       os << sgml::escapeChar(c);
+                       os << xml::escapeChar(c, XMLStream::ESCAPE_ALL);
                }
        }
        return i;
 }
 
 
-pos_type Paragraph::firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runparams)
+pos_type Paragraph::firstWordLyXHTML(XMLStream & xs, OutputParams const & runparams)
        const
 {
        pos_type i;
@@ -3038,7 +3039,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
                        if (style.pass_thru)
                                os.put(c);
                        else
-                               os << sgml::escapeChar(c);
+                               os << xml::escapeChar(c, XMLStream::EscapeSettings::ESCAPE_ALL);
                }
                font_old = font.fontInfo();
        }
@@ -3055,27 +3056,29 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
 
 
 namespace {
-void doFontSwitch(vector<html::FontTag> & tagsToOpen,
-                  vector<html::EndFontTag> & tagsToClose,
-                  bool & flag, FontState curstate, html::FontTypes type)
+
+void doFontSwitchXHTML(vector<xml::FontTag> & tagsToOpen,
+                  vector<xml::EndFontTag> & tagsToClose,
+                  bool & flag, FontState curstate, xml::FontTypes type)
 {
        if (curstate == FONT_ON) {
-               tagsToOpen.push_back(html::FontTag(type));
+               tagsToOpen.push_back(xhtmlStartFontTag(type));
                flag = true;
        } else if (flag) {
-               tagsToClose.push_back(html::EndFontTag(type));
+               tagsToClose.push_back(xhtmlEndFontTag(type));
                flag = false;
        }
 }
-} // namespace
+
+} // anonymous namespace
 
 
 docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
-                                   XHTMLStream & xs,
-                                   OutputParams const & runparams,
-                                   Font const & outerfont,
-                                   bool start_paragraph, bool close_paragraph,
-                                   pos_type initial) const
+                                                                                XMLStream & xs,
+                                                                                OutputParams const & runparams,
+                                                                                Font const & outerfont,
+                                                                                bool start_paragraph, bool close_paragraph,
+                                                                                pos_type initial) const
 {
        docstring retval;
 
@@ -3110,8 +3113,8 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
        string const default_family =
                buf.masterBuffer()->params().fonts_default_family;
 
-       vector<html::FontTag> tagsToOpen;
-       vector<html::EndFontTag> tagsToClose;
+       vector<xml::FontTag> tagsToOpen;
+       vector<xml::EndFontTag> tagsToClose;
 
        // parsing main loop
        for (pos_type i = initial; i < size(); ++i) {
@@ -3124,260 +3127,260 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
                // emphasis
                FontState curstate = font.fontInfo().emph();
                if (font_old.emph() != curstate)
-                       doFontSwitch(tagsToOpen, tagsToClose, emph_flag, curstate, html::FT_EMPH);
+                       doFontSwitchXHTML(tagsToOpen, tagsToClose, emph_flag, curstate, xml::FT_EMPH);
 
                // noun
                curstate = font.fontInfo().noun();
                if (font_old.noun() != curstate)
-                       doFontSwitch(tagsToOpen, tagsToClose, noun_flag, curstate, html::FT_NOUN);
+                       doFontSwitchXHTML(tagsToOpen, tagsToClose, noun_flag, curstate, xml::FT_NOUN);
 
                // underbar
                curstate = font.fontInfo().underbar();
                if (font_old.underbar() != curstate)
-                       doFontSwitch(tagsToOpen, tagsToClose, ubar_flag, curstate, html::FT_UBAR);
+                       doFontSwitchXHTML(tagsToOpen, tagsToClose, ubar_flag, curstate, xml::FT_UBAR);
 
                // strikeout
                curstate = font.fontInfo().strikeout();
                if (font_old.strikeout() != curstate)
-                       doFontSwitch(tagsToOpen, tagsToClose, sout_flag, curstate, html::FT_SOUT);
+                       doFontSwitchXHTML(tagsToOpen, tagsToClose, sout_flag, curstate, xml::FT_SOUT);
 
                // xout
                curstate = font.fontInfo().xout();
                if (font_old.xout() != curstate)
-                       doFontSwitch(tagsToOpen, tagsToClose, xout_flag, curstate, html::FT_XOUT);
+                       doFontSwitchXHTML(tagsToOpen, tagsToClose, xout_flag, curstate, xml::FT_XOUT);
 
                // double underbar
                curstate = font.fontInfo().uuline();
                if (font_old.uuline() != curstate)
-                       doFontSwitch(tagsToOpen, tagsToClose, dbar_flag, curstate, html::FT_DBAR);
+                       doFontSwitchXHTML(tagsToOpen, tagsToClose, dbar_flag, curstate, xml::FT_DBAR);
 
                // wavy line
                curstate = font.fontInfo().uwave();
                if (font_old.uwave() != curstate)
-                       doFontSwitch(tagsToOpen, tagsToClose, wave_flag, curstate, html::FT_WAVE);
+                       doFontSwitchXHTML(tagsToOpen, tagsToClose, wave_flag, curstate, xml::FT_WAVE);
 
                // bold
                // a little hackish, but allows us to reuse what we have.
                curstate = (font.fontInfo().series() == BOLD_SERIES ? FONT_ON : FONT_OFF);
                if (font_old.series() != font.fontInfo().series())
-                       doFontSwitch(tagsToOpen, tagsToClose, bold_flag, curstate, html::FT_BOLD);
+                       doFontSwitchXHTML(tagsToOpen, tagsToClose, bold_flag, curstate, xml::FT_BOLD);
 
                // Font shape
                curr_fs = font.fontInfo().shape();
                FontShape old_fs = font_old.shape();
                if (old_fs != curr_fs) {
-                       if (shap_flag) {
-                               switch (old_fs) {
-                               case ITALIC_SHAPE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_ITALIC));
-                                       break;
-                               case SLANTED_SHAPE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SLANTED));
-                                       break;
-                               case SMALLCAPS_SHAPE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SMALLCAPS));
-                                       break;
-                               case UP_SHAPE:
-                               case INHERIT_SHAPE:
-                                       break;
-                               default:
-                                       // the other tags are for internal use
-                                       LATTEST(false);
-                                       break;
-                               }
-                               shap_flag = false;
-                       }
-                       switch (curr_fs) {
-                       case ITALIC_SHAPE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_ITALIC));
-                               shap_flag = true;
-                               break;
-                       case SLANTED_SHAPE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SLANTED));
-                               shap_flag = true;
-                               break;
-                       case SMALLCAPS_SHAPE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SMALLCAPS));
-                               shap_flag = true;
-                               break;
-                       case UP_SHAPE:
-                       case INHERIT_SHAPE:
-                               break;
-                       default:
-                               // the other tags are for internal use
-                               LATTEST(false);
-                               break;
-                       }
+            if (shap_flag) {
+                switch (old_fs) {
+                case ITALIC_SHAPE:
+                    tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_ITALIC), xml::FT_ITALIC));
+                    break;
+                case SLANTED_SHAPE:
+                    tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_SLANTED), xml::FT_SLANTED));
+                    break;
+                case SMALLCAPS_SHAPE:
+                    tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_SMALLCAPS), xml::FT_SMALLCAPS));
+                    break;
+                case UP_SHAPE:
+                case INHERIT_SHAPE:
+                    break;
+                default:
+                    // the other tags are for internal use
+                    LATTEST(false);
+                    break;
+                }
+                shap_flag = false;
+            }
+            switch (curr_fs) {
+            case ITALIC_SHAPE:
+                tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_ITALIC), xml::FT_ITALIC));
+                shap_flag = true;
+                break;
+            case SLANTED_SHAPE:
+                tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_SLANTED), xml::FT_SLANTED));
+                shap_flag = true;
+                break;
+            case SMALLCAPS_SHAPE:
+                tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_SMALLCAPS), xml::FT_SMALLCAPS));
+                shap_flag = true;
+                break;
+            case UP_SHAPE:
+            case INHERIT_SHAPE:
+                break;
+            default:
+                // the other tags are for internal use
+                LATTEST(false);
+                break;
+            }
                }
 
                // Font family
                curr_fam = font.fontInfo().family();
                FontFamily old_fam = font_old.family();
                if (old_fam != curr_fam) {
-                       if (faml_flag) {
-                               switch (old_fam) {
-                               case ROMAN_FAMILY:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_ROMAN));
-                                       break;
-                               case SANS_FAMILY:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SANS));
-                                       break;
-                               case TYPEWRITER_FAMILY:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_TYPE));
-                                       break;
-                               case INHERIT_FAMILY:
-                                       break;
-                               default:
-                                       // the other tags are for internal use
-                                       LATTEST(false);
-                                       break;
-                               }
-                               faml_flag = false;
-                       }
-                       switch (curr_fam) {
-                       case ROMAN_FAMILY:
-                               // we will treat a "default" font family as roman, since we have
-                               // no other idea what to do.
-                               if (default_family != "rmdefault" && default_family != "default") {
-                                       tagsToOpen.push_back(html::FontTag(html::FT_ROMAN));
-                                       faml_flag = true;
-                               }
-                               break;
-                       case SANS_FAMILY:
-                               if (default_family != "sfdefault") {
-                                       tagsToOpen.push_back(html::FontTag(html::FT_SANS));
-                                       faml_flag = true;
-                               }
-                               break;
-                       case TYPEWRITER_FAMILY:
-                               if (default_family != "ttdefault") {
-                                       tagsToOpen.push_back(html::FontTag(html::FT_TYPE));
-                                       faml_flag = true;
-                               }
-                               break;
-                       case INHERIT_FAMILY:
-                               break;
-                       default:
-                               // the other tags are for internal use
-                               LATTEST(false);
-                               break;
-                       }
+            if (faml_flag) {
+                switch (old_fam) {
+                case ROMAN_FAMILY:
+                    tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_ROMAN), xml::FT_ROMAN));
+                    break;
+                case SANS_FAMILY:
+                    tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_SANS), xml::FT_SANS));
+                    break;
+                case TYPEWRITER_FAMILY:
+                    tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_TYPE), xml::FT_TYPE));
+                    break;
+                case INHERIT_FAMILY:
+                    break;
+                default:
+                    // the other tags are for internal use
+                    LATTEST(false);
+                    break;
+                }
+                faml_flag = false;
+            }
+            switch (curr_fam) {
+            case ROMAN_FAMILY:
+                // we will treat a "default" font family as roman, since we have
+                // no other idea what to do.
+                if (default_family != "rmdefault" && default_family != "default") {
+                    tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_ROMAN), xml::FT_ROMAN));
+                    faml_flag = true;
+                }
+                break;
+            case SANS_FAMILY:
+                if (default_family != "sfdefault") {
+                    tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_SANS), xml::FT_SANS));
+                    faml_flag = true;
+                }
+                break;
+            case TYPEWRITER_FAMILY:
+                if (default_family != "ttdefault") {
+                    tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_TYPE), xml::FT_TYPE));
+                    faml_flag = true;
+                }
+                break;
+            case INHERIT_FAMILY:
+                break;
+            default:
+                // the other tags are for internal use
+                LATTEST(false);
+                break;
+            }
                }
 
                // Font size
                curr_size = font.fontInfo().size();
                FontSize old_size = font_old.size();
                if (old_size != curr_size) {
-                       if (size_flag) {
-                               switch (old_size) {
-                               case TINY_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_TINY));
-                                       break;
-                               case SCRIPT_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_SCRIPT));
-                                       break;
-                               case FOOTNOTE_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_FOOTNOTE));
-                                       break;
-                               case SMALL_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_SMALL));
-                                       break;
-                               case LARGE_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGE));
-                                       break;
-                               case LARGER_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGER));
-                                       break;
-                               case LARGEST_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGEST));
-                                       break;
-                               case HUGE_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_HUGE));
-                                       break;
-                               case HUGER_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_HUGER));
-                                       break;
-                               case INCREASE_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_INCREASE));
-                                       break;
-                               case DECREASE_SIZE:
-                                       tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_DECREASE));
-                                       break;
-                               case INHERIT_SIZE:
-                               case NORMAL_SIZE:
-                                       break;
-                               default:
-                                       // the other tags are for internal use
-                                       LATTEST(false);
-                                       break;
-                               }
-                               size_flag = false;
-                       }
-                       switch (curr_size) {
-                       case TINY_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_TINY));
-                               size_flag = true;
-                               break;
-                       case SCRIPT_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_SCRIPT));
-                               size_flag = true;
-                               break;
-                       case FOOTNOTE_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_FOOTNOTE));
-                               size_flag = true;
-                               break;
-                       case SMALL_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_SMALL));
-                               size_flag = true;
-                               break;
-                       case LARGE_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGE));
-                               size_flag = true;
-                               break;
-                       case LARGER_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGER));
-                               size_flag = true;
-                               break;
-                       case LARGEST_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGEST));
-                               size_flag = true;
-                               break;
-                       case HUGE_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_HUGE));
-                               size_flag = true;
-                               break;
-                       case HUGER_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_HUGER));
-                               size_flag = true;
-                               break;
-                       case INCREASE_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_INCREASE));
-                               size_flag = true;
-                               break;
-                       case DECREASE_SIZE:
-                               tagsToOpen.push_back(html::FontTag(html::FT_SIZE_DECREASE));
-                               size_flag = true;
-                               break;
-                       case NORMAL_SIZE:
-                       case INHERIT_SIZE:
-                               break;
-                       default:
-                               // the other tags are for internal use
-                               LATTEST(false);
-                               break;
-                       }
+            if (size_flag) {
+                switch (old_size) {
+                case TINY_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_TINY), xml::FT_SIZE_TINY);
+                    break;
+                case SCRIPT_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_SCRIPT), xml::FT_SIZE_SCRIPT);
+                    break;
+                case FOOTNOTE_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_FOOTNOTE), xml::FT_SIZE_FOOTNOTE);
+                    break;
+                case SMALL_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_SMALL), xml::FT_SIZE_SMALL);
+                    break;
+                case LARGE_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGE), xml::FT_SIZE_LARGE);
+                    break;
+                case LARGER_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGER), xml::FT_SIZE_LARGER);
+                    break;
+                case LARGEST_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGEST), xml::FT_SIZE_LARGEST);
+                    break;
+                case HUGE_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_HUGE), xml::FT_SIZE_HUGE);
+                    break;
+                case HUGER_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_HUGER), xml::FT_SIZE_HUGER);
+                    break;
+                case INCREASE_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_INCREASE), xml::FT_SIZE_INCREASE);
+                    break;
+                case DECREASE_SIZE:
+                    tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_DECREASE), xml::FT_SIZE_DECREASE);
+                    break;
+                case INHERIT_SIZE:
+                case NORMAL_SIZE:
+                    break;
+                default:
+                    // the other tags are for internal use
+                    LATTEST(false);
+                    break;
+                }
+                size_flag = false;
+            }
+            switch (curr_size) {
+            case TINY_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_TINY), xml::FT_SIZE_TINY);
+                size_flag = true;
+                break;
+            case SCRIPT_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_SCRIPT), xml::FT_SIZE_SCRIPT);
+                size_flag = true;
+                break;
+            case FOOTNOTE_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_FOOTNOTE), xml::FT_SIZE_FOOTNOTE);
+                size_flag = true;
+                break;
+            case SMALL_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_SMALL), xml::FT_SIZE_SMALL);
+                size_flag = true;
+                break;
+            case LARGE_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGE), xml::FT_SIZE_LARGE);
+                size_flag = true;
+                break;
+            case LARGER_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGER), xml::FT_SIZE_LARGER);
+                size_flag = true;
+                break;
+            case LARGEST_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGEST), xml::FT_SIZE_LARGEST);
+                size_flag = true;
+                break;
+            case HUGE_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_HUGE), xml::FT_SIZE_HUGE);
+                size_flag = true;
+                break;
+            case HUGER_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_HUGER), xml::FT_SIZE_HUGER);
+                size_flag = true;
+                break;
+            case INCREASE_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_INCREASE), xml::FT_SIZE_INCREASE);
+                size_flag = true;
+                break;
+            case DECREASE_SIZE:
+                tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_DECREASE), xml::FT_SIZE_DECREASE);
+                size_flag = true;
+                break;
+            case INHERIT_SIZE:
+            case NORMAL_SIZE:
+                break;
+            default:
+                // the other tags are for internal use
+                LATTEST(false);
+                break;
+            }
                }
 
                // FIXME XHTML
                // Other such tags? What about the other text ranges?
 
-               vector<html::EndFontTag>::const_iterator cit = tagsToClose.begin();
-               vector<html::EndFontTag>::const_iterator cen = tagsToClose.end();
+               vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
+               vector<xml::EndFontTag>::const_iterator cen = tagsToClose.end();
                for (; cit != cen; ++cit)
                        xs << *cit;
 
-               vector<html::FontTag>::const_iterator sit = tagsToOpen.begin();
-               vector<html::FontTag>::const_iterator sen = tagsToOpen.end();
+               vector<xml::FontTag>::const_iterator sit = tagsToOpen.begin();
+               vector<xml::FontTag>::const_iterator sen = tagsToOpen.end();
                for (; sit != sen; ++sit)
                        xs << *sit;
 
@@ -3399,7 +3402,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
                        char_type c = getUChar(buf.masterBuffer()->params(),
                                               runparams, i);
                        if (c == ' ' && (style.free_spacing || runparams.free_spacing))
-                               xs << XHTMLStream::ESCAPE_NONE << "&nbsp;";
+                               xs << XMLStream::ESCAPE_NONE << "&nbsp;";
                        else
                                xs << c;
                }
index 3b5f2b81624b72ac968a529fda1c350ea05748ea..60b829e813ced09832c6edbf56dec0e5b005f77e 100644 (file)
@@ -50,7 +50,7 @@ class PainterInfo;
 class ParagraphParameters;
 class TocBackend;
 class WordLangTuple;
-class XHTMLStream;
+class XMLStream;
 class otexstream;
 
 class FontSpan {
@@ -203,7 +203,7 @@ public:
        pos_type firstWordDocBook(odocstream & os, OutputParams const & runparams) const;
 
        /// Output the first word of a paragraph, return the position where it left.
-       pos_type firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runparams) const;
+       pos_type firstWordLyXHTML(XMLStream & xs, OutputParams const & runparams) const;
 
        /// Writes to stream the docbook representation
        void simpleDocBookOnePar(Buffer const & buf,
@@ -211,10 +211,11 @@ public:
                                 OutputParams const & runparams,
                                 Font const & outerfont,
                                 pos_type initial = 0) const;
+
        /// \return any material that has had to be deferred until after the
        /// paragraph has closed.
        docstring simpleLyXHTMLOnePar(Buffer const & buf,
-                                XHTMLStream & xs,
+                                XMLStream & xs,
                                 OutputParams const & runparams,
                                 Font const & outerfont,
                                 bool start_paragraph = true,
index 1d3ce0db5cfe196c718e632629dffa21f7276265..0cbe3e9a76d60f7ca316bd3ad0d719b7f79e80ab 100644 (file)
@@ -31,7 +31,7 @@
 #include "LyXRC.h"
 #include "Row.h"
 #include "OutputParams.h"
-#include "sgml.h"
+#include "xml.h"
 #include "TextClass.h"
 #include "TexRow.h"
 
index 77a14498269b5a16af8d3f28cfb3515e7b0dfb20..904ac81686c2708bf4f088a39291e86e0e0dcf71 100644 (file)
@@ -472,7 +472,7 @@ int Inset::docbook(odocstream &, OutputParams const &) const
 }
 
 
-docstring Inset::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring Inset::xhtml(XMLStream & xs, OutputParams const &) const
 {
        xs << "[[Inset: " << from_ascii(insetName(lyxCode())) << "]]";
        return docstring();
index 457ff44cb916095218ec24ea255853c888268206..1366ca59f2196a2de3eec9320652537c89f98ed7 100644 (file)
@@ -64,7 +64,7 @@ class ParIterator;
 class Text;
 class TocBackend;
 class TocList;
-class XHTMLStream;
+class XMLStream;
 class otexstream;
 
 namespace graphics { class PreviewLoader; }
@@ -343,11 +343,11 @@ public:
        /// docbook output
        virtual int docbook(odocstream & os, OutputParams const &) const;
        /// XHTML output
-       /// the inset is expected to write XHTML to the XHTMLStream
+       /// the inset is expected to write XHTML to the XMLStream
        /// \return any "deferred" material that should be written outside the
        /// normal stream, and which will in fact be written after the current
        /// paragraph closes. this is appropriate e.g. for floats.
-       virtual docstring xhtml(XHTMLStream & xs, OutputParams const &) const;
+       virtual docstring xhtml(XMLStream &, OutputParams const &) const;
 
        /// Writes a string representation of the inset to the odocstream.
        /// This one should be called when you want the whole contents of
index 15d3b85fd254b43c8992dc5039451a88837c0d68..8cc3e087227560c337fb16cf0374b6a10667d3a4 100644 (file)
@@ -56,7 +56,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const { return 0; }
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const
+       docstring xhtml(XMLStream &, OutputParams const &) const
                { return docstring(); }
        ///
        void write(std::ostream & os) const;
index c70e92ea734866aa16ba6f0cc0a1cef80e0775f4..85c6a5990f289b0699495e16999983bd4bf70c1d 100644 (file)
@@ -343,7 +343,7 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype, bool c
 }
 
 
-docstring InsetBibitem::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetBibitem::xhtml(XMLStream & xs, OutputParams const &) const
 {
        // FIXME XHTML
        // XHTML 1.1 doesn't have the "name" attribute for <a>, so we have to use
@@ -352,11 +352,11 @@ docstring InsetBibitem::xhtml(XHTMLStream & xs, OutputParams const &) const
        // handle jumping to ids. If we don't do that, though, we can just put the
        // id into the span tag.
        string const attrs =
-               "id='LyXCite-" + to_utf8(html::cleanAttr(getParam("key"))) + "'";
-       xs << html::CompTag("a", attrs);
-       xs << html::StartTag("span", "class='bibitemlabel'");
+               "id='LyXCite-" + to_utf8(xml::cleanAttr(getParam("key"))) + "'";
+       xs << xml::CompTag("a", attrs);
+       xs << xml::StartTag("span", "class='bibitemlabel'");
        xs << bibLabel();
-       xs << html::EndTag("span");
+       xs << xml::EndTag("span");
        return docstring();
 }
 
index eda3a4626f8fee03a1fdc98e7902504bc67f873c..22e3ac112b2aa94e31cac39dc3b7819039a91ea3 100644 (file)
@@ -58,7 +58,7 @@ public:
        int plaintext(odocstringstream &, OutputParams const &,
                      size_t max_length = INT_MAX) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void collectBibKeys(InsetIterator const &, support::FileNameList &) const;
        /// update the counter of this inset
index 15953e1cded7dec4a6455e55c8c18e05df1e02ce..3bfc5930130b575825ba7c3cebf4832abb839a8e 100644 (file)
@@ -28,6 +28,7 @@
 #include "LaTeXFeatures.h"
 #include "output_latex.h"
 #include "output_xhtml.h"
+#include "xml.h"
 #include "OutputParams.h"
 #include "PDFOptions.h"
 #include "texstream.h"
@@ -1008,7 +1009,7 @@ int InsetBibtex::plaintext(odocstringstream & os,
                refoutput += "[" + entry.label() + "] ";
                // FIXME Right now, we are calling BibInfo::getInfo on the key,
                // which will give us all the cross-referenced info. But for every
-               // entry, so there's a lot of repitition. This should be fixed.
+               // entry, so there's a lot of repetition. This should be fixed.
                refoutput += bibinfo.getInfo(entry.key(), buffer(), ci) + "\n\n";
        }
        os << refoutput;
@@ -1019,7 +1020,7 @@ int InsetBibtex::plaintext(odocstringstream & os,
 // FIXME
 // docstring InsetBibtex::entriesAsXHTML(vector<docstring> const & entries)
 // And then here just: entriesAsXHTML(buffer().masterBibInfo().citedEntries())
-docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetBibtex::xhtml(XMLStream & xs, OutputParams const &) const
 {
        BiblioInfo const & bibinfo = buffer().masterBibInfo();
        bool const all_entries = getParam("btprint") == "btPrintAll";
@@ -1034,10 +1035,10 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
        ci.richtext = true;
        ci.max_key_size = UINT_MAX;
 
-       xs << html::StartTag("h2", "class='bibtex'")
+       xs << xml::StartTag("h2", "class='bibtex'")
                << reflabel
-               << html::EndTag("h2")
-               << html::StartTag("div", "class='bibtex'");
+               << xml::EndTag("h2")
+               << xml::StartTag("div", "class='bibtex'");
 
        // Now we loop over the entries
        vector<docstring>::const_iterator vit = cites.begin();
@@ -1049,27 +1050,27 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
 
                BibTeXInfo const & entry = biit->second;
                string const attr = "class='bibtexentry' id='LyXCite-"
-                   + to_utf8(html::cleanAttr(entry.key())) + "'";
-               xs << html::StartTag("div", attr);
+                   + to_utf8(xml::cleanAttr(entry.key())) + "'";
+               xs << xml::StartTag("div", attr);
 
                // don't print labels if we're outputting all entries
                if (!all_entries) {
-                       xs << html::StartTag("span", "class='bibtexlabel'")
+                       xs << xml::StartTag("span", "class='bibtexlabel'")
                                << entry.label()
-                               << html::EndTag("span");
+                               << xml::EndTag("span");
                }
 
                // FIXME Right now, we are calling BibInfo::getInfo on the key,
                // which will give us all the cross-referenced info. But for every
                // entry, so there's a lot of repitition. This should be fixed.
-               xs << html::StartTag("span", "class='bibtexinfo'")
-                  << XHTMLStream::ESCAPE_AND
+               xs << xml::StartTag("span", "class='bibtexinfo'")
+                  << XMLStream::ESCAPE_AND
                   << bibinfo.getInfo(entry.key(), buffer(), ci)
-                  << html::EndTag("span")
-                  << html::EndTag("div")
-                  << html::CR();
+                  << xml::EndTag("span")
+                  << xml::EndTag("div")
+                  << xml::CR();
        }
-       xs << html::EndTag("div");
+       xs << xml::EndTag("div");
        return docstring();
 }
 
index a46619367bc4df2ab02f826f64ead6c8331d9939..db7005d2dadfab53fd25113b9d0e38746cbf3122 100644 (file)
@@ -64,7 +64,9 @@ public:
        ///
        void validate(LaTeXFeatures &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
+       ///
+       docstring docbook(XMLStream &, OutputParams const &) const;
        ///
        std::string contextMenuName() const;
        //@}
index 8a867ee234fc4066a81040aae14b2c4847ad46c4..0b2ab3eea1fca9e15a597fa720ee7892fab972ab 100644 (file)
@@ -721,7 +721,7 @@ int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
+docstring InsetBox::xhtml(XMLStream & xs, OutputParams const & runparams) const
 {
        // construct attributes
        string attrs = "class='" + params_.type + "'";
@@ -737,10 +737,10 @@ docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) cons
        if (!style.empty())
                attrs += " style='" + style + "'";
 
-       xs << html::StartTag("div", attrs);
+       xs << xml::StartTag("div", attrs);
        XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag;
        docstring defer = InsetText::insetAsXHTML(xs, runparams, opts);
-       xs << html::EndTag("div");
+       xs << xml::EndTag("div");
        xs << defer;
        return docstring();
 }
index 6dd671c9a4deaad01b8e0c1d7dc685a4b9e03c5f..4e9894548c17332e5aaf10d412713463b3380734 100644 (file)
@@ -137,7 +137,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
        ///
index ad7cbc5cdc21fb6f83efc517a2be06a1842790b8..6d87af7fae15de858004f596e6af7dc75745a5f6 100644 (file)
@@ -333,7 +333,7 @@ int InsetBranch::docbook(odocstream & os,
 }
 
 
-docstring InsetBranch::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetBranch::xhtml(XMLStream & xs, OutputParams const & rp) const
 {
        if (producesOutput()) {
                OutputParams newrp = rp;
index be926d99f5fac324410526672674777407ffdc7a..1723fd1484276d88297195ed680051b7651c0e14 100644 (file)
@@ -78,7 +78,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void toString(odocstream &) const;
        ///
index 32ead246794cf0d863d1d17d379da58270d9df50..42f951989ce0cf62af9fc437a2dc23bdfb798f14 100644 (file)
@@ -302,7 +302,7 @@ int InsetCaption::docbook(odocstream & os,
 }
 
 
-docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetCaption::xhtml(XMLStream & xs, OutputParams const & rp) const
 {
        if (rp.html_disable_captions)
                return docstring();
@@ -317,9 +317,9 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const
                else
                        attr = attr + " class='" + our_class + "'";
        }
-       xs << html::StartTag(tag, attr);
+       xs << xml::StartTag(tag, attr);
        docstring def = getCaptionAsHTML(xs, rp);
-       xs << html::EndTag(tag);
+       xs << xml::EndTag(tag);
        return def;
 }
 
@@ -364,7 +364,7 @@ int InsetCaption::getCaptionAsPlaintext(odocstream & os,
 }
 
 
-docstring InsetCaption::getCaptionAsHTML(XHTMLStream & xs,
+docstring InsetCaption::getCaptionAsHTML(XMLStream & xs,
                        OutputParams const & runparams) const
 {
        xs << full_label_ << ' ';
index a651a71a5641be5e9dfcd3e0df51be982dba31b7..be0d163041ef43504aab31f3135d90d7d6664476 100644 (file)
@@ -31,7 +31,7 @@ public:
        /// return the caption text
        int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const;
        /// return the caption text as HTML
-       docstring getCaptionAsHTML(XHTMLStream & os, OutputParams const &) const;
+       docstring getCaptionAsHTML(XMLStream & os, OutputParams const &) const;
        ///
        std::string contextMenuName() const;
 private:
@@ -78,7 +78,7 @@ private:
        ///
        int docbook(odocstream & os, OutputParams const & runparams) const;
        ///
-       docstring xhtml(XHTMLStream & os, OutputParams const & runparams) const;
+       docstring xhtml(XMLStream & os, OutputParams const & runparams) const;
        ///
        void addToToc(DocIterator const & di, bool output_active, UpdateType utype,
                      TocBackend & backend) const;
index 1a2e5f0670f64ab07c1edd2b608c610e79d9ec38..61c9acc3b8ac492aa97ad84f2c3339d741fab7a3 100644 (file)
@@ -87,11 +87,11 @@ docstring InsetCaptionable::getCaptionHTML(OutputParams const & runparams) const
                return docstring();
 
        odocstringstream ods;
-       XHTMLStream xs(ods);
+       XMLStream xs(ods);
        docstring def = ins->getCaptionAsHTML(xs, runparams);
        if (!def.empty())
                // should already have been escaped
-               xs << XHTMLStream::ESCAPE_NONE << def << '\n';
+               xs << XMLStream::ESCAPE_NONE << def << '\n';
        return ods.str();
 }
 
index 497f313f45b7f32a8f0fab5c3be32702497a7077..0335b9c771d9b21a3b8231803cdedebae657e232 100644 (file)
@@ -322,8 +322,8 @@ inline docstring wrapCitation(docstring const & key,
                return content;
        // we have to do the escaping here, because we will ultimately
        // write this as a raw string, so as not to escape the tags.
-       return "<a href='#LyXCite-" + html::cleanAttr(key) + "'>" +
-                       html::htmlize(content, XHTMLStream::ESCAPE_ALL) + "</a>";
+       return "<a href='#LyXCite-" + xml::cleanAttr(key) + "'>" +
+                       xml::xmlize(content, XMLStream::ESCAPE_ALL) + "</a>";
 }
 
 } // anonymous namespace
@@ -554,14 +554,14 @@ int InsetCitation::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetCitation::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetCitation::xhtml(XMLStream & xs, OutputParams const &) const
 {
        string const & cmd = getCmdName();
        if (cmd == "nocite")
                return docstring();
 
        // have to output this raw, because generateLabel() will include tags
-       xs << XHTMLStream::ESCAPE_NONE << generateLabel(true);
+       xs << XMLStream::ESCAPE_NONE << generateLabel(true);
 
        return docstring();
 }
index b2a738cd9e10af24a4e95ae91e55d18d0eef5b69..c7cd8dcb604b1d8469bbd20b5e8d2aa7328456e6 100644 (file)
@@ -58,7 +58,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void toString(odocstream &) const;
        ///
index 5b2d1dbf31d7924ca9488226e837c54b63cbcbf0..85efd3add2d027f61c9ab359dae88bbd5ef7f2d2 100644 (file)
@@ -17,7 +17,7 @@
 #include "LaTeXFeatures.h"
 #include "OutputParams.h"
 #include "output_xhtml.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "TextClass.h"
 
@@ -194,7 +194,7 @@ int InsetCounter::docbook(odocstream &, OutputParams const &) const
 }
 
 
-docstring InsetCounter::xhtml(XHTMLStream &, OutputParams const &) const
+docstring InsetCounter::xhtml(XMLStream &, OutputParams const &) const
 {
        // Here, we need to track counter values ourselves,
        // since unlike in the LaTeX case, there is no external
index a050532e092a0a90681796cf66c0f1a3b9242866..65334a3836f62838c36885d7d9dbe9aaacd79257 100644 (file)
@@ -41,7 +41,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void toString(odocstream &) const;
        ///
index e3863ea09df1e244be261d2f92f1e1dd4dafa7b6..403df75032da7d1c5263c65e785b42be7d68cbd1 100644 (file)
@@ -183,7 +183,7 @@ string InsetERT::params2string(CollapseStatus status)
 }
 
 
-docstring InsetERT::xhtml(XHTMLStream &, OutputParams const &) const
+docstring InsetERT::xhtml(XMLStream &, OutputParams const &) const
 {
        return docstring();
 }
index 30938e0ee0a06e06ef933085eeca75d4aafb1ca2..6ef43760d9f053019dbc0eddab6c36d6bb431359 100644 (file)
@@ -54,7 +54,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const {}
        /// should paragraph indendation be omitted in any case?
index f604a1fb9d2e0028005a57524e643037b60e35c9..7fd96cbb1d277967b3ef3a50e407a2e85d410506 100644 (file)
@@ -33,6 +33,7 @@
 #include "output_latex.h"
 #include "output_xhtml.h"
 #include "texstream.h"
+#include "xml.h"
 #include "TocBackend.h"
 
 #include "frontends/alert.h"
@@ -789,7 +790,7 @@ int InsetExternal::docbook(odocstream & os,
 }
 
 
-docstring InsetExternal::xhtml(XHTMLStream & xs,
+docstring InsetExternal::xhtml(XMLStream & xs,
                        OutputParams const & runparams) const
 {
        bool const external_in_tmpdir = !runparams.nice;
@@ -804,7 +805,7 @@ docstring InsetExternal::xhtml(XHTMLStream & xs,
                if (buffer().isClone() && buffer().isExporting())
                        throw ConversionException();
        }
-       xs << XHTMLStream::ESCAPE_NONE << ods.str();
+       xs << XMLStream::ESCAPE_NONE << ods.str();
        return docstring();
 }
 
index eefce3a10d52d8f309a9151831aace0b26ca2eaf..b03e416de822f58fcba7cf8a9dc1203f0b5e34c8 100644 (file)
@@ -149,7 +149,7 @@ public:
        int docbook(odocstream &, OutputParams const &) const;
        /// For now, this does nothing. Someone who knows about this
        /// should see what needs doing for XHTML output.
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        /// Update needed features for this inset.
        void validate(LaTeXFeatures & features) const;
        ///
index 5e1dd3d7fcfd18780258026dc386fe9b26e47e6a..a37b9549479b229078f84e38598b95ea323d5a13 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <config.h>
+#include <xml.h>
 
 #include "InsetFloat.h"
 #include "InsetCaption.h"
@@ -32,6 +33,7 @@
 #include "TexRow.h"
 #include "texstream.h"
 #include "TextClass.h"
+#include "InsetList.h"
 
 #include "support/debug.h"
 #include "support/docstream.h"
@@ -334,7 +336,7 @@ void InsetFloat::validate(LaTeXFeatures & features) const
 }
 
 
-docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetFloat::xhtml(XMLStream & xs, OutputParams const & rp) const
 {
        FloatList const & floats = buffer().params().documentClass().floats();
        Floating const & ftype = floats.getType(params_.type);
@@ -342,12 +344,12 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
        string const & attr = ftype.htmlAttrib();
 
        odocstringstream ods;
-       XHTMLStream newxs(ods);
-       newxs << html::StartTag(htmltype, attr);
+       XMLStream newxs(ods);
+       newxs << xml::StartTag(htmltype, attr);
        InsetText::XHTMLOptions const opts =
                InsetText::WriteLabel | InsetText::WriteInnerTag;
        docstring deferred = InsetText::insetAsXHTML(newxs, rp, opts);
-       newxs << html::EndTag(htmltype);
+       newxs << xml::EndTag(htmltype);
 
        if (rp.inFloat == OutputParams::NONFLOAT) {
                // In this case, this float needs to be deferred, but we'll put it
@@ -358,7 +360,7 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
                // we can write to the stream.
                // Note that things will already have been escaped, so we do not
                // want to escape them again.
-               xs << XHTMLStream::ESCAPE_NONE << ods.str();
+               xs << XMLStream::ESCAPE_NONE << ods.str();
        }
        return deferred;
 }
index 53c584c40abe974ad74e0c4bc3cb5046dd272053..f58c89c2f6945a8b289c467e6a7d6130bd288a52 100644 (file)
@@ -101,7 +101,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        bool insetAllowed(InsetCode) const;
        /** returns false if, when outputing LaTeX, font changes should
index 1ba8dea8e7501a2221e13df319c0d23b55baca9a..e711feebf4c6db3e397a2c441fcb48111cf5d0c4 100644 (file)
@@ -172,7 +172,7 @@ int InsetFloatList::plaintext(odocstringstream & os,
 }
 
 
-docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
+docstring InsetFloatList::xhtml(XMLStream &, OutputParams const & op) const {
        FloatList const & floats = buffer().params().documentClass().floats();
        FloatList::const_iterator cit = floats[to_ascii(getParam("type"))];
 
@@ -239,14 +239,14 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
        // that's how we deal with the fact that we're probably inside a standard
        // paragraph, and we don't want to be.
        odocstringstream ods;
-       XHTMLStream xs(ods);
+       XMLStream xs(ods);
 
        InsetLayout const & il = getLayout();
        string const & tag = il.htmltag();
-       xs << html::StartTag("div", "class='toc toc-floats'");
-       xs << html::StartTag(tag, tocattr)
+       xs << xml::StartTag("div", "class='toc toc-floats'");
+       xs << xml::StartTag(tag, tocattr)
                 << toclabel
-                << html::EndTag(tag);
+                << xml::EndTag(tag);
 
        Toc::const_iterator it = toc->begin();
        Toc::const_iterator const en = toc->end();
@@ -255,14 +255,14 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
                        continue;
                Paragraph const & par = it->dit().innerParagraph();
                string const attr = "class='lyxtoc-floats lyxtoc-" + toctype + "'";
-               xs << html::StartTag("div", attr);
+               xs << xml::StartTag("div", attr);
                string const parattr = "href='#" + par.magicLabel() + "' class='lyxtoc-floats'";
-               xs << html::StartTag("a", parattr)
+               xs << xml::StartTag("a", parattr)
                   << it->str()
-                  << html::EndTag("a");
-               xs << html::EndTag("div");
+                  << xml::EndTag("a");
+               xs << xml::EndTag("div");
        }
-       xs << html::EndTag("div");
+       xs << xml::EndTag("div");
        return ods.str();
 }
 
index 7d1df4765aa015fa1a4dda8d02aef84744078016..78417096407a1ad23ccc5f6b1bcdf44ea756c751 100644 (file)
@@ -45,7 +45,7 @@ public:
        int plaintext(odocstringstream & ods, OutputParams const & op,
                      size_t max_length = INT_MAX) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
index 92de4c043f8f98386671fbaa541b3072aafc77e3..a5a9ef320e9cd0b98bad58501dfeba65f16b66ad 100644 (file)
@@ -68,7 +68,7 @@ TODO
 #include "Mover.h"
 #include "OutputParams.h"
 #include "output_xhtml.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "TocBackend.h"
 
@@ -107,7 +107,7 @@ namespace Alert = frontend::Alert;
 namespace {
 
 /// Find the most suitable image format for images in \p format
-/// Note that \p format may be unknown (i. e. an empty string)
+/// Note that \p format may be unknown (i.e. an empty string)
 string findTargetFormat(string const & format, OutputParams const & runparams)
 {
        // Are we latexing to DVI or PDF?
@@ -177,7 +177,7 @@ void readInsetGraphics(Lexer & lex, Buffer const & buf, bool allowOrigin,
 
 
 InsetGraphics::InsetGraphics(Buffer * buf)
-       : Inset(buf), graphic_label(sgml::uniqueID(from_ascii("graph"))),
+       : Inset(buf), graphic_label(xml::uniqueID(from_ascii("graph"))),
          graphic_(new RenderGraphic(this))
 {
 }
@@ -185,7 +185,7 @@ InsetGraphics::InsetGraphics(Buffer * buf)
 
 InsetGraphics::InsetGraphics(InsetGraphics const & ig)
        : Inset(ig),
-         graphic_label(sgml::uniqueID(from_ascii("graph"))),
+         graphic_label(xml::uniqueID(from_ascii("graph"))),
          graphic_(new RenderGraphic(*ig.graphic_, this))
 {
        setParams(ig.params());
@@ -502,10 +502,6 @@ docstring InsetGraphics::createDocBookAttributes() const
        // Calculate the options part of the command, we must do it to a string
        // stream since we copied the code from createLatexParams() ;-)
 
-       // FIXME: av: need to translate spec -> Docbook XSL spec
-       // (http://www.sagehill.net/docbookxsl/ImageSizing.html)
-       // Right now it only works with my version of db2latex :-)
-
        odocstringstream options;
        double const scl = convert<double>(params().scale);
        if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
@@ -942,14 +938,14 @@ static int writeImageObject(char const * format, odocstream & os,
 {
        if (runparams.flavor != OutputParams::XML)
                os << "<![ %output.print." << format
-                        << "; [" << endl;
+                  << "; [" << endl;
 
        os <<"<imageobject><imagedata fileref=\"&"
-                << graphic_label
-                << ";."
-                << format
-                << "\" "
-                << attributes;
+          << graphic_label
+          << ";."
+          << format
+          << "\" "
+          << attributes;
 
        if (runparams.flavor == OutputParams::XML)
                os <<  " role=\"" << format << "\"/>" ;
@@ -1078,7 +1074,7 @@ string InsetGraphics::prepareHTMLFile(OutputParams const & runparams) const
 }
 
 
-docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
+docstring InsetGraphics::xhtml(XMLStream & xs, OutputParams const & op) const
 {
        string const output_file = op.dryrun ? string() : prepareHTMLFile(op);
 
@@ -1087,7 +1083,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
                        << params().filename << "' for output. File missing?");
                string const attr = "src='" + params().filename.absFileName()
                                    + "' alt='image: " + output_file + "'";
-               xs << html::CompTag("img", attr);
+               xs << xml::CompTag("img", attr);
                return docstring();
        }
 
@@ -1115,7 +1111,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
 
        string const attr = imgstyle + "src='" + output_file + "' alt='image: "
                            + output_file + "'";
-       xs << html::CompTag("img", attr);
+       xs << xml::CompTag("img", attr);
        return docstring();
 }
 
index be4a31773ada009df95bac9eedfcfbaa50fd3f6b..46a746b9d4ca9c8cbe51e66e0e154b1d9d791f53 100644 (file)
@@ -80,7 +80,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream & os, OutputParams const &) const;
+       docstring xhtml(XMLStream & os, OutputParams const &) const;
        /** Tell LyX what the latex features you need i.e. what latex packages
            you need to be included.
         */
index a225a8eb0bd55fbd94fc1ddec7d53f6906006f5e..6246ff840a53ac3752fb1fbf9b59b009b09844f5 100644 (file)
@@ -22,7 +22,7 @@
 #include "LaTeXFeatures.h"
 #include "OutputParams.h"
 #include "output_xhtml.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 
 #include "support/docstream.h"
@@ -218,20 +218,20 @@ int InsetHyperlink::docbook(odocstream & os, OutputParams const &) const
        os << "<ulink url=\""
           << subst(getParam("target"), from_ascii("&"), from_ascii("&amp;"))
           << "\">"
-          << sgml::escapeString(getParam("name"))
+          << xml::escapeString(getParam("name"))
           << "</ulink>";
        return 0;
 }
 
 
-docstring InsetHyperlink::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetHyperlink::xhtml(XMLStream & xs, OutputParams const &) const
 {
        docstring const & target =
-               html::htmlize(getParam("target"), XHTMLStream::ESCAPE_AND);
+               xml::xmlize(getParam("target"), XMLStream::ESCAPE_AND);
        docstring const & name   = getParam("name");
-       xs << html::StartTag("a", to_utf8("href=\"" + target + "\""));
+       xs << xml::StartTag("a", to_utf8("href=\"" + target + "\""));
        xs << (name.empty() ? target : name);
-       xs << html::EndTag("a");
+       xs << xml::EndTag("a");
        return docstring();
 }
 
index d5da130d763e3d0e58486501ad58feb4056baa96..0e0e8d34465320821e9ddb43feea6ea367f23b36 100644 (file)
@@ -53,7 +53,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        //@}
 
        /// \name Static public methods obligated for InsetCommand derived classes
index ac2b7d8422a11fe540784956c3edfaefc662935f..e11f0cc1f5186924178c21fe43eeef95ec580bc4 100644 (file)
@@ -233,7 +233,7 @@ void InsetIPA::latex(otexstream & os, OutputParams const & runparams_in) const
 }
 
 
-docstring InsetIPA::xhtml(XHTMLStream & xs, OutputParams const & runparams_in) const
+docstring InsetIPA::xhtml(XMLStream & xs, OutputParams const & runparams_in) const
 {
        OutputParams runparams(runparams_in);
        runparams.inIPA = true;
index d499edfdc81ccfe7ad07d222d763092b03fa8105..003c1bad56cb139257d625791e417eaf4deabdfd 100644 (file)
@@ -77,7 +77,7 @@ public:
        ///
        void latex(otexstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream & xs, OutputParams const &) const;
+       docstring xhtml(XMLStream & xs, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
index 4b2369b3796741fb6177bd1f876da9313146f893..91c5c88176438ac6e473aac22634aaa4b99459bc 100644 (file)
@@ -312,7 +312,7 @@ int InsetIPADeco::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetIPADeco::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
+docstring InsetIPADeco::xhtml(XMLStream & xs, OutputParams const & runparams) const
 {
        // FIXME: Like in plaintext, the combining characters "&#x361;" (toptiebar)
        // or "&#x35c;" (bottomtiebar) would need to be inserted just in the mid
@@ -556,29 +556,29 @@ int InsetIPAChar::docbook(odocstream & /*os*/, OutputParams const &) const
 }
 
 
-docstring InsetIPAChar::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetIPAChar::xhtml(XMLStream & xs, OutputParams const &) const
 {
        switch (kind_) {
        case TONE_FALLING:
-               xs << XHTMLStream::ESCAPE_NONE << "&#x2e5;"
-                  << XHTMLStream::ESCAPE_NONE << "&#x2e9;";
+               xs << XMLStream::ESCAPE_NONE << "&#x2e5;"
+                  << XMLStream::ESCAPE_NONE << "&#x2e9;";
                break;
        case TONE_RISING:
-               xs << XHTMLStream::ESCAPE_NONE << "&#x2e9;"
-                  << XHTMLStream::ESCAPE_NONE << "&#x2e5;";
+               xs << XMLStream::ESCAPE_NONE << "&#x2e9;"
+                  << XMLStream::ESCAPE_NONE << "&#x2e5;";
                break;
        case TONE_HIGH_RISING:
-               xs << XHTMLStream::ESCAPE_NONE << "&#x2e7;"
-                  << XHTMLStream::ESCAPE_NONE << "&#x2e5;";
+               xs << XMLStream::ESCAPE_NONE << "&#x2e7;"
+                  << XMLStream::ESCAPE_NONE << "&#x2e5;";
                break;
        case TONE_LOW_RISING:
-               xs << XHTMLStream::ESCAPE_NONE << "&#x2e9;"
-                  << XHTMLStream::ESCAPE_NONE << "&#x2e7;";
+               xs << XMLStream::ESCAPE_NONE << "&#x2e9;"
+                  << XMLStream::ESCAPE_NONE << "&#x2e7;";
                break;
        case TONE_HIGH_RISING_FALLING:
-               xs << XHTMLStream::ESCAPE_NONE << "&#x2e8;"
-                  << XHTMLStream::ESCAPE_NONE << "&#x2e5;"
-                  << XHTMLStream::ESCAPE_NONE << "&#x2e8;";
+               xs << XMLStream::ESCAPE_NONE << "&#x2e8;"
+                  << XMLStream::ESCAPE_NONE << "&#x2e5;"
+                  << XMLStream::ESCAPE_NONE << "&#x2e8;";
                break;
        }
        return docstring();
index fb35adb763f213ffb079e29cf89880cea0e26c21..b985ef3b7b5707706db3453e00a9542693442d2e 100644 (file)
@@ -81,7 +81,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
@@ -152,7 +152,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void toString(odocstream &) const;
        ///
index 5f1af32640a5cf19a68b676c7ac938b28a92f4a4..ba52db91c2d30de45a353bb86a31b962b5c7e6f5 100644 (file)
@@ -937,7 +937,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetInclude::xhtml(XMLStream & xs, OutputParams const & rp) const
 {
        if (rp.inComment)
                 return docstring();
@@ -947,11 +947,11 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const
        bool const listing = isListings(params());
        if (listing || isVerbatim(params())) {
                if (listing)
-                       xs << html::StartTag("pre");
+                       xs << xml::StartTag("pre");
                // FIXME: We don't know the encoding of the file, default to UTF-8.
                xs << includedFileName(buffer(), params()).fileContents("UTF-8");
                if (listing)
-                       xs << html::EndTag("pre");
+                       xs << xml::EndTag("pre");
                return docstring();
        }
 
@@ -988,10 +988,10 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const
                op.par_end = 0;
                ibuf->writeLyXHTMLSource(xs.os(), op, Buffer::IncludedFile);
        } else
-               xs << XHTMLStream::ESCAPE_NONE
+               xs << XMLStream::ESCAPE_NONE
                   << "<!-- Included file: "
                   << from_utf8(included_file.absFileName())
-                  << XHTMLStream::ESCAPE_NONE
+                  << XMLStream::ESCAPE_NONE
                         << " -->";
        
        return docstring();
index 66487bc934c45a805dab92965da823aef0c36be2..64e01e46d525e7a3a0482eb7df4bccbdd7b0c68c 100644 (file)
@@ -96,7 +96,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
        ///
@@ -159,8 +159,8 @@ private:
        /// get the text displayed on the button
        docstring screenLabel() const;
        //@}
-
-       /// holds the entity name that defines the file location (SGML)
+       
+       /// holds the entity name that defines the file location (XML)
        docstring const include_label;
 
        /// The pointer never changes although *preview_'s contents may.
index 5e375e9fdbea0ca40911a228b391da94d96f29c6..11a854528074e654b70946a543f10fb61bcabc62 100644 (file)
@@ -27,7 +27,7 @@
 #include "Lexer.h"
 #include "output_latex.h"
 #include "output_xhtml.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "TextClass.h"
 #include "TocBackend.h"
@@ -55,7 +55,7 @@ namespace lyx {
 
 
 InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
-       : InsetCollapsible(buf), params_(params)
+        : InsetCollapsible(buf), params_(params)
 {}
 
 
@@ -67,7 +67,7 @@ void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) cons
        otexstringstream os;
 
        if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
-           && params_.index != "idx") {
+               && params_.index != "idx") {
                os << "\\sindex[";
                os << escape(params_.index);
                os << "]{";
@@ -112,12 +112,12 @@ void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) cons
                        LYXERR0("The `|' separator was not found in the plaintext version!");
        }
 
-       // Separate the entires and subentries, i.e., split on "!"
+       // Separate the entries and subentries, i.e., split on "!"
        // FIXME This would do the wrong thing with escaped ! characters
        std::vector<docstring> const levels =
-               getVectorFromString(latexstr, from_ascii("!"), true);
+                       getVectorFromString(latexstr, from_ascii("!"), true);
        std::vector<docstring> const levels_plain =
-               getVectorFromString(plainstr, from_ascii("!"), true);
+                       getVectorFromString(plainstr, from_ascii("!"), true);
 
        vector<docstring>::const_iterator it = levels.begin();
        vector<docstring>::const_iterator end = levels.end();
@@ -138,27 +138,27 @@ void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) cons
                if (contains(*it, '\\') && !contains(*it, '@')) {
                        // Plaintext might return nothing (e.g. for ERTs)
                        docstring const spart =
-                               (it2 < levels_plain.end() && !(*it2).empty())
-                               ? *it2 : *it;
+                                       (it2 < levels_plain.end() && !(*it2).empty())
+                                       ? *it2 : *it;
                        // Now we need to validate that all characters in
                        // the sorting part are representable in the current
                        // encoding. If not try the LaTeX macro which might
                        // or might not be a good choice, and issue a warning.
                        pair<docstring, docstring> spart_latexed =
-                               runparams.encoding->latexString(spart, runparams.dryrun);
+                                       runparams.encoding->latexString(spart, runparams.dryrun);
                        if (!spart_latexed.second.empty())
-                                       LYXERR0("Uncodable character in index entry. Sorting might be wrong!");
+                               LYXERR0("Uncodable character in index entry. Sorting might be wrong!");
                        if (spart != spart_latexed.first && !runparams.dryrun) {
                                // FIXME: warning should be passed to the error dialog
                                frontend::Alert::warning(_("Index sorting failed"),
-                               bformat(_("LyX's automatic index sorting algorithm faced\n"
-                                 "problems with the entry '%1$s'.\n"
-                                 "Please specify the sorting of this entry manually, as\n"
-                                 "explained in the User Guide."), spart));
+                                                                                bformat(_("LyX's automatic index sorting algorithm faced\n"
+                                                                                                                  "problems with the entry '%1$s'.\n"
+                                                                                                                  "Please specify the sorting of this entry manually, as\n"
+                                                                                                                  "explained in the User Guide."), spart));
                        }
                        // remove remaining \'s for the sorting part
                        docstring const ppart =
-                               subst(spart_latexed.first, from_ascii("\\"), docstring());
+                                       subst(spart_latexed.first, from_ascii("\\"), docstring());
                        os << ppart;
                        os << '@';
                }
@@ -191,13 +191,13 @@ int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetIndex::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetIndex::xhtml(XMLStream & xs, OutputParams const &) const
 {
        // we just print an anchor, taking the paragraph ID from
        // our own interior paragraph, which doesn't get printed
        std::string const magic = paragraphs().front().magicLabel();
        std::string const attr = "id='" + magic + "'";
-       xs << html::CompTag("a", attr);
+       xs << xml::CompTag("a", attr);
        return docstring();
 }
 
@@ -707,7 +707,7 @@ bool operator<(IndexEntry const & lhs, IndexEntry const & rhs)
 } // namespace
 
 
-docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
+docstring InsetPrintIndex::xhtml(XMLStream &, OutputParams const & op) const
 {
        BufferParams const & bp = buffer().masterBuffer()->params();
 
@@ -747,14 +747,14 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
        // that's how we deal with the fact that we're probably inside a standard
        // paragraph, and we don't want to be.
        odocstringstream ods;
-       XHTMLStream xs(ods);
+       XMLStream xs(ods);
 
-       xs << html::StartTag("div", tocattr);
-       xs << html::StartTag(lay.htmltag(), lay.htmlattr())
+       xs << xml::StartTag("div", tocattr);
+       xs << xml::StartTag(lay.htmltag(), lay.htmlattr())
                 << translateIfPossible(from_ascii("Index"),
                                  op.local_font->language()->lang())
-                << html::EndTag(lay.htmltag());
-       xs << html::StartTag("ul", "class='main'");
+                << xml::EndTag(lay.htmltag());
+       xs << xml::StartTag("ul", "class='main'");
        Font const dummy;
 
        vector<IndexEntry>::const_iterator eit = entries.begin();
@@ -774,11 +774,11 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
                                // close last entry or entries, depending.
                                if (level == 3) {
                                        // close this sub-sub-entry
-                                       xs << html::EndTag("li") << html::CR();
+                                       xs << xml::EndTag("li") << xml::CR();
                                        // is this another sub-sub-entry within the same sub-entry?
                                        if (!eit->same_sub(last)) {
                                                // close this level
-                                               xs << html::EndTag("ul") << html::CR();
+                                               xs << xml::EndTag("ul") << xml::CR();
                                                level = 2;
                                        }
                                }
@@ -789,11 +789,11 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
                                // sub-entry. In that case, we do not want to close anything.
                                if (level == 2 && !eit->same_sub(last)) {
                                        // close sub-entry
-                                       xs << html::EndTag("li") << html::CR();
+                                       xs << xml::EndTag("li") << xml::CR();
                                        // is this another sub-entry with the same main entry?
                                        if (!eit->same_main(last)) {
                                                // close this level
-                                               xs << html::EndTag("ul") << html::CR();
+                                               xs << xml::EndTag("ul") << xml::CR();
                                                level = 1;
                                        }
                                }
@@ -802,7 +802,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
                                // close the entry.
                                if (level == 1 && !eit->same_main(last)) {
                                        // close entry
-                                       xs << html::EndTag("li") << html::CR();
+                                       xs << xml::EndTag("li") << xml::CR();
                                }
                        }
 
@@ -812,7 +812,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
                        // We need to use our own stream, since we will have to
                        // modify what we get back.
                        odocstringstream ent;
-                       XHTMLStream entstream(ent);
+                       XMLStream entstream(ent);
                        OutputParams ours = op;
                        ours.for_toc = true;
                        par.simpleLyXHTMLOnePar(buffer(), entstream, ours, dummy);
@@ -830,8 +830,8 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
 
                        if (level == 3) {
                                // another subsubentry
-                               xs << html::StartTag("li", "class='subsubentry'")
-                                  << XHTMLStream::ESCAPE_NONE << subsub;
+                               xs << xml::StartTag("li", "class='subsubentry'")
+                                  << XMLStream::ESCAPE_NONE << subsub;
                        } else if (level == 2) {
                                // there are two ways we can be here:
                                // (i) we can actually be inside a sub-entry already and be about
@@ -844,14 +844,14 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
                                // note that in this case, too, though, the sub-entry might already
                                // have a sub-sub-entry.
                                if (eit->sub != last.sub)
-                                       xs << html::StartTag("li", "class='subentry'")
-                                          << XHTMLStream::ESCAPE_NONE << sub;
+                                       xs << xml::StartTag("li", "class='subentry'")
+                                          << XMLStream::ESCAPE_NONE << sub;
                                if (!subsub.empty()) {
                                        // it's actually a subsubentry, so we need to start that list
-                                       xs << html::CR()
-                                          << html::StartTag("ul", "class='subsubentry'")
-                                          << html::StartTag("li", "class='subsubentry'")
-                                          << XHTMLStream::ESCAPE_NONE << subsub;
+                                       xs << xml::CR()
+                                          << xml::StartTag("ul", "class='subsubentry'")
+                                          << xml::StartTag("li", "class='subsubentry'")
+                                          << XMLStream::ESCAPE_NONE << subsub;
                                        level = 3;
                                }
                        } else {
@@ -866,20 +866,20 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
                                // note that in this case, too, though, the main entry might already
                                // have a sub-entry, or even a sub-sub-entry.
                                if (eit->main != last.main)
-                                       xs << html::StartTag("li", "class='main'") << main;
+                                       xs << xml::StartTag("li", "class='main'") << main;
                                if (!sub.empty()) {
                                        // there's a sub-entry, too
-                                       xs << html::CR()
-                                          << html::StartTag("ul", "class='subentry'")
-                                          << html::StartTag("li", "class='subentry'")
-                                          << XHTMLStream::ESCAPE_NONE << sub;
+                                       xs << xml::CR()
+                                          << xml::StartTag("ul", "class='subentry'")
+                                          << xml::StartTag("li", "class='subentry'")
+                                          << XMLStream::ESCAPE_NONE << sub;
                                        level = 2;
                                        if (!subsub.empty()) {
                                                // and a sub-sub-entry
-                                               xs << html::CR()
-                                                  << html::StartTag("ul", "class='subsubentry'")
-                                                  << html::StartTag("li", "class='subsubentry'")
-                                                  << XHTMLStream::ESCAPE_NONE << subsub;
+                                               xs << xml::CR()
+                                                  << xml::StartTag("ul", "class='subsubentry'")
+                                                  << xml::StartTag("li", "class='subsubentry'")
+                                                  << XMLStream::ESCAPE_NONE << subsub;
                                                level = 3;
                                        }
                                }
@@ -888,16 +888,16 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
                // finally, then, we can output the index link itself
                string const parattr = "href='#" + par.magicLabel() + "'";
                xs << (entry_number == 0 ? ":" : ",");
-               xs << " " << html::StartTag("a", parattr)
-                  << ++entry_number << html::EndTag("a");
+               xs << " " << xml::StartTag("a", parattr)
+                  << ++entry_number << xml::EndTag("a");
                last = *eit;
        }
        // now we have to close all the open levels
        while (level > 0) {
-               xs << html::EndTag("li") << html::EndTag("ul") << html::CR();
+               xs << xml::EndTag("li") << xml::EndTag("ul") << xml::CR();
                --level;
        }
-       xs << html::EndTag("div") << html::CR();
+       xs << xml::EndTag("div") << xml::CR();
        return ods.str();
 }
 
index 504eb84720a860b6107ec8634c5dc1c3cc04b8fa..46fe84576939ca529c941a182c4c1a85938b1b21 100644 (file)
@@ -59,7 +59,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void latex(otexstream &, OutputParams const &) const;
        ///
@@ -105,7 +105,7 @@ public:
        ///
        void latex(otexstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
index 30211b8e190aaf3873fafb7f71479f3bcd7c3056..44324933194d677760ae0abe47d1bfae9817173c 100644 (file)
@@ -27,7 +27,7 @@
 #include "LyX.h"
 #include "output_xhtml.h"
 #include "ParIterator.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "Text.h"
 #include "TextClass.h"
@@ -351,24 +351,24 @@ int InsetLabel::plaintext(odocstringstream & os,
 }
 
 
-int InsetLabel::docbook(odocstream & os, OutputParams const & runparams) const
+int InsetLabel::docbook(odocstream & os, OutputParams const &) const
 {
        os << "<!-- anchor id=\""
-          << sgml::cleanID(buffer(), runparams, getParam("name"))
+          << xml::cleanID(getParam("name"))
           << "\" -->";
        return 0;
 }
 
 
-docstring InsetLabel::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetLabel::xhtml(XMLStream & xs, OutputParams const &) const
 {
        // FIXME XHTML
        // Unfortunately, the name attribute has been deprecated, so we have to use
        // id here to get the document to validate as XHTML 1.1. This will cause a
        // problem with some browsers, though, I'm sure. (Guess which!) So we will
        // have to figure out what to do about this later.
-       docstring const attr = "id=\"" + html::cleanAttr(getParam("name")) + '"';
-       xs << html::CompTag("a", to_utf8(attr));
+       docstring const attr = "id=\"" + xml::cleanAttr(getParam("name")) + '"';
+       xs << xml::CompTag("a", to_utf8(attr));
        return docstring();
 }
 
index ab54e5e959f4f24e8c3d917a3011502ed112fffd..8d063168b68223341f66a2f127e971a0983322c0 100644 (file)
@@ -55,7 +55,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false);
        ///
index c1c890c2ed8b7ffe81bd023f18ad997b0d8e313f..d76ba16c3d705606e536fa141afee382791a35c8 100644 (file)
@@ -190,9 +190,9 @@ int InsetLine::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetLine::xhtml(XMLStream & xs, OutputParams const &) const
 {
-       xs << html::CompTag("hr") << html::CR();
+       xs << xml::CompTag("hr") << xml::CR();
        return docstring();
 }
 
index f518297445dd1b70d0145246c1a215fe1dc15b24..7be587028ffb9e9a55005ad68292530e9b72954e 100644 (file)
@@ -43,7 +43,7 @@ private:
        InsetCode lyxCode() const { return LINE_CODE; }
        int docbook(odocstream &, OutputParams const &) const;
        /// Does nothing at the moment.
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        bool hasSettings() const { return true; }
        void metrics(MetricsInfo &, Dimension &) const;
        void draw(PainterInfo & pi, int x, int y) const;
index f2af5813bd625e30bde7c0729fb8476526a491d8..7f98186630c0c5adf1734d3a81c87549bfbf9676 100644 (file)
@@ -433,21 +433,21 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetListings::xhtml(XHTMLStream & os, OutputParams const & rp) const
+docstring InsetListings::xhtml(XMLStream & os, OutputParams const & rp) const
 {
        odocstringstream ods;
-       XHTMLStream out(ods);
+       XMLStream out(ods);
 
        bool const isInline = params().isInline();
        if (isInline)
-               out << html::CompTag("br");
+               out << xml::CompTag("br");
        else {
-               out << html::StartTag("div", "class='float-listings'");
+               out << xml::StartTag("div", "class='float-listings'");
                docstring caption = getCaptionHTML(rp);
                if (!caption.empty())
-                       out << html::StartTag("div", "class='listings-caption'")
-                           << XHTMLStream::ESCAPE_NONE
-                           << caption << html::EndTag("div");
+                       out << xml::StartTag("div", "class='listings-caption'")
+                           << XMLStream::ESCAPE_NONE
+                           << caption << xml::EndTag("div");
        }
 
        InsetLayout const & il = getLayout();
@@ -457,21 +457,21 @@ docstring InsetListings::xhtml(XHTMLStream & os, OutputParams const & rp) const
        if (!lang.empty())
                attr += " " + lang;
        attr += "'";
-       out << html::StartTag(tag, attr);
+       out << xml::StartTag(tag, attr);
        OutputParams newrp = rp;
        newrp.html_disable_captions = true;
        // We don't want to convert dashes here. That's the only conversion we
        // do for XHTML, so this is safe.
        newrp.pass_thru = true;
        docstring def = InsetText::insetAsXHTML(out, newrp, InsetText::JustText);
-       out << html::EndTag(tag);
+       out << xml::EndTag(tag);
 
        if (isInline) {
-               out << html::CompTag("br");
+               out << xml::CompTag("br");
                // escaping will already have been done
-               os << XHTMLStream::ESCAPE_NONE << ods.str();
+               os << XMLStream::ESCAPE_NONE << ods.str();
        } else {
-               out << html::EndTag("div");
+               out << xml::EndTag("div");
                // In this case, this needs to be deferred, but we'll put it
                // before anything the text itself deferred.
                def = ods.str() + '\n' + def;
index 4be28f850dd942c108d5e83b021f3e9e7f1927a1..2b6de4e0f825563573c708a609fbad19cbe0652a 100644 (file)
@@ -56,7 +56,7 @@ private:
        ///
        void latex(otexstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
        ///
index b20886c8301fc57cd833054e8095960bdc180193..4930dd902a38930ea9b6f0c65856940937d2de1d 100644 (file)
@@ -178,9 +178,9 @@ int InsetNewline::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetNewline::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetNewline::xhtml(XMLStream & xs, OutputParams const &) const
 {
-       xs << html::CR() << html::CompTag("br") << html::CR();
+       xs << xml::CR() << xml::CompTag("br") << xml::CR();
        return docstring();
 }
 
index e0a13f38d415172d62f489973b5f5d9732058ece..8ea59366d8b64e344364f6f185767236da5dbcb8 100644 (file)
@@ -65,7 +65,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void read(Lexer & lex);
        ///
index 145cec96c6ed2696700d4b0aa691c64e36149df0..b108885f9c522a37c386688f4afac930342a2057 100644 (file)
@@ -255,9 +255,9 @@ int InsetNewpage::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetNewpage::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetNewpage::xhtml(XMLStream & xs, OutputParams const &) const
 {
-       xs << html::CompTag("br");
+       xs << xml::CompTag("br");
        return docstring();
 }
 
index 4a7d60d0103d7c09f0e9442f703c1cfcdc8e5d65..749d5972d8e83f5908baa8242a49513553532f70 100644 (file)
@@ -68,7 +68,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void read(Lexer & lex);
        ///
index 880f0fff52aec86df97c015b3ef9995e00c6af15..5e8813c39840ad1e658320c64d641763aa337fe9 100644 (file)
@@ -30,7 +30,7 @@
 #include "LyX.h"
 #include "OutputParams.h"
 #include "output_xhtml.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "TocBackend.h"
 
@@ -55,7 +55,7 @@ namespace lyx {
 
 InsetNomencl::InsetNomencl(Buffer * buf, InsetCommandParams const & p)
        : InsetCommand(buf, p),
-         nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen")))
+         nomenclature_entry_id(xml::uniqueID(from_ascii("nomen")))
 {}
 
 
@@ -108,13 +108,13 @@ int InsetNomencl::plaintext(odocstringstream & os,
 int InsetNomencl::docbook(odocstream & os, OutputParams const &) const
 {
        os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
-          << sgml::escapeString(getParam("symbol"))
+          << xml::escapeString(getParam("symbol"))
           << "</glossterm>";
        return 0;
 }
 
 
-docstring InsetNomencl::xhtml(XHTMLStream &, OutputParams const &) const
+docstring InsetNomencl::xhtml(XMLStream &, OutputParams const &) const
 {
        return docstring();
 }
@@ -124,10 +124,10 @@ int InsetNomencl::docbookGlossary(odocstream & os) const
 {
        os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
           << "<glossterm>"
-          << sgml::escapeString(getParam("symbol"))
+          << xml::escapeString(getParam("symbol"))
           << "</glossterm>\n"
           << "<glossdef><para>"
-          << sgml::escapeString(getParam("description"))
+          << xml::escapeString(getParam("description"))
           << "</para></glossdef>\n"
           <<"</glossentry>\n";
        return 4;
@@ -200,7 +200,7 @@ struct NomenclEntry {
 typedef map<docstring, NomenclEntry > EntryMap;
 
 
-docstring InsetPrintNomencl::xhtml(XHTMLStream &, OutputParams const & op) const
+docstring InsetPrintNomencl::xhtml(XMLStream &, OutputParams const & op) const
 {
        shared_ptr<Toc const> toc = buffer().tocBackend().toc("nomencl");
 
@@ -234,42 +234,42 @@ docstring InsetPrintNomencl::xhtml(XHTMLStream &, OutputParams const & op) const
        // that's how we deal with the fact that we're probably inside a standard
        // paragraph, and we don't want to be.
        odocstringstream ods;
-       XHTMLStream xs(ods);
+       XMLStream xs(ods);
 
        InsetLayout const & il = getLayout();
        string const & tag = il.htmltag();
        docstring toclabel = translateIfPossible(from_ascii("Nomenclature"),
                op.local_font->language()->lang());
 
-       xs << html::StartTag("div", "class='nomencl'")
-          << html::StartTag(tag, "class='nomencl'")
+       xs << xml::StartTag("div", "class='nomencl'")
+          << xml::StartTag(tag, "class='nomencl'")
                 << toclabel
-                << html::EndTag(tag)
-          << html::CR()
-          << html::StartTag("dl")
-          << html::CR();
+                << xml::EndTag(tag)
+          << xml::CR()
+          << xml::StartTag("dl")
+          << xml::CR();
 
        EntryMap::const_iterator eit = entries.begin();
        EntryMap::const_iterator const een = entries.end();
        for (; eit != een; ++eit) {
                NomenclEntry const & ne = eit->second;
                string const parid = ne.par->magicLabel();
-               xs << html::StartTag("dt")
-                  << html::StartTag("a", "href='#" + parid + "' class='nomencl'")
+               xs << xml::StartTag("dt")
+                  << xml::StartTag("a", "href='#" + parid + "' class='nomencl'")
                   << ne.symbol
-                  << html::EndTag("a")
-                  << html::EndTag("dt")
-                  << html::CR()
-                  << html::StartTag("dd")
+                  << xml::EndTag("a")
+                  << xml::EndTag("dt")
+                  << xml::CR()
+                  << xml::StartTag("dd")
                   << ne.desc
-                  << html::EndTag("dd")
-                  << html::CR();
+                  << xml::EndTag("dd")
+                  << xml::CR();
        }
 
-       xs << html::EndTag("dl")
-          << html::CR()
-          << html::EndTag("div")
-          << html::CR();
+       xs << xml::EndTag("dl")
+          << xml::CR()
+          << xml::EndTag("div")
+          << xml::CR();
 
        return ods.str();
 }
index 4d11a47d793c0bfd7f99f442558440dc300053d0..35887e88cd51b402846803ec3b7e96f996edbd8a 100644 (file)
@@ -50,7 +50,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        /// Does nothing at the moment.
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        //@}
 
        /// \name Static public methods obligated for InsetCommand derived classes
@@ -94,7 +94,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        InsetCode lyxCode() const;
        ///
index 9f4c5ed1d0349b130c81a6bf214db737b183bd1a..d9eb2f36991b54b0f6ea4160688d72c6979ba1cf 100644 (file)
@@ -290,7 +290,7 @@ int InsetNote::docbook(odocstream & os, OutputParams const & runparams_in) const
 }
 
 
-docstring InsetNote::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetNote::xhtml(XMLStream & xs, OutputParams const & rp) const
 {
        if (params_.type == InsetNoteParams::Note)
                return docstring();
index 9df1a501a29c75ba12c7ebc3c8f13517f7f4d3c4..e40b769854f24ca44c45c73a605a416ac2a01a86 100644 (file)
@@ -90,7 +90,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
        ///
index f8c3c3895568aaa9febc6a8ea022a62f6f66d7c7..4771cb83ee42899992846295e967d8b67141d664 100644 (file)
@@ -367,7 +367,7 @@ int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetPhantom::xhtml(XHTMLStream &, OutputParams const &) const
+docstring InsetPhantom::xhtml(XMLStream &, OutputParams const &) const
 {
        return docstring();
 }
index 46e8576678f5a1567ccefde72fcf441ecafeda21..9d363374a08f97e81b555e679825132ecb696c00 100644 (file)
@@ -81,7 +81,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        /// Makes no sense fof XHTML.
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
        ///
index 2f70f87222709651f7ddaac33509d3e1fbe3565b..d7f7510ebd668bf43f471656a768d711d195b84b 100644 (file)
@@ -536,6 +536,79 @@ docstring InsetQuotesParams::getHTMLQuote(char_type c) const
 }
 
 
+docstring InsetQuotesParams::getXMLQuote(char_type c) const
+{
+       string res;
+
+       switch (c){
+               case 0x201a: // ,
+                       res = "&#8218;";
+                       break;
+               case 0x2019: // '
+                       res = "&#8217;";
+                       break;
+               case 0x2018: // `
+                       res = "&#8216;";
+                       break;
+               case 0x2039: // <
+                       res = "&#8249;";
+                       break;
+               case 0x203a: // >
+                       res = "&#8250;";
+                       break;
+               case 0x0027: // ' (plain)
+                       res = "&#x27;";
+                       break;
+               case 0x201e: // ,,
+                       res = "&#8222;";
+                       break;
+               case 0x201d: // ''
+                       res = "&#8221;";
+                       break;
+               case 0x201c: // ``
+                       res = "&#8220;";
+                       break;
+               case 0x00ab: // <<
+                       res = "&#171;";
+                       break;
+               case 0x00bb: // >>
+                       res = "&#187;";
+                       break;
+               case 0x0022: // "
+                       res = "&#34;";
+                       break;
+               case 0x300c: // LEFT CORNER BRACKET
+                       res = "&#x300c;";
+                       break;
+               case 0x300d: // RIGHT CORNER BRACKET
+                       res = "&#x300d;";
+                       break;
+               case 0x300e: // LEFT WHITE CORNER BRACKET
+                       res = "&#x300e;";
+                       break;
+               case 0x300f: // RIGHT WHITE CORNER BRACKET
+                       res = "&#x300f;";
+                       break;
+               case 0x300a: // LEFT DOUBLE ANGLE BRACKET
+                       res = "&#x300a;";
+                       break;
+               case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
+                       res = "&#x300b;";
+                       break;
+               case 0x3008: // LEFT ANGLE BRACKET
+                       res = "&#x3008;";
+                       break;
+               case 0x3009: // RIGHT ANGLE BRACKET
+                       res = "&#x3009;";
+                       break;
+               default:
+                       break;
+       }
+
+       return from_ascii(res);
+}
+
+
 map<string, docstring> InsetQuotesParams::getTypes() const
 {
        map<string, docstring> res;
@@ -946,10 +1019,11 @@ int InsetQuotes::plaintext(odocstringstream & os,
 }
 
 
-docstring InsetQuotes::getQuoteEntity() const {
+docstring InsetQuotes::getQuoteEntity(bool isHTML) const {
        InsetQuotesParams::QuoteStyle style =
                        (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
-       docstring res = quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_));
+       docstring res = isHTML ? quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)) :
+                                       quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_));
        // in French, thin spaces are added inside double guillemets
        if (prefixIs(context_lang_, "fr")
            && level_ == InsetQuotesParams::PrimaryQuotes
@@ -969,14 +1043,14 @@ docstring InsetQuotes::getQuoteEntity() const {
 
 int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
 {
-       os << getQuoteEntity();
+       os << getQuoteEntity(false);
        return 0;
 }
 
 
-docstring InsetQuotes::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const
 {
-       xs << XHTMLStream::ESCAPE_NONE << getQuoteEntity();
+       xs << XMLStream::ESCAPE_NONE << getQuoteEntity(true);
        return docstring();
 }
 
index ea33b0eea00cb56560f1971e858ea141443fb4fd..939e6d61b4e43c39edcdd43306c9b905997b82e3 100644 (file)
@@ -82,6 +82,8 @@ public:
                                bool const rtl = false) const;
        ///
        docstring getHTMLQuote(char_type c) const;
+       ///
+       docstring getXMLQuote(char_type c) const;
        /// Returns a descriptive label of a style suitable for dialog and menu
        docstring const getGuiLabel(QuoteStyle const & qs,
                                    bool langdef = false);
@@ -146,7 +148,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
 
        ///
        void toString(odocstream &) const;
@@ -180,7 +182,7 @@ private:
        ///
        docstring displayString() const;
        ///
-       docstring getQuoteEntity() const;
+       docstring getQuoteEntity(bool isHTML) const;
        ///
        InsetQuotesParams::QuoteStyle getStyle(std::string const &);
 
index 79dfad24806415beefb79254718844040bd042f0..ac4a3a93d77099e2a5ebd5bfbd9affbc352ca0c3 100644 (file)
@@ -24,7 +24,7 @@
 #include "output_xhtml.h"
 #include "Paragraph.h"
 #include "ParIterator.h"
-#include "sgml.h"
+#include "xml.h"
 #include "texstream.h"
 #include "TocBackend.h"
 
@@ -315,16 +315,16 @@ int InsetRef::docbook(odocstream & os, OutputParams const & runparams) const
        if (name.empty()) {
                if (runparams.flavor == OutputParams::XML) {
                        os << "<xref linkend=\""
-                          << sgml::cleanID(buffer(), runparams, getParam("reference"))
+                          << xml::cleanID(getParam("reference"))
                           << "\" />";
                } else {
                        os << "<xref linkend=\""
-                          << sgml::cleanID(buffer(), runparams, getParam("reference"))
+                          << xml::cleanID(getParam("reference"))
                           << "\">";
                }
        } else {
                os << "<link linkend=\""
-                  << sgml::cleanID(buffer(), runparams, getParam("reference"))
+                  << xml::cleanID(getParam("reference"))
                   << "\">"
                   << getParam("name")
                   << "</link>";
@@ -334,7 +334,7 @@ int InsetRef::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const & op) const
+docstring InsetRef::xhtml(XMLStream & xs, OutputParams const & op) const
 {
        docstring const & ref = getParam("reference");
        InsetLabel const * il = buffer().insetLabel(ref, true);
@@ -375,10 +375,10 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const & op) const
        // FIXME What we'd really like to do is to be able to output some
        // appropriate sort of text here. But to do that, we need to associate
        // some sort of counter with the label, and we don't have that yet.
-       docstring const attr = "href=\"#" + html::cleanAttr(ref) + '"';
-       xs << html::StartTag("a", to_utf8(attr));
+       docstring const attr = "href=\"#" + xml::cleanAttr(ref) + '"';
+       xs << xml::StartTag("a", to_utf8(attr));
        xs << display_string;
-       xs << html::EndTag("a");
+       xs << xml::EndTag("a");
        return docstring();
 }
 
index 8683ecf9899b9de82de088c70ee3164c31d4cb41..5839033c2563aee5519234cda1537933c52310bb 100644 (file)
@@ -65,7 +65,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void toString(odocstream &) const;
        ///
index af7fb644cd1b04dd83441e7c8aa11b2f24c9c648..42ff09e70ae0463ee74c5f1fd0d2977152bb95e3 100644 (file)
@@ -174,9 +174,9 @@ int InsetSeparator::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetSeparator::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetSeparator::xhtml(XMLStream & xs, OutputParams const &) const
 {
-       xs << html::CR() << html::CompTag("br") << html::CR();
+       xs << xml::CR() << xml::CompTag("br") << xml::CR();
        return docstring();
 }
 
index 2d256d6bee1b5593976f459e3aead29c35cd31aa..2433b8247bac7e982c5fdaca7d97cae32e7fde79 100644 (file)
@@ -79,7 +79,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void read(Lexer & lex);
        ///
index a5fed47fbfec5f27896ac344a847f298e8b22186..34ce9b51f652c855b6d8f80dbcfc12748be38e8a 100644 (file)
@@ -762,7 +762,7 @@ int InsetSpace::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetSpace::xhtml(XMLStream & xs, OutputParams const &) const
 {
        string output;
        switch (params_.kind) {
@@ -822,7 +822,7 @@ docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
                break;
        }
        // don't escape the entities!
-       xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
+       xs << XMLStream::ESCAPE_NONE << from_ascii(output);
        return docstring();
 }
 
index 2784022955b6e80adfe84234ced1eec780394325..0b6ea5135c1b08da69db49f4f73d1a3fa09f3436 100644 (file)
@@ -129,7 +129,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
index 740061e0312ea85a2ef60aa639f478ccbfdefd5d..01007f6651390331b6719f5d537251dca4ef29ce 100644 (file)
@@ -551,31 +551,31 @@ int InsetSpecialChar::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetSpecialChar::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetSpecialChar::xhtml(XMLStream & xs, OutputParams const &) const
 {
        switch (kind_) {
        case HYPHENATION:
                break;
        case ALLOWBREAK:
-               xs << XHTMLStream::ESCAPE_NONE << "&#8203;";
+               xs << XMLStream::ESCAPE_NONE << "&#8203;";
                break;
        case LIGATURE_BREAK:
-               xs << XHTMLStream::ESCAPE_NONE << "&#8204;";
+               xs << XMLStream::ESCAPE_NONE << "&#8204;";
                break;
        case END_OF_SENTENCE:
                xs << '.';
                break;
        case LDOTS:
-               xs << XHTMLStream::ESCAPE_NONE << "&hellip;";
+               xs << XMLStream::ESCAPE_NONE << "&hellip;";
                break;
        case MENU_SEPARATOR:
-               xs << XHTMLStream::ESCAPE_NONE << "&rArr;";
+               xs << XMLStream::ESCAPE_NONE << "&rArr;";
                break;
        case SLASH:
-               xs << XHTMLStream::ESCAPE_NONE << "&frasl;";
+               xs << XMLStream::ESCAPE_NONE << "&frasl;";
                break;
        case NOBREAKDASH:
-               xs << XHTMLStream::ESCAPE_NONE << "&#8209;";
+               xs << XMLStream::ESCAPE_NONE << "&#8209;";
                break;
        case PHRASE_LYX:
                xs << "LyX";
@@ -584,7 +584,7 @@ docstring InsetSpecialChar::xhtml(XHTMLStream & xs, OutputParams const &) const
                xs << "TeX";
                break;
        case PHRASE_LATEX2E:
-               xs << "LaTeX2" << XHTMLStream::ESCAPE_NONE << "&#x3b5;";
+               xs << "LaTeX2" << XMLStream::ESCAPE_NONE << "&#x3b5;";
                break;
        case PHRASE_LATEX:
                xs << "LaTeX";
index 982b1d51a385ffa97f504e470779fe4da50fbc06..6b33572bd7e6eb6a90f815de2e719caa4ef8a523 100644 (file)
@@ -78,7 +78,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void toString(odocstream &) const;
        ///
index 29b7540cc277cbb2c690e5f15a2a2e50e4b49b12..a3739d74f51a4deb52de231c760e1c0b3cbd8b9e 100644 (file)
@@ -136,11 +136,11 @@ int InsetTOC::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-void InsetTOC::makeTOCEntry(XHTMLStream & xs,
+void InsetTOC::makeTOCEntry(XMLStream & xs,
                Paragraph const & par, OutputParams const & op) const
 {
        string const attr = "href='#" + par.magicLabel() + "' class='tocentry'";
-       xs << html::StartTag("a", attr);
+       xs << xml::StartTag("a", attr);
 
        // First the label, if there is one
        docstring const & label = par.params().labelString();
@@ -152,11 +152,11 @@ void InsetTOC::makeTOCEntry(XHTMLStream & xs,
        Font const dummy;
        par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy);
 
-       xs << html::EndTag("a") << html::CR();
+       xs << xml::EndTag("a") << xml::CR();
 }
 
 
-void InsetTOC::makeTOCWithDepth(XHTMLStream & xs,
+void InsetTOC::makeTOCWithDepth(XMLStream & xs,
                Toc const & toc, OutputParams const & op) const
 {
        Toc::const_iterator it = toc.begin();
@@ -177,13 +177,13 @@ void InsetTOC::makeTOCWithDepth(XHTMLStream & xs,
                        continue;
 
                if (depth > lastdepth) {
-                       xs << html::CR();
+                       xs << xml::CR();
                        // open as many tags as we need to open to get to this level
                        // this includes the tag for the current level
                        for (int i = lastdepth + 1; i <= depth; ++i) {
                                stringstream attr;
                                attr << "class='lyxtoc-" << i << "'";
-                               xs << html::StartTag("div", attr.str()) << html::CR();
+                               xs << xml::StartTag("div", attr.str()) << xml::CR();
                        }
                        lastdepth = depth;
                }
@@ -191,18 +191,18 @@ void InsetTOC::makeTOCWithDepth(XHTMLStream & xs,
                        // close as many as we have to close to get back to this level
                        // this includes closing the last tag at this level
                        for (int i = lastdepth; i >= depth; --i)
-                               xs << html::EndTag("div") << html::CR();
+                               xs << xml::EndTag("div") << xml::CR();
                        // now open our tag
                        stringstream attr;
                        attr << "class='lyxtoc-" << depth << "'";
-                       xs << html::StartTag("div", attr.str()) << html::CR();
+                       xs << xml::StartTag("div", attr.str()) << xml::CR();
                        lastdepth = depth;
                } else {
                        // no change of level, so close and open
-                       xs << html::EndTag("div") << html::CR();
+                       xs << xml::EndTag("div") << xml::CR();
                        stringstream attr;
                        attr << "class='lyxtoc-" << depth << "'";
-                       xs << html::StartTag("div", attr.str()) << html::CR();
+                       xs << xml::StartTag("div", attr.str()) << xml::CR();
                }
 
                // Now output TOC info for this entry
@@ -210,11 +210,11 @@ void InsetTOC::makeTOCWithDepth(XHTMLStream & xs,
                makeTOCEntry(xs, par, op);
        }
        for (int i = lastdepth; i > 0; --i)
-               xs << html::EndTag("div") << html::CR();
+               xs << xml::EndTag("div") << xml::CR();
 }
 
 
-void InsetTOC::makeTOCNoDepth(XHTMLStream & xs,
+void InsetTOC::makeTOCNoDepth(XMLStream & xs,
                Toc const & toc, const OutputParams & op) const
 {
        Toc::const_iterator it = toc.begin();
@@ -225,17 +225,17 @@ void InsetTOC::makeTOCNoDepth(XHTMLStream & xs,
                if (!it->isOutput())
                        continue;
 
-               xs << html::StartTag("div", "class='lyxtoc-flat'") << html::CR();
+               xs << xml::StartTag("div", "class='lyxtoc-flat'") << xml::CR();
 
                Paragraph const & par = it->dit().innerParagraph();
                makeTOCEntry(xs, par, op);
 
-               xs << html::EndTag("div");
+               xs << xml::EndTag("div");
        }
 }
 
 
-docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
+docstring InsetTOC::xhtml(XMLStream &, OutputParams const & op) const
 {
        string const & command = getCmdName();
        if (command != "tableofcontents" && command != "lstlistoflistings") {
@@ -252,9 +252,9 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
        // that's how we deal with the fact that we're probably inside a standard
        // paragraph, and we don't want to be.
        odocstringstream ods;
-       XHTMLStream xs(ods);
+       XMLStream xs(ods);
 
-       xs << html::StartTag("div", "class='toc'");
+       xs << xml::StartTag("div", "class='toc'");
 
        // Title of TOC
        InsetLayout const & il = getLayout();
@@ -263,9 +263,9 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
        Layout const & lay = buffer().params().documentClass().htmlTOCLayout();
        string const & tocclass = lay.defaultCSSClass();
        string const tocattr = "class='tochead " + tocclass + "'";
-       xs << html::StartTag(tag, tocattr)
+       xs << xml::StartTag(tag, tocattr)
                 << title
-                << html::EndTag(tag);
+                << xml::EndTag(tag);
 
        // with lists of listings, at least, there is no depth
        // to worry about. so the code can be simpler.
@@ -277,7 +277,7 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
        else
                makeTOCNoDepth(xs, *toc, op);
 
-       xs << html::EndTag("div") << html::CR();
+       xs << xml::EndTag("div") << xml::CR();
        return ods.str();
 }
 
index 4d48c3220f5ce40acf031689966539ca7290e3c0..00f6c7688bad4e52646faf1ebfc5e8532a97a292 100644 (file)
@@ -46,7 +46,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream & xs, OutputParams const &) const;
+       docstring xhtml(XMLStream & xs, OutputParams const &) const;
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
@@ -65,11 +65,11 @@ public:
 
 private:
        ///
-       void makeTOCWithDepth(XHTMLStream & xs, Toc const & toc, const OutputParams & op) const;
+       void makeTOCWithDepth(XMLStream & xs, Toc const & toc, const OutputParams & op) const;
        ///
-       void makeTOCNoDepth(XHTMLStream & xs, Toc const & toc, const OutputParams & op) const;
+       void makeTOCNoDepth(XMLStream & xs, Toc const & toc, const OutputParams & op) const;
        ///
-       void makeTOCEntry(XHTMLStream & xs, Paragraph const & par, OutputParams const & op) const;
+       void makeTOCEntry(XMLStream & xs, Paragraph const & par, OutputParams const & op) const;
 
        /// \name Private functions inherited from Inset class
        //@{
index 82cbfc7287c8bbe53b196a64628af57ee130585f..70f691917b8a6ce26e94cf45de9325c219b80f4e 100644 (file)
@@ -3649,14 +3649,14 @@ int Tabular::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
+docstring Tabular::xhtmlRow(XMLStream & xs, row_type row,
                           OutputParams const & runparams, bool header) const
 {
        docstring ret;
        string const celltag = header ? "th" : "td";
        idx_type cell = getFirstCellInRow(row);
 
-       xs << html::StartTag("tr");
+       xs << xml::StartTag("tr");
        for (col_type c = 0; c < ncols(); ++c) {
                if (isPartOfMultiColumn(row, c) || isPartOfMultiRow(row, c))
                        continue;
@@ -3700,17 +3700,17 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
                else if (isMultiRow(cell))
                        attr << " rowspan='" << rowSpan(cell) << "'";
 
-               xs << html::StartTag(celltag, attr.str(), true) << html::CR();
+               xs << xml::StartTag(celltag, attr.str(), true) << xml::CR();
                ret += cellInset(cell)->xhtml(xs, runparams);
-               xs << html::EndTag(celltag) << html::CR();
+               xs << xml::EndTag(celltag) << xml::CR();
                ++cell;
        }
-       xs << html::EndTag("tr");
+       xs << xml::EndTag("tr");
        return ret;
 }
 
 
-docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
+docstring Tabular::xhtml(XMLStream & xs, OutputParams const & runparams) const
 {
        docstring ret;
 
@@ -3728,20 +3728,20 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
                        align = "right";
                        break;
                }
-               xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'")
-                  << html::CR();
+               xs << xml::StartTag("div", "class='longtable' style='text-align: " + align + ";'")
+                  << xml::CR();
                // The caption flag wins over head/foot
                if (haveLTCaption()) {
-                       xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'")
-                          << html::CR();
+                       xs << xml::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'")
+                          << xml::CR();
                        for (row_type r = 0; r < nrows(); ++r)
                                if (row_info[r].caption)
                                        ret += xhtmlRow(xs, r, runparams);
-                       xs << html::EndTag("div") << html::CR();
+                       xs << xml::EndTag("div") << xml::CR();
                }
        }
 
-       xs << html::StartTag("table") << html::CR();
+       xs << xml::StartTag("table") << xml::CR();
 
        // output header info
        bool const havefirsthead = haveLTFirstHead(false);
@@ -3750,7 +3750,7 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
        // in XHTML. this test accomplishes that.
        bool const havehead = !havefirsthead && haveLTHead(false);
        if (havehead || havefirsthead) {
-               xs << html::StartTag("thead") << html::CR();
+               xs << xml::StartTag("thead") << xml::CR();
                for (row_type r = 0; r < nrows(); ++r) {
                        if (((havefirsthead && row_info[r].endfirsthead) ||
                             (havehead && row_info[r].endhead)) &&
@@ -3758,14 +3758,14 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
                                ret += xhtmlRow(xs, r, runparams, true);
                        }
                }
-               xs << html::EndTag("thead") << html::CR();
+               xs << xml::EndTag("thead") << xml::CR();
        }
        // output footer info
        bool const havelastfoot = haveLTLastFoot(false);
        // as before.
        bool const havefoot = !havelastfoot && haveLTFoot(false);
        if (havefoot || havelastfoot) {
-               xs << html::StartTag("tfoot") << html::CR();
+               xs << xml::StartTag("tfoot") << xml::CR();
                for (row_type r = 0; r < nrows(); ++r) {
                        if (((havelastfoot && row_info[r].endlastfoot) ||
                             (havefoot && row_info[r].endfoot)) &&
@@ -3773,21 +3773,21 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
                                ret += xhtmlRow(xs, r, runparams);
                        }
                }
-               xs << html::EndTag("tfoot") << html::CR();
+               xs << xml::EndTag("tfoot") << xml::CR();
        }
 
-       xs << html::StartTag("tbody") << html::CR();
+       xs << xml::StartTag("tbody") << xml::CR();
        for (row_type r = 0; r < nrows(); ++r) {
                if (isValidRow(r)) {
                        ret += xhtmlRow(xs, r, runparams);
                }
        }
-       xs << html::EndTag("tbody")
-          << html::CR()
-          << html::EndTag("table")
-          << html::CR();
+       xs << xml::EndTag("tbody")
+          << xml::CR()
+          << xml::EndTag("table")
+          << xml::CR();
        if (is_long_tabular)
-               xs << html::EndTag("div") << html::CR();
+               xs << xml::EndTag("div") << xml::CR();
        return ret;
 }
 
@@ -4167,7 +4167,7 @@ void InsetTableCell::addToToc(DocIterator const & di, bool output_active,
 }
 
 
-docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetTableCell::xhtml(XMLStream & xs, OutputParams const & rp) const
 {
        if (!isFixedWidth)
                return InsetText::insetAsXHTML(xs, rp, InsetText::JustText);
@@ -4203,7 +4203,6 @@ void InsetTableCell::metrics(MetricsInfo & mi, Dimension & dim) const
 }
 
 
-
 /////////////////////////////////////////////////////////////////////
 //
 // InsetTabular
@@ -6028,7 +6027,7 @@ int InsetTabular::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetTabular::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetTabular::xhtml(XMLStream & xs, OutputParams const & rp) const
 {
        return tabular.xhtml(xs, rp);
 }
index 3e8a6bcfab5a711001dfc8defd949cb861d98582..355a2520e998921648e57e5863c25623f5176ee7 100644 (file)
@@ -44,7 +44,7 @@ class FuncStatus;
 class Lexer;
 class OutputParams;
 class Paragraph;
-class XHTMLStream;
+class XMLStream;
 
 
 ///
@@ -72,7 +72,7 @@ public:
        /// descending into insets
        docstring asString(bool intoInsets = true);
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void addToToc(DocIterator const & di, bool output_active,
                                  UpdateType utype, TocBackend & backend) const;
@@ -573,7 +573,7 @@ public:
        ///
        int docbook(odocstream & os, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream & os, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void plaintext(odocstringstream &,
                       OutputParams const & runparams, int const depth,
@@ -908,7 +908,7 @@ public:
        /// auxiliary function for docbook
        int docbookRow(odocstream & os, row_type, OutputParams const &) const;
        ///
-       docstring xhtmlRow(XHTMLStream & xs, row_type, OutputParams const &,
+       docstring xhtmlRow(XMLStream & xs, row_type, OutputParams const &,
                           bool header = false) const;
 
        /// change associated Buffer
@@ -981,7 +981,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
index c76f0dbf4a1d7cd4911e0a5eeb9c387ff7a88000..ac10443d00bcf04f67094c442db42e079dfc8b4f 100644 (file)
@@ -45,7 +45,7 @@
 #include "ParagraphParameters.h"
 #include "ParIterator.h"
 #include "Row.h"
-#include "sgml.h"
+#include "xml.h"
 #include "TexRow.h"
 #include "texstream.h"
 #include "TextClass.h"
@@ -590,19 +590,19 @@ int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
        ParagraphList::const_iterator const beg = paragraphs().begin();
 
        if (!undefined())
-               sgml::openTag(os, getLayout().latexname(),
+               xml::openTag(os, getLayout().latexname(),
                              beg->getID(buffer(), runparams) + getLayout().latexparam());
 
        docbookParagraphs(text_, buffer(), os, runparams);
 
        if (!undefined())
-               sgml::closeTag(os, getLayout().latexname());
+               xml::closeTag(os, getLayout().latexname());
 
        return 0;
 }
 
 
-docstring InsetText::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
+docstring InsetText::xhtml(XMLStream & xs, OutputParams const & runparams) const
 {
        return insetAsXHTML(xs, runparams, WriteEverything);
 }
@@ -621,7 +621,7 @@ docstring InsetText::xhtml(XHTMLStream & xs, OutputParams const & runparams) con
 // if so, try to close fonts, etc.
 // There are probably limits to how well we can do here, though, and we will
 // have to rely upon users not putting footnotes inside noun-type insets.
-docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
+docstring InsetText::insetAsXHTML(XMLStream & xs, OutputParams const & rp,
                                   XHTMLOptions opts) const
 {
        // we will always want to output all our paragraphs when we are
@@ -639,7 +639,7 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
 
        InsetLayout const & il = getLayout();
        if (opts & WriteOuterTag)
-               xs << html::StartTag(il.htmltag(), il.htmlattr());
+               xs << xml::StartTag(il.htmltag(), il.htmlattr());
 
        if ((opts & WriteLabel) && !il.counter().empty()) {
                BufferParams const & bp = buffer().masterBuffer()->params();
@@ -651,15 +651,15 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
                                cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
                        // FIXME is this check necessary?
                        if (!lbl.empty()) {
-                               xs << html::StartTag(il.htmllabeltag(), il.htmllabelattr());
+                               xs << xml::StartTag(il.htmllabeltag(), il.htmllabelattr());
                                xs << lbl;
-                               xs << html::EndTag(il.htmllabeltag());
+                               xs << xml::EndTag(il.htmllabeltag());
                        }
                }
        }
 
        if (opts & WriteInnerTag)
-               xs << html::StartTag(il.htmlinnertag(), il.htmlinnerattr());
+               xs << xml::StartTag(il.htmlinnertag(), il.htmlinnerattr());
 
        // we will eventually lose information about the containing inset
        if (!allowMultiPar() || opts == JustText)
@@ -672,10 +672,10 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
        xs.endDivision();
 
        if (opts & WriteInnerTag)
-               xs << html::EndTag(il.htmlinnertag());
+               xs << xml::EndTag(il.htmlinnertag());
 
        if (opts & WriteOuterTag)
-               xs << html::EndTag(il.htmltag());
+               xs << xml::EndTag(il.htmltag());
 
        return docstring();
 }
index 6c9790b13556edbe0014920162e29b5fc8fde332..0ad33a1f163b9e08dc6f37d8fc03cfeb9f28b18b 100644 (file)
@@ -83,7 +83,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        enum XHTMLOptions {
                JustText = 0,
@@ -93,7 +93,7 @@ public:
                WriteEverything = 7
        };
        ///
-       docstring insetAsXHTML(XHTMLStream &, OutputParams const &,
+       docstring insetAsXHTML(XMLStream &, OutputParams const &,
                               XHTMLOptions) const;
        ///
        void validate(LaTeXFeatures & features) const;
index 4cdd1ba6edd37dfbdca46ea36db7e0770bbbefc8..24ea9aa63659b8c2a7fbbbf43789dd96dab637e8 100644 (file)
@@ -231,11 +231,11 @@ int InsetVSpace::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetVSpace::xhtml(XHTMLStream & os, OutputParams const &) const
+docstring InsetVSpace::xhtml(XMLStream & os, OutputParams const &) const
 {
        string const len = space_.asHTMLLength();
        string const attr = "style='height:" + (len.empty() ? "1em" : len) + "'";
-       os << html::StartTag("div", attr, true) << html::EndTag("div");
+       os << xml::StartTag("div", attr, true) << xml::EndTag("div");
        return docstring();
 }
 
index b2c8ac9780bb799af576770e4ece9bff7fdc3dc9..16e50da09616201a8e8c5838190a82e26243ac3f 100644 (file)
@@ -56,7 +56,7 @@ private:
        /// The normal case is that this inset will be on a line by
        /// itself, and in that case the present paragraph will not,
        /// in fact, appear at all.
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void read(Lexer & lex);
        ///
index fe56091a75501992e30281450a58cb7a1c2254f1..4460f99c9b2d2ef441a3bfe96afc925324194ced 100644 (file)
@@ -217,17 +217,17 @@ int InsetWrap::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetWrap::xhtml(XHTMLStream & xs, OutputParams const & rp) const
+docstring InsetWrap::xhtml(XMLStream & xs, OutputParams const & rp) const
 {
        string const len = params_.width.asHTMLString();
        string const width = len.empty() ? "50%" : len;
        InsetLayout const & il = getLayout();
        string const & tag = il.htmltag();
        string const attr = il.htmlattr() + " style='width:" + width + ";'";
-       xs << html::StartTag(tag, attr);
+       xs << xml::StartTag(tag, attr);
        docstring const deferred =
                InsetText::insetAsXHTML(xs, rp, InsetText::WriteInnerTag);
-       xs << html::EndTag(tag);
+       xs << xml::EndTag(tag);
        return deferred;
 }
 
index 3bf837876a237e53abe32eeac3061c1dc606bd8b..8df38e97f5de5f5e4040e042abde2ada0b235ea4 100644 (file)
@@ -74,7 +74,7 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        bool insetAllowed(InsetCode) const;
        ///
index 8e16787fe741cea43ce43d5985d01d6155a4bffe..a117af6cdc2c2b7aa61b512213995dee590b8c27 100644 (file)
@@ -41,7 +41,7 @@
 #include "output_xhtml.h"
 #include "Paragraph.h"
 #include "ParIterator.h"
-#include "sgml.h"
+#include "xml.h"
 #include "TexRow.h"
 #include "TextClass.h"
 #include "TextPainter.h"
@@ -2416,7 +2416,7 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
 
        docstring bname = name;
        if (!label(0).empty())
-               bname += " id='" + sgml::cleanID(buffer(), runparams, label(0)) + "'";
+               bname += " id='" + xml::cleanID(label(0)) + "'";
 
        ++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>';
 
@@ -2446,9 +2446,9 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
 
        ms << from_ascii("<graphic fileref=\"eqn/");
        if (!label(0).empty())
-               ms << sgml::cleanID(buffer(), runparams, label(0));
+               ms << xml::cleanID(label(0));
        else
-               ms << sgml::uniqueID(from_ascii("anon"));
+               ms << xml::uniqueID(from_ascii("anon"));
 
        if (runparams.flavor == OutputParams::XML)
                ms << from_ascii("\"/>");
@@ -2585,7 +2585,7 @@ void InsetMathHull::mathAsLatex(WriteStream & os) const
 }
 
 
-docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
+docstring InsetMathHull::xhtml(XMLStream & xs, OutputParams const & op) const
 {
        BufferParams::MathOutput const mathtype =
                buffer().masterBuffer()->params().html_math_output;
@@ -2611,14 +2611,14 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
                } catch (MathExportException const &) {}
                if (success) {
                        if (getType() == hullSimple)
-                               xs << html::StartTag("math",
+                               xs << xml::StartTag("math",
                                                        "xmlns=\"http://www.w3.org/1998/Math/MathML\"", true);
                        else
-                               xs << html::StartTag("math",
+                               xs << xml::StartTag("math",
                                      "display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\"", true);
-                       xs << XHTMLStream::ESCAPE_NONE
+                       xs << XMLStream::ESCAPE_NONE
                                 << os.str()
-                                << html::EndTag("math");
+                                << xml::EndTag("math");
                }
        } else if (mathtype == BufferParams::HTML) {
                odocstringstream os;
@@ -2629,10 +2629,10 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
                } catch (MathExportException const &) {}
                if (success) {
                        string const tag = (getType() == hullSimple) ? "span" : "div";
-                       xs << html::StartTag(tag, "class='formula'", true)
-                          << XHTMLStream::ESCAPE_NONE
+                       xs << xml::StartTag(tag, "class='formula'", true)
+                          << XMLStream::ESCAPE_NONE
                           << os.str()
-                          << html::EndTag(tag);
+                          << xml::EndTag(tag);
                }
        }
 
@@ -2672,11 +2672,11 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
                        }
 
                        string const tag = (getType() == hullSimple) ? "span" : "div";
-                       xs << html::CR()
-                          << html::StartTag(tag, "style = \"text-align: center;\"")
-                                << html::CompTag("img", "src=\"" + filename + "\" alt=\"Mathematical Equation\"")
-                                << html::EndTag(tag)
-                                << html::CR();
+                       xs << xml::CR()
+                          << xml::StartTag(tag, "style = \"text-align: center;\"")
+                                << xml::CompTag("img", "src=\"" + filename + "\" alt=\"Mathematical Equation\"")
+                                << xml::EndTag(tag)
+                                << xml::CR();
                        success = true;
                }
        }
@@ -2699,10 +2699,10 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
                // FIXME XHTML
                // probably should allow for some kind of customization here
                string const tag = (getType() == hullSimple) ? "span" : "div";
-               xs << html::StartTag(tag, "class='math'")
+               xs << xml::StartTag(tag, "class='math'")
                   << latex
-                  << html::EndTag(tag)
-                  << html::CR();
+                  << xml::EndTag(tag)
+                  << xml::CR();
        }
        return docstring();
 }
index 9c27e0e374c29ad9a2a6ab38140af5cf55df5423..32e4f09fa0930c726c018b95a6b5b2da46b770ec 100644 (file)
@@ -146,7 +146,7 @@ public:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        void mathmlize(MathStream &) const;
        ///
index dd9bec9accf2b8917e6752e10db0789482f1e7a7..50362552fb1fe1c4f5d00b37b48a93f3b396a976 100644 (file)
@@ -1263,7 +1263,7 @@ int InsetMathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition)
 }
 
 
-docstring InsetMathMacroTemplate::xhtml(XHTMLStream &, OutputParams const &) const
+docstring InsetMathMacroTemplate::xhtml(XMLStream &, OutputParams const &) const
 {
        return docstring();
 }
index 978aa64ed7db7f723683c1505bf54a78c89ef5c4..da629fbe2b9e872b07e990495099ee6c9f5ee662 100644 (file)
@@ -21,7 +21,7 @@
 namespace lyx {
 
 class OutputParams;
-class XHTMLStream;
+class XMLStream;
 
 /// This class contains the macro definition.
 class InsetMathMacroTemplate : public InsetMathNest {
@@ -52,7 +52,7 @@ public:
        /// if overwriteRedefinition is true
        int write(WriteStream & os, bool overwriteRedefinition) const;
        /// Nothing happens. This is simply to suppress the default output.
-       docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       docstring xhtml(XMLStream &, OutputParams const &) const;
        ///
        int plaintext(odocstringstream &, OutputParams const &, size_t) const;
        ///
index 6a911afa57b2a53e73dd147f0c1133448dc01c1d..9eaad0c033d3621e2ea899f710eeaad0cb417a60 100644 (file)
@@ -24,7 +24,7 @@
 #include "MathSupport.h"
 #include "OutputParams.h"
 #include "ParIterator.h"
-#include "sgml.h"
+#include "xml.h"
 
 #include "insets/InsetCommand.h"
 
@@ -186,14 +186,14 @@ int InsetMathRef::docbook(odocstream & os, OutputParams const & runparams) const
 {
        if (cell(1).empty()) {
                os << "<xref linkend=\""
-                  << sgml::cleanID(buffer(), runparams, asString(cell(0)));
+                  << xml::cleanID(asString(cell(0)));
                if (runparams.flavor == OutputParams::XML)
                        os << "\"/>";
                else
                        os << "\">";
        } else {
                os << "<link linkend=\""
-                  << sgml::cleanID(buffer(), runparams, asString(cell(0)))
+                  << xml::cleanID(asString(cell(0)))
                   << "\">"
                   << asString(cell(1))
                   << "</link>";
index a1a188952b3eb32233d9d9e1a998fc28fd505b35..45af41bece27ff56baef5ef6ca1d504c92e112ce 100644 (file)
@@ -23,7 +23,7 @@
 #include "Paragraph.h"
 #include "ParagraphList.h"
 #include "ParagraphParameters.h"
-#include "sgml.h"
+#include "xml.h"
 #include "Text.h"
 #include "TextClass.h"
 
@@ -41,6 +41,45 @@ namespace lyx {
 
 namespace {
 
+std::string const fontToDocBookTag(xml::FontTypes type) {
+    switch (type) {
+    case xml::FontTypes::FT_EMPH:
+    case xml::FontTypes::FT_BOLD:
+        return "emphasis";
+    case xml::FontTypes::FT_NOUN:
+        return "person";
+    case xml::FontTypes::FT_UBAR:
+    case xml::FontTypes::FT_WAVE:
+    case xml::FontTypes::FT_DBAR:
+    case xml::FontTypes::FT_SOUT:
+    case xml::FontTypes::FT_XOUT:
+    case xml::FontTypes::FT_ITALIC:
+    case xml::FontTypes::FT_UPRIGHT:
+    case xml::FontTypes::FT_SLANTED:
+    case xml::FontTypes::FT_SMALLCAPS:
+    case xml::FontTypes::FT_ROMAN:
+    case xml::FontTypes::FT_SANS:
+        return "emphasis";
+    case xml::FontTypes::FT_TYPE:
+        return "code";
+    case xml::FontTypes::FT_SIZE_TINY:
+    case xml::FontTypes::FT_SIZE_SCRIPT:
+    case xml::FontTypes::FT_SIZE_FOOTNOTE:
+    case xml::FontTypes::FT_SIZE_SMALL:
+    case xml::FontTypes::FT_SIZE_NORMAL:
+    case xml::FontTypes::FT_SIZE_LARGE:
+    case xml::FontTypes::FT_SIZE_LARGER:
+    case xml::FontTypes::FT_SIZE_LARGEST:
+    case xml::FontTypes::FT_SIZE_HUGE:
+    case xml::FontTypes::FT_SIZE_HUGER:
+    case xml::FontTypes::FT_SIZE_INCREASE:
+    case xml::FontTypes::FT_SIZE_DECREASE:
+        return "emphasis";
+    default:
+        return "";
+    }
+}
+
 ParagraphList::const_iterator searchParagraph(
        ParagraphList::const_iterator p,
        ParagraphList::const_iterator const & pend)
@@ -115,10 +154,10 @@ ParagraphList::const_iterator makeParagraph(
                        par->simpleDocBookOnePar(buf, os, runparams,
                                        text.outerFont(distance(paragraphs.begin(), par)));
                } else {
-                       sgml::openTag(buf, os, runparams, *par);
+                       xml::openTag(buf, os, runparams, *par);
                        par->simpleDocBookOnePar(buf, os, runparams,
                                        text.outerFont(distance(paragraphs.begin(), par)));
-                       sgml::closeTag(os, *par);
+                       xml::closeTag(os, *par);
                }
        }
        return pend;
@@ -140,7 +179,7 @@ ParagraphList::const_iterator makeEnvironment(
        Layout const & bstyle = par->layout();
 
        // Opening outter tag
-       sgml::openTag(buf, os, runparams, *pbegin);
+       xml::openTag(buf, os, runparams, *pbegin);
        os << '\n';
        if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru)
                os << "<![CDATA[";
@@ -156,23 +195,23 @@ ParagraphList::const_iterator makeEnvironment(
                switch (bstyle.latextype) {
                case LATEX_ENVIRONMENT:
                        if (!bstyle.innertag().empty()) {
-                               sgml::openTag(os, bstyle.innertag(), id);
+                               xml::openTag(os, bstyle.innertag(), id);
                        }
                        break;
 
                case LATEX_ITEM_ENVIRONMENT:
                        if (!bstyle.labeltag().empty()) {
-                               sgml::openTag(os, bstyle.innertag(), id);
-                               sgml::openTag(os, bstyle.labeltag());
+                               xml::openTag(os, bstyle.innertag(), id);
+                               xml::openTag(os, bstyle.labeltag());
                                sep = par->firstWordDocBook(os, runparams) + 1;
-                               sgml::closeTag(os, bstyle.labeltag());
+                               xml::closeTag(os, bstyle.labeltag());
                        }
                        wrapper = defaultstyle.latexname();
                        // If a sub list (embedded list) appears next with a
                        // different depth, then there is no need to open
                        // another tag at the current depth.
                        if(par->params().depth() == pbegin->params().depth()) {
-                               sgml::openTag(os, bstyle.itemtag());
+                               xml::openTag(os, bstyle.itemtag());
                        }
                        break;
                default:
@@ -183,10 +222,10 @@ ParagraphList::const_iterator makeEnvironment(
                case LATEX_ENVIRONMENT:
                case LATEX_ITEM_ENVIRONMENT: {
                        if (par->params().depth() == pbegin->params().depth()) {
-                               sgml::openTag(os, wrapper);
+                               xml::openTag(os, wrapper);
                                par->simpleDocBookOnePar(buf, os, runparams,
                                        text.outerFont(distance(paragraphs.begin(), par)), sep);
-                               sgml::closeTag(os, wrapper);
+                               xml::closeTag(os, wrapper);
                                ++par;
                        }
                        else {
@@ -212,7 +251,7 @@ ParagraphList::const_iterator makeEnvironment(
                switch (bstyle.latextype) {
                case LATEX_ENVIRONMENT:
                        if (!bstyle.innertag().empty()) {
-                               sgml::closeTag(os, bstyle.innertag());
+                               xml::closeTag(os, bstyle.innertag());
                                os << '\n';
                        }
                        break;
@@ -226,10 +265,10 @@ ParagraphList::const_iterator makeEnvironment(
                        // when par == pend but at the same time that the
                        // current tag is closed.
                        if((par != pend && par->params().depth() == pbegin->params().depth()) || par == pend) {
-                               sgml::closeTag(os, bstyle.itemtag());
+                               xml::closeTag(os, bstyle.itemtag());
                        }
                        if (!bstyle.labeltag().empty())
-                               sgml::closeTag(os, bstyle.innertag());
+                               xml::closeTag(os, bstyle.innertag());
                        break;
                default:
                        break;
@@ -240,7 +279,7 @@ ParagraphList::const_iterator makeEnvironment(
                os << "]]>";
 
        // Closing outer tag
-       sgml::closeTag(os, *pbegin);
+       xml::closeTag(os, *pbegin);
 
        return pend;
 }
@@ -259,22 +298,22 @@ ParagraphList::const_iterator makeCommand(
        Layout const & bstyle = par->layout();
 
        //Open outter tag
-       sgml::openTag(buf, os, runparams, *pbegin);
+       xml::openTag(buf, os, runparams, *pbegin);
        os << '\n';
 
        // Label around sectioning number:
        if (!bstyle.labeltag().empty()) {
-               sgml::openTag(os, bstyle.labeltag());
+               xml::openTag(os, bstyle.labeltag());
                // We don't care about appendix in DOCBOOK.
                os << par->expandDocBookLabel(bstyle, buf.params());
-               sgml::closeTag(os, bstyle.labeltag());
+               xml::closeTag(os, bstyle.labeltag());
        }
 
        // Opend inner tag and  close inner tags
-       sgml::openTag(os, bstyle.innertag());
+       xml::openTag(os, bstyle.innertag());
        par->simpleDocBookOnePar(buf, os, runparams,
                text.outerFont(distance(paragraphs.begin(), par)));
-       sgml::closeTag(os, bstyle.innertag());
+       xml::closeTag(os, bstyle.innertag());
        os << '\n';
 
        ++par;
@@ -307,7 +346,7 @@ ParagraphList::const_iterator makeCommand(
                }
        }
        // Close outter tag
-       sgml::closeTag(os, *pbegin);
+       xml::closeTag(os, *pbegin);
 
        return pend;
 }
index 46e495f0057afb8f93c1dca04d55bf6b7fdacc51..819c2035e4b04f6d800fc1ee33175b5c7144282f 100644 (file)
 #define OUTPUT_DOCBOOK_H
 
 #include "support/strfwd.h"
+#include "xml.h"
 
 namespace lyx {
 
+std::string const fontToDocBookTag(xml::FontTypes type);
+
 class Buffer;
 class OutputParams;
 class Text;
index 469b316ea4809abd3a48bcf510e00050eb2ecfe8..dcc3f69c333c438a451452d17c60b38a1110564a 100644 (file)
@@ -24,7 +24,7 @@
 #include "Paragraph.h"
 #include "ParagraphList.h"
 #include "ParagraphParameters.h"
-#include "sgml.h"
+#include "xml.h"
 #include "Text.h"
 #include "TextClass.h"
 
@@ -44,212 +44,102 @@ using namespace lyx::support;
 
 namespace lyx {
 
-namespace html {
 
-docstring escapeChar(char_type c, XHTMLStream::EscapeSettings e)
-{
-       docstring str;
-       switch (e) {
-       case XHTMLStream::ESCAPE_NONE:
-               str += c;
-               break;
-       case XHTMLStream::ESCAPE_ALL:
-               if (c == '<') {
-                       str += "&lt;";
-                       break;
-               } else if (c == '>') {
-                       str += "&gt;";
-                       break;
-               }
-       // fall through
-       case XHTMLStream::ESCAPE_AND:
-               if (c == '&')
-                       str += "&amp;";
-               else
-                       str     +=c ;
-               break;
-       }
-       return str;
-}
-
-
-// escape what needs escaping
-docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e)
-{
-       odocstringstream d;
-       docstring::const_iterator it = str.begin();
-       docstring::const_iterator en = str.end();
-       for (; it != en; ++it)
-               d << escapeChar(*it, e);
-       return d.str();
-}
-
-
-docstring escapeChar(char c, XHTMLStream::EscapeSettings e)
-{
-       LATTEST(static_cast<unsigned char>(c) < 0x80);
-       return escapeChar(static_cast<char_type>(c), e);
-}
-
-
-docstring cleanAttr(docstring const & str)
-{
-       docstring newname;
-       docstring::const_iterator it = str.begin();
-       docstring::const_iterator en = str.end();
-       for (; it != en; ++it) {
-               char_type const c = *it;
-               newname += isAlnumASCII(c) ? c : char_type('_');
-       }
-       return newname;
-}
-
-
-docstring StartTag::writeTag() const
-{
-       docstring output = '<' + from_utf8(tag_);
-       if (!attr_.empty())
-               output += ' ' + html::htmlize(from_utf8(attr_), XHTMLStream::ESCAPE_NONE);
-       output += ">";
-       return output;
+docstring const & fontToHtmlTag(xml::FontTypes type)
+{
+    switch(type) {
+        case xml::FontTypes::FT_EMPH:
+            return from_utf8("em");
+        case xml::FontTypes::FT_BOLD:
+            return from_utf8("b");
+        case xml::FontTypes::FT_NOUN:
+            return from_utf8("dfn");
+        case xml::FontTypes::FT_UBAR:
+        case xml::FontTypes::FT_WAVE:
+        case xml::FontTypes::FT_DBAR:
+            return from_utf8("u");
+        case xml::FontTypes::FT_SOUT:
+        case xml::FontTypes::FT_XOUT:
+            return from_utf8("del");
+        case xml::FontTypes::FT_ITALIC:
+            return from_utf8("i");
+        case xml::FontTypes::FT_UPRIGHT:
+        case xml::FontTypes::FT_SLANTED:
+        case xml::FontTypes::FT_SMALLCAPS:
+        case xml::FontTypes::FT_ROMAN:
+        case xml::FontTypes::FT_SANS:
+        case xml::FontTypes::FT_TYPE:
+        case xml::FontTypes::FT_SIZE_TINY:
+        case xml::FontTypes::FT_SIZE_SCRIPT:
+        case xml::FontTypes::FT_SIZE_FOOTNOTE:
+        case xml::FontTypes::FT_SIZE_SMALL:
+        case xml::FontTypes::FT_SIZE_NORMAL:
+        case xml::FontTypes::FT_SIZE_LARGE:
+        case xml::FontTypes::FT_SIZE_LARGER:
+        case xml::FontTypes::FT_SIZE_LARGEST:
+        case xml::FontTypes::FT_SIZE_HUGE:
+        case xml::FontTypes::FT_SIZE_HUGER:
+        case xml::FontTypes::FT_SIZE_INCREASE:
+        case xml::FontTypes::FT_SIZE_DECREASE:
+            return from_utf8("span");
+    }
+    // kill warning
+    return docstring();
 }
 
 
-docstring StartTag::writeEndTag() const
-{
-       string output = "</" + tag_ + ">";
-       return from_utf8(output);
-}
-
-
-bool StartTag::operator==(FontTag const & rhs) const
-{
-       return rhs == *this;
-}
-
-
-docstring EndTag::writeEndTag() const
-{
-       string output = "</" + tag_ + ">";
-       return from_utf8(output);
-}
-
-
-ParTag::ParTag(std::string const & tag, std::string attr,
-       std::string const & parid)
-  : StartTag(tag)
-{
-       if (!parid.empty())
-               attr += " id='" + parid + "'";
-       attr_ = attr;
-}
-
-
-docstring CompTag::writeTag() const
-{
-       docstring output = '<' + from_utf8(tag_);
-       if (!attr_.empty())
-               output += ' ' + html::htmlize(from_utf8(attr_), XHTMLStream::ESCAPE_NONE);
-       output += " />";
-       return output;
-}
-
-
-
 namespace {
 
-string fontToTag(html::FontTypes type)
+string fontToAttribute(xml::FontTypes type)
 {
        switch(type) {
-       case FT_EMPH:
-               return "em";
-       case FT_BOLD:
-               return "b";
-       case FT_NOUN:
-               return "dfn";
-       case FT_UBAR:
-       case FT_WAVE:
-       case FT_DBAR:
-               return "u";
-       case FT_SOUT:
-       case FT_XOUT:
-               return "del";
-       case FT_ITALIC:
-               return "i";
-       case FT_UPRIGHT:
-       case FT_SLANTED:
-       case FT_SMALLCAPS:
-       case FT_ROMAN:
-       case FT_SANS:
-       case FT_TYPE:
-       case FT_SIZE_TINY:
-       case FT_SIZE_SCRIPT:
-       case FT_SIZE_FOOTNOTE:
-       case FT_SIZE_SMALL:
-       case FT_SIZE_NORMAL:
-       case FT_SIZE_LARGE:
-       case FT_SIZE_LARGER:
-       case FT_SIZE_LARGEST:
-       case FT_SIZE_HUGE:
-       case FT_SIZE_HUGER:
-       case FT_SIZE_INCREASE:
-       case FT_SIZE_DECREASE:
-               return "span";
-       }
-       // kill warning
-       return "";
-}
-
-string fontToAttribute(html::FontTypes type)
-{
-       switch(type) {
-       case FT_EMPH:
-       case FT_BOLD:
+       case xml::FontTypes::FT_EMPH:
+       case xml::FontTypes::FT_BOLD:
                return "";
-       case FT_NOUN:
+       case xml::FontTypes::FT_NOUN:
                return "class='lyxnoun'";
-       case FT_UBAR:
+       case xml::FontTypes::FT_UBAR:
                return "";
-       case FT_DBAR:
+       case xml::FontTypes::FT_DBAR:
                return "class='dline'";
-       case FT_XOUT:
-       case FT_SOUT:
+       case xml::FontTypes::FT_XOUT:
+       case xml::FontTypes::FT_SOUT:
                return "class='strikeout'";
-       case FT_WAVE:
+       case xml::FontTypes::FT_WAVE:
                return "class='wline'";
-       case FT_ITALIC:
+       case xml::FontTypes::FT_ITALIC:
                return "";
-       case FT_UPRIGHT:
+       case xml::FontTypes::FT_UPRIGHT:
                return "style='font-style:normal;'";
-       case FT_SLANTED:
+       case xml::FontTypes::FT_SLANTED:
                return "style='font-style:oblique;'";
-       case FT_SMALLCAPS:
+       case xml::FontTypes::FT_SMALLCAPS:
                return "style='font-variant:small-caps;'";
-       case FT_ROMAN:
+       case xml::FontTypes::FT_ROMAN:
                return "style='font-family:serif;'";
-       case FT_SANS:
+       case xml::FontTypes::FT_SANS:
                return "style='font-family:sans-serif;'";
-       case FT_TYPE:
+       case xml::FontTypes::FT_TYPE:
                return "style='font-family:monospace;'";
-       case FT_SIZE_TINY:
-       case FT_SIZE_SCRIPT:
-       case FT_SIZE_FOOTNOTE:
+       case xml::FontTypes::FT_SIZE_TINY:
+       case xml::FontTypes::FT_SIZE_SCRIPT:
+       case xml::FontTypes::FT_SIZE_FOOTNOTE:
                return "style='font-size:x-small;'";
-       case FT_SIZE_SMALL:
+       case xml::FontTypes::FT_SIZE_SMALL:
                return "style='font-size:small;'";
-       case FT_SIZE_NORMAL:
+       case xml::FontTypes::FT_SIZE_NORMAL:
                return "style='font-size:normal;'";
-       case FT_SIZE_LARGE:
+       case xml::FontTypes::FT_SIZE_LARGE:
                return "style='font-size:large;'";
-       case FT_SIZE_LARGER:
-       case FT_SIZE_LARGEST:
+       case xml::FontTypes::FT_SIZE_LARGER:
+       case xml::FontTypes::FT_SIZE_LARGEST:
                return "style='font-size:x-large;'";
-       case FT_SIZE_HUGE:
-       case FT_SIZE_HUGER:
+       case xml::FontTypes::FT_SIZE_HUGE:
+       case xml::FontTypes::FT_SIZE_HUGER:
                return "style='font-size:xx-large;'";
-       case FT_SIZE_INCREASE:
+       case xml::FontTypes::FT_SIZE_INCREASE:
                return "style='font-size:larger;'";
-       case FT_SIZE_DECREASE:
+       case xml::FontTypes::FT_SIZE_DECREASE:
                return "style='font-size:smaller;'";
        }
        // kill warning
@@ -259,487 +149,29 @@ string fontToAttribute(html::FontTypes type)
 } // end anonymous namespace
 
 
-FontTag::FontTag(FontTypes type)
-  : StartTag(fontToTag(type), fontToAttribute(type)), font_type_(type)
-{}
-
-
-bool FontTag::operator==(StartTag const & tag) const
-{
-       FontTag const * const ftag = tag.asFontTag();
-       if (!ftag)
-               return false;
-       return (font_type_ == ftag->font_type_);
-}
-
-
-EndFontTag::EndFontTag(FontTypes type)
-         : EndTag(fontToTag(type)), font_type_(type)
-{}
-
-} // namespace html
-
-
-
-////////////////////////////////////////////////////////////////
-///
-/// XHTMLStream
-///
-////////////////////////////////////////////////////////////////
-
-XHTMLStream::XHTMLStream(odocstream & os)
-  : os_(os), escape_(ESCAPE_ALL)
-{}
-
-
-#ifdef XHTML_DEBUG
-void XHTMLStream::dumpTagStack(string const & msg)
+xml::FontTag xhtmlStartFontTag(xml::FontTypes type)
 {
-       *this << html::CR();
-       writeError(msg);
-       *this << html::CR();
-       writeError("Tag Stack");
-       TagDeque::const_reverse_iterator it = tag_stack_.rbegin();
-       TagDeque::const_reverse_iterator en = tag_stack_.rend();
-       for (; it != en; ++it) {
-               writeError(it->get()->tag_);
-       }
-       writeError("End Tag Stack");
-       *this << html::CR();
-       writeError("Pending Tags");
-       it = pending_tags_.rbegin();
-       en = pending_tags_.rend();
-       for (; it != en; ++it) {
-               writeError(it->get()->tag_);
-       }
-       writeError("End Pending Tags");
-       *this << html::CR();
+       return xml::FontTag(fontToHtmlTag(type), from_utf8(fontToAttribute(type)), type);
 }
-#endif
 
 
-void XHTMLStream::writeError(std::string const & s) const
+xml::EndFontTag xhtmlEndFontTag(xml::FontTypes type)
 {
-       LYXERR0(s);
-       os_ << from_utf8("<!-- Output Error: " + s + " -->\n");
+       return xml::EndFontTag(fontToHtmlTag(type), type);
 }
 
-
-namespace {
-       // an illegal tag for internal use
-       static html::StartTag const parsep_tag("&LyX_parsep_tag&");
-} // namespace
-
-
-bool XHTMLStream::closeFontTags()
-{
-       if (isTagPending(parsep_tag))
-               // we haven't had any content
-               return true;
-
-#ifdef XHTML_DEBUG
-       dumpTagStack("Beging Close Font Tags");
-#endif
-
-       // this may be a useless check, since we ought at least to have
-       // the parsep_tag. but it can't hurt too much to be careful.
-       if (tag_stack_.empty())
-               return true;
-
-       // first, we close any open font tags we can close
-       TagPtr curtag = tag_stack_.back();
-       while (curtag->asFontTag()) {
-               os_ << curtag->writeEndTag();
-               tag_stack_.pop_back();
-               // this shouldn't happen, since then the font tags
-               // weren't in any other tag.
-               LASSERT(!tag_stack_.empty(), return true);
-               curtag = tag_stack_.back();
-       }
-
-#ifdef XHTML_DEBUG
-       dumpTagStack("End Close Font Tags");
-#endif
-
-       if (*curtag == parsep_tag)
-               return true;
-
-       // so we've hit a non-font tag.
-       writeError("Tags still open in closeFontTags(). Probably not a problem,\n"
-                  "but you might want to check these tags:");
-       TagDeque::const_reverse_iterator it = tag_stack_.rbegin();
-       TagDeque::const_reverse_iterator const en = tag_stack_.rend();
-       for (; it != en; ++it) {
-               if (**it == parsep_tag)
-                       break;
-               writeError((*it)->tag_);
-       }
-       return false;
-}
-
-
-void XHTMLStream::startDivision(bool keep_empty)
-{
-       pending_tags_.push_back(makeTagPtr(html::StartTag(parsep_tag)));
-       if (keep_empty)
-               clearTagDeque();
-#ifdef XHTML_DEBUG
-       dumpTagStack("StartDivision");
-#endif
-}
-
-
-void XHTMLStream::endDivision()
-{
-       if (isTagPending(parsep_tag)) {
-               // this case is normal. it just means we didn't have content,
-               // so the parsep_tag never got moved onto the tag stack.
-               while (!pending_tags_.empty()) {
-                       // clear all pending tags up to and including the parsep tag.
-                       // note that we work from the back, because we want to get rid
-                       // of everything that hasn't been used.
-                       TagPtr const cur_tag = pending_tags_.back();
-                       pending_tags_.pop_back();
-                       if (*cur_tag == parsep_tag)
-                               break;
-               }
-
-#ifdef XHTML_DEBUG
-               dumpTagStack("EndDivision");
-#endif
-
-               return;
-       }
-
-       if (!isTagOpen(parsep_tag)) {
-               writeError("No division separation tag found in endDivision().");
-               return;
-       }
-
-       // this case is also normal, if the parsep tag is the last one
-       // on the stack. otherwise, it's an error.
-       while (!tag_stack_.empty()) {
-               TagPtr const cur_tag = tag_stack_.back();
-               tag_stack_.pop_back();
-               if (*cur_tag == parsep_tag)
-                       break;
-               writeError("Tag `" + cur_tag->tag_ + "' still open at end of paragraph. Closing.");
-               os_ << cur_tag->writeEndTag();
-       }
-
-#ifdef XHTML_DEBUG
-       dumpTagStack("EndDivision");
-#endif
-}
-
-
-void XHTMLStream::clearTagDeque()
-{
-       while (!pending_tags_.empty()) {
-               TagPtr const tag = pending_tags_.front();
-               if (*tag != parsep_tag)
-                       // tabs?
-                       os_ << tag->writeTag();
-               tag_stack_.push_back(tag);
-               pending_tags_.pop_front();
-       }
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(docstring const & d)
-{
-       clearTagDeque();
-       os_ << html::htmlize(d, escape_);
-       escape_ = ESCAPE_ALL;
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(const char * s)
-{
-       clearTagDeque();
-       docstring const d = from_ascii(s);
-       os_ << html::htmlize(d, escape_);
-       escape_ = ESCAPE_ALL;
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(char_type c)
-{
-       clearTagDeque();
-       os_ << html::escapeChar(c, escape_);
-       escape_ = ESCAPE_ALL;
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(char c)
-{
-       clearTagDeque();
-       os_ << html::escapeChar(c, escape_);
-       escape_ = ESCAPE_ALL;
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(int i)
-{
-       clearTagDeque();
-       os_ << i;
-       escape_ = ESCAPE_ALL;
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(EscapeSettings e)
-{
-       escape_ = e;
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(html::StartTag const & tag)
-{
-       if (tag.tag_.empty())
-               return *this;
-       pending_tags_.push_back(makeTagPtr(tag));
-       if (tag.keepempty_)
-               clearTagDeque();
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(html::ParTag const & tag)
-{
-       if (tag.tag_.empty())
-               return *this;
-       pending_tags_.push_back(makeTagPtr(tag));
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(html::CompTag const & tag)
-{
-       if (tag.tag_.empty())
-               return *this;
-       clearTagDeque();
-       os_ << tag.writeTag();
-       *this << html::CR();
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(html::FontTag const & tag)
-{
-       if (tag.tag_.empty())
-               return *this;
-       pending_tags_.push_back(makeTagPtr(tag));
-       return *this;
-}
-
-
-XHTMLStream & XHTMLStream::operator<<(html::CR const &)
-{
-       // tabs?
-       os_ << from_ascii("\n");
-       return *this;
-}
-
-
-bool XHTMLStream::isTagOpen(html::StartTag const & stag) const
-{
-       TagDeque::const_iterator sit = tag_stack_.begin();
-       TagDeque::const_iterator const sen = tag_stack_.end();
-       for (; sit != sen; ++sit)
-               if (**sit == stag)
-                       return true;
-       return false;
-}
-
-
-bool XHTMLStream::isTagOpen(html::EndTag const & etag) const
-{
-       TagDeque::const_iterator sit = tag_stack_.begin();
-       TagDeque::const_iterator const sen = tag_stack_.end();
-       for (; sit != sen; ++sit)
-               if (etag == **sit)
-                       return true;
-       return false;
-}
-
-
-bool XHTMLStream::isTagPending(html::StartTag const & stag) const
-{
-       TagDeque::const_iterator sit = pending_tags_.begin();
-       TagDeque::const_iterator const sen = pending_tags_.end();
-       for (; sit != sen; ++sit)
-               if (**sit == stag)
-                       return true;
-       return false;
-}
-
-
-// this is complicated, because we want to make sure that
-// everything is properly nested. the code ought to make
-// sure of that, but we won't assert (yet) if we run into
-// a problem. we'll just output error messages and try our
-// best to make things work.
-XHTMLStream & XHTMLStream::operator<<(html::EndTag const & etag)
-{
-       if (etag.tag_.empty())
-               return *this;
-
-       // if this tag is pending, we can simply discard it.
-       if (!pending_tags_.empty()) {
-
-               if (etag == *pending_tags_.back()) {
-                       // we have <tag></tag>, so we discard it and remove it
-                       // from the pending_tags_.
-                       pending_tags_.pop_back();
-                       return *this;
-               }
-
-               // there is a pending tag that isn't the one we are trying
-               // to close.
-
-               // is this tag itself pending?
-               // non-const iterators because we may call erase().
-               TagDeque::iterator dit = pending_tags_.begin();
-               TagDeque::iterator const den = pending_tags_.end();
-               for (; dit != den; ++dit) {
-                       if (etag == **dit) {
-                               // it was pending, so we just erase it
-                               writeError("Tried to close pending tag `" + etag.tag_
-                                       + "' when other tags were pending. Last pending tag is `"
-                                       + to_utf8(pending_tags_.back()->writeTag())
-                                       + "'. Tag discarded.");
-                               pending_tags_.erase(dit);
-                               return *this;
-                       }
-               }
-               // so etag isn't itself pending. is it even open?
-               if (!isTagOpen(etag)) {
-                       writeError("Tried to close `" + etag.tag_
-                                + "' when tag was not open. Tag discarded.");
-                       return *this;
-               }
-               // ok, so etag is open.
-               // our strategy will be as below: we will do what we need to
-               // do to close this tag.
-               string estr = "Closing tag `" + etag.tag_
-                       + "' when other tags are pending. Discarded pending tags:\n";
-               for (dit = pending_tags_.begin(); dit != den; ++dit)
-                       estr += to_utf8(html::htmlize((*dit)->writeTag(), XHTMLStream::ESCAPE_ALL)) + "\n";
-               writeError(estr);
-               // clear the pending tags...
-               pending_tags_.clear();
-               // ...and then just fall through.
-       }
-
-       // make sure there are tags to be closed
-       if (tag_stack_.empty()) {
-               writeError("Tried to close `" + etag.tag_
-                        + "' when no tags were open!");
-               return *this;
-       }
-
-       // is the tag we are closing the last one we opened?
-       if (etag == *tag_stack_.back()) {
-               // output it...
-               os_ << etag.writeEndTag();
-               // ...and forget about it
-               tag_stack_.pop_back();
-               return *this;
-       }
-
-       // we are trying to close a tag other than the one last opened.
-       // let's first see if this particular tag is still open somehow.
-       if (!isTagOpen(etag)) {
-               writeError("Tried to close `" + etag.tag_
-                       + "' when tag was not open. Tag discarded.");
-               return *this;
-       }
-
-       // so the tag was opened, but other tags have been opened since
-       // and not yet closed.
-       // if it's a font tag, though...
-       if (etag.asFontTag()) {
-               // it won't be a problem if the other tags open since this one
-               // are also font tags.
-               TagDeque::const_reverse_iterator rit = tag_stack_.rbegin();
-               TagDeque::const_reverse_iterator ren = tag_stack_.rend();
-               for (; rit != ren; ++rit) {
-                       if (etag == **rit)
-                               break;
-                       if (!(*rit)->asFontTag()) {
-                               // we'll just leave it and, presumably, have to close it later.
-                               writeError("Unable to close font tag `" + etag.tag_
-                                       + "' due to open non-font tag `" + (*rit)->tag_ + "'.");
-                               return *this;
-                       }
-               }
-
-               // so we have e.g.:
-               //    <em>this is <strong>bold
-               // and are being asked to closed em. we want:
-               //    <em>this is <strong>bold</strong></em><strong>
-               // first, we close the intervening tags...
-               TagPtr curtag = tag_stack_.back();
-               // ...remembering them in a stack.
-               TagDeque fontstack;
-               while (etag != *curtag) {
-                       os_ << curtag->writeEndTag();
-                       fontstack.push_back(curtag);
-                       tag_stack_.pop_back();
-                       curtag = tag_stack_.back();
-               }
-               os_ << etag.writeEndTag();
-               tag_stack_.pop_back();
-
-               // ...and restore the other tags.
-               rit = fontstack.rbegin();
-               ren = fontstack.rend();
-               for (; rit != ren; ++rit)
-                       pending_tags_.push_back(*rit);
-               return *this;
-       }
-
-       // it wasn't a font tag.
-       // so other tags were opened before this one and not properly closed.
-       // so we'll close them, too. that may cause other issues later, but it
-       // at least guarantees proper nesting.
-       writeError("Closing tag `" + etag.tag_
-               + "' when other tags are open, namely:");
-       TagPtr curtag = tag_stack_.back();
-       while (etag != *curtag) {
-               writeError(curtag->tag_);
-               if (*curtag != parsep_tag)
-                       os_ << curtag->writeEndTag();
-               tag_stack_.pop_back();
-               curtag = tag_stack_.back();
-       }
-       // curtag is now the one we actually want.
-       os_ << curtag->writeEndTag();
-       tag_stack_.pop_back();
-
-       return *this;
-}
-
-// End code for XHTMLStream
-
 namespace {
 
 // convenience functions
 
-inline void openParTag(XHTMLStream & xs, Layout const & lay,
+inline void openParTag(XMLStream & xs, Layout const & lay,
                        std::string parlabel)
 {
-       xs << html::ParTag(lay.htmltag(), lay.htmlattr(), parlabel);
+       xs << xml::ParTag(lay.htmltag(), lay.htmlattr(), parlabel);
 }
 
 
-void openParTag(XHTMLStream & xs, Layout const & lay,
+void openParTag(XMLStream & xs, Layout const & lay,
                 ParagraphParameters const & params,
                 std::string parlabel)
 {
@@ -750,35 +182,35 @@ void openParTag(XHTMLStream & xs, Layout const & lay,
                return;
        }
        string attrs = lay.htmlattr() + " style='text-align: " + align + ";'";
-       xs << html::ParTag(lay.htmltag(), attrs, parlabel);
+       xs << xml::ParTag(lay.htmltag(), attrs, parlabel);
 }
 
 
-inline void closeTag(XHTMLStream & xs, Layout const & lay)
+inline void closeTag(XMLStream & xs, Layout const & lay)
 {
-       xs << html::EndTag(lay.htmltag());
+       xs << xml::EndTag(lay.htmltag());
 }
 
 
-inline void openLabelTag(XHTMLStream & xs, Layout const & lay)
+inline void openLabelTag(XMLStream & xs, Layout const & lay)
 {
-       xs << html::StartTag(lay.htmllabeltag(), lay.htmllabelattr());
+       xs << xml::StartTag(lay.htmllabeltag(), lay.htmllabelattr());
 }
 
 
-inline void closeLabelTag(XHTMLStream & xs, Layout const & lay)
+inline void closeLabelTag(XMLStream & xs, Layout const & lay)
 {
-       xs << html::EndTag(lay.htmllabeltag());
+       xs << xml::EndTag(lay.htmllabeltag());
 }
 
 
-inline void openItemTag(XHTMLStream & xs, Layout const & lay)
+inline void openItemTag(XMLStream & xs, Layout const & lay)
 {
-       xs << html::StartTag(lay.htmlitemtag(), lay.htmlitemattr(), true);
+       xs << xml::StartTag(lay.htmlitemtag(), lay.htmlitemattr(), true);
 }
 
 
-void openItemTag(XHTMLStream & xs, Layout const & lay,
+void openItemTag(XMLStream & xs, Layout const & lay,
              ParagraphParameters const & params)
 {
        // FIXME Are there other things we should handle here?
@@ -788,13 +220,13 @@ void openItemTag(XHTMLStream & xs, Layout const & lay,
                return;
        }
        string attrs = lay.htmlattr() + " style='text-align: " + align + ";'";
-       xs << html::StartTag(lay.htmlitemtag(), attrs);
+       xs << xml::StartTag(lay.htmlitemtag(), attrs);
 }
 
 
-inline void closeItemTag(XHTMLStream & xs, Layout const & lay)
+inline void closeItemTag(XMLStream & xs, Layout const & lay)
 {
-       xs << html::EndTag(lay.htmlitemtag());
+       xs << xml::EndTag(lay.htmlitemtag());
 }
 
 // end of convenience functions
@@ -844,7 +276,7 @@ ParagraphList::const_iterator findEndOfEnvironment(
 
 
 ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
-                                           XHTMLStream & xs,
+                                           XMLStream & xs,
                                            OutputParams const & runparams,
                                            Text const & text,
                                            ParagraphList::const_iterator const & pbegin,
@@ -861,7 +293,7 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
                // FIXME We should see if there's a label to be output and
                // do something with it.
                if (par != pbegin)
-                       xs << html::CR();
+                       xs << xml::CR();
 
                // We want to open the paragraph tag if:
                //   (i) the current layout permits multiple paragraphs
@@ -918,11 +350,11 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
 
                if (close_par) {
                        closeTag(xs, lay);
-                       xs << html::CR();
+                       xs << xml::CR();
                }
 
                if (!deferred.empty()) {
-                       xs << XHTMLStream::ESCAPE_NONE << deferred << html::CR();
+                       xs << XMLStream::ESCAPE_NONE << deferred << xml::CR();
                }
        }
        return pend;
@@ -930,7 +362,7 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
 
 
 ParagraphList::const_iterator makeBibliography(Buffer const & buf,
-                               XHTMLStream & xs,
+                               XMLStream & xs,
                                OutputParams const & runparams,
                                Text const & text,
                                ParagraphList::const_iterator const & pbegin,
@@ -938,14 +370,14 @@ ParagraphList::const_iterator makeBibliography(Buffer const & buf,
 {
        // FIXME XHTML
        // Use TextClass::htmlTOCLayout() to figure out how we should look.
-       xs << html::StartTag("h2", "class='bibliography'")
+       xs << xml::StartTag("h2", "class='bibliography'")
           << pbegin->layout().labelstring(false)
-          << html::EndTag("h2")
-          << html::CR()
-          << html::StartTag("div", "class='bibliography'")
-          << html::CR();
+          << xml::EndTag("h2")
+          << xml::CR()
+          << xml::StartTag("div", "class='bibliography'")
+          << xml::CR();
        makeParagraphs(buf, xs, runparams, text, pbegin, pend);
-       xs << html::EndTag("div");
+       xs << xml::EndTag("div");
        return pend;
 }
 
@@ -958,7 +390,7 @@ bool isNormalEnv(Layout const & lay)
 
 
 ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
-                                             XHTMLStream & xs,
+                                             XMLStream & xs,
                                              OutputParams const & runparams,
                                              Text const & text,
                                              ParagraphList::const_iterator const & pbegin,
@@ -971,7 +403,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
 
        // open tag for this environment
        openParTag(xs, bstyle, pbegin->magicLabel());
-       xs << html::CR();
+       xs << xml::CR();
 
        // we will on occasion need to remember a layout from before.
        Layout const * lastlay = nullptr;
@@ -997,7 +429,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                case LATEX_ENVIRONMENT:
                case LATEX_LIST_ENVIRONMENT:
                case LATEX_ITEM_ENVIRONMENT: {
-                       // There are two possiblities in this case.
+                       // There are two possibilities in this case.
                        // One is that we are still in the environment in which we
                        // started---which we will be if the depth is the same.
                        if (par->params().depth() == origdepth) {
@@ -1028,20 +460,20 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                                                                xs << lbl;
                                                                closeLabelTag(xs, style);
                                                        }
-                                                       xs << html::CR();
+                                                       xs << xml::CR();
                                                }
                                        } else { // some kind of list
                                                if (style.labeltype == LABEL_MANUAL) {
                                                        openLabelTag(xs, style);
                                                        sep = par->firstWordLyXHTML(xs, runparams);
                                                        closeLabelTag(xs, style);
-                                                       xs << html::CR();
+                                                       xs << xml::CR();
                                                }
                                                else {
                                                        openLabelTag(xs, style);
                                                        xs << par->params().labelString();
                                                        closeLabelTag(xs, style);
-                                                       xs << html::CR();
+                                                       xs << xml::CR();
                                                }
                                        }
                                } // end label output
@@ -1051,7 +483,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
 
                                docstring deferred = par->simpleLyXHTMLOnePar(buf, xs, runparams,
                                        text.outerFont(distance(begin, par)), true, true, sep);
-                               xs << XHTMLStream::ESCAPE_NONE << deferred;
+                               xs << XMLStream::ESCAPE_NONE << deferred;
                                ++par;
 
                                // We may not want to close the tag yet, in particular:
@@ -1066,7 +498,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                                        lastlay = &style;
                                } else
                                        closeItemTag(xs, style);
-                               xs << html::CR();
+                               xs << xml::CR();
                        }
                        // The other possibility is that the depth has increased, in which
                        // case we need to recurse.
@@ -1096,13 +528,13 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
        if (lastlay != nullptr)
                closeItemTag(xs, *lastlay);
        closeTag(xs, bstyle);
-       xs << html::CR();
+       xs << xml::CR();
        return pend;
 }
 
 
 void makeCommand(Buffer const & buf,
-                XHTMLStream & xs,
+                XMLStream & xs,
                 OutputParams const & runparams,
                 Text const & text,
                 ParagraphList::const_iterator const & pbegin)
@@ -1132,7 +564,7 @@ void makeCommand(Buffer const & buf,
        pbegin->simpleLyXHTMLOnePar(buf, xs, runparams,
                        text.outerFont(distance(begin, pbegin)));
        closeTag(xs, style);
-       xs << html::CR();
+       xs << xml::CR();
 }
 
 } // end anonymous namespace
@@ -1140,7 +572,7 @@ void makeCommand(Buffer const & buf,
 
 void xhtmlParagraphs(Text const & text,
                       Buffer const & buf,
-                      XHTMLStream & xs,
+                      XMLStream & xs,
                       OutputParams const & runparams)
 {
        ParagraphList const & paragraphs = text.paragraphs();
@@ -1151,7 +583,7 @@ void xhtmlParagraphs(Text const & text,
        pit_type bpit = runparams.par_begin;
        pit_type const epit = runparams.par_end;
        LASSERT(bpit < epit,
-               { xs << XHTMLStream::ESCAPE_NONE << "<!-- XHTML output error! -->\n"; return; });
+               { xs << XMLStream::ESCAPE_NONE << "<!-- XHTML output error! -->\n"; return; });
 
        OutputParams ourparams = runparams;
        ParagraphList::const_iterator const pend =
index a9ee0ea090baa8230509aa9cd811a09da9709084..562d380a2d3f1e4d1b24dc5ed4efdba55eb5e25f 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "support/docstream.h"
 #include "support/strfwd.h"
+#include "xml.h"
 
 #include <deque>
 #include <memory>
 
 namespace lyx {
 
+docstring const & fontToHtmlTag(xml::FontTypes type);
+
 class Buffer;
 class OutputParams;
 class Text;
 
-// Inspiration for the *Tag structs and for XHTMLStream
-// came from MathStream and its cousins.
-
-namespace html {
-
-struct FontTag;
-struct EndFontTag;
-
-/// Attributes will be escaped automatically and so should NOT
-/// be escaped before being passed to the constructor.
-struct StartTag
-{
-       ///
-       explicit StartTag(std::string const & tag) : tag_(tag), keepempty_(false) {}
-       ///
-       explicit StartTag(std::string const & tag, std::string const & attr,
-               bool keepempty = false)
-               : tag_(tag), attr_(attr), keepempty_(keepempty) {}
-       ///
-       virtual ~StartTag() {}
-       /// <tag_ attr_>
-       virtual docstring writeTag() const;
-       /// </tag_>
-       virtual docstring writeEndTag() const;
-       ///
-       virtual FontTag const * asFontTag() const { return 0; }
-       ///
-       virtual bool operator==(StartTag const & rhs) const
-               { return tag_ == rhs.tag_; }
-       ///
-       virtual bool operator!=(StartTag const & rhs) const
-               { return !(*this == rhs); }
-       ///
-       virtual bool operator==(FontTag const & rhs) const;
-       ///
-       std::string tag_;
-       ///
-       std::string attr_;
-       /// whether to keep things like "<tag></tag>" or discard them
-       /// you would want this for td, e.g, but maybe not for a div
-       bool keepempty_;
-};
-
-
-///
-struct EndTag
-{
-       ///
-       explicit EndTag(std::string const & tag) : tag_(tag) {}
-       ///
-       virtual ~EndTag() {}
-       /// </tag_>
-       virtual docstring writeEndTag() const;
-       ///
-       bool operator==(StartTag const & rhs) const
-               { return tag_ == rhs.tag_; }
-       ///
-       bool operator!=(StartTag const & rhs) const
-               { return !(*this == rhs); }
-       ///
-       virtual EndFontTag const * asFontTag() const { return 0; }
-       ///
-       std::string tag_;
-};
-
-
-/// Tags like <img />
-/// Attributes will be escaped automatically and so should NOT
-/// be escaped before being passed to the constructor.
-struct CompTag
-{
-       ///
-       explicit CompTag(std::string const & tag)
-               : tag_(tag) {}
-       ///
-       explicit CompTag(std::string const & tag, std::string const & attr)
-               : tag_(tag), attr_(attr) {}
-       /// <tag_ attr_ />
-       docstring writeTag() const;
-       ///
-       std::string tag_;
-       ///
-       std::string attr_;
-};
-
-
-/// A special case of StartTag, used exclusively for tags that wrap paragraphs.
-struct ParTag : public StartTag
-{
-       ///
-       explicit ParTag(std::string const & tag, std::string attr,
-              std::string const & parid);
-       ///
-       ~ParTag() {}
-};
-
-
-///
-enum FontTypes {
-       // ranges
-       FT_EMPH,
-       FT_NOUN,
-       FT_UBAR,
-       FT_DBAR,
-       FT_WAVE,
-       FT_SOUT,
-       FT_XOUT,
-       // bold
-       FT_BOLD,
-       // shapes
-       FT_UPRIGHT,
-       FT_ITALIC,
-       FT_SLANTED,
-       FT_SMALLCAPS,
-       // families
-       FT_ROMAN,
-       FT_SANS,
-       FT_TYPE,
-       // sizes
-       FT_SIZE_TINY,
-       FT_SIZE_SCRIPT,
-       FT_SIZE_FOOTNOTE,
-       FT_SIZE_SMALL,
-       FT_SIZE_NORMAL,
-       FT_SIZE_LARGE,
-       FT_SIZE_LARGER,
-       FT_SIZE_LARGEST,
-       FT_SIZE_HUGE,
-       FT_SIZE_HUGER,
-       FT_SIZE_INCREASE,
-       FT_SIZE_DECREASE
-};
-
-
 ///
-struct FontTag : public StartTag
-{
-       ///
-       explicit FontTag(FontTypes type);
-       ///
-       FontTag const * asFontTag() const { return this; }
-       ///
-       bool operator==(StartTag const &) const;
-       ///
-       FontTypes font_type_;
-};
-
-
+xml::FontTag xhtmlStartFontTag(xml::FontTypes type);
 ///
-struct EndFontTag : public EndTag
-{
-       ///
-       explicit EndFontTag(FontTypes type);
-       ///
-       EndFontTag const * asFontTag() const { return this; }
-       ///
-       FontTypes font_type_;
-};
-
-
-// trivial struct for output of newlines
-struct CR{};
-
-} // namespace html
-
-class XHTMLStream {
-public:
-       ///
-       explicit XHTMLStream(odocstream & os);
-       ///
-       odocstream & os() { return os_; }
-       ///
-       // int & tab() { return tab_; }
-       /// closes any font tags that are eligible to be closed,
-       /// i.e., last on the tag_stack_.
-       /// \return false if there are open font tags we could not close.
-       /// because they are "blocked" by open non-font tags on the stack.
-       bool closeFontTags();
-       /// sets a mark so we know what tags to close at the end.
-       /// normally called at the start of a paragraph.
-       void startDivision(bool keep_empty);
-       /// clears the mark set by previous method.
-       /// there should not be any other tags open before it on the stack,
-       /// but if there are, we will close them.
-       void endDivision();
-       ///
-       XHTMLStream & operator<<(docstring const &);
-       ///
-       XHTMLStream & operator<<(const char *);
-       ///
-       XHTMLStream & operator<<(char_type);
-       ///
-       XHTMLStream & operator<<(int);
-       ///
-       XHTMLStream & operator<<(char);
-       ///
-       XHTMLStream & operator<<(html::StartTag const &);
-       ///
-       XHTMLStream & operator<<(html::EndTag const &);
-       ///
-       XHTMLStream & operator<<(html::CompTag const &);
-       ///
-       XHTMLStream & operator<<(html::ParTag const &);
-       ///
-       XHTMLStream & operator<<(html::FontTag const &);
-       ///
-       XHTMLStream & operator<<(html::CR const &);
-       ///
-       enum EscapeSettings {
-               ESCAPE_NONE,
-               ESCAPE_AND, // meaning &
-               ESCAPE_ALL  // meaning <, >, &, at present
-       };
-       /// Sets what we are going to escape on the NEXT write.
-       /// Everything is reset for the next time.
-       XHTMLStream & operator<<(EscapeSettings);
-       /// This routine is for debugging the tag stack, etc. Code
-       /// for it is disabled by default, however, so you will need
-       /// to enable it if you want to use it.
-       void dumpTagStack(std::string const & msg);
-private:
-       ///
-       void clearTagDeque();
-       ///
-       bool isTagOpen(html::StartTag const &) const;
-       ///
-       bool isTagOpen(html::EndTag const &) const;
-       ///
-       bool isTagPending(html::StartTag const &) const;
-       ///
-       void writeError(std::string const &) const;
-       ///
-       odocstream & os_;
-       ///
-       EscapeSettings escape_;
-       // What we would really like to do here is simply use a
-       // deque<StartTag>. But we want to store both StartTags and
-       // sub-classes thereof on this stack, which means we run into the
-       // so-called polymorphic class problem with the STL. We therefore have
-       // to use a deque<StartTag *>, which leads to the question who will
-       // own these pointers and how they will be deleted, so we use shared
-       // pointers.
-       ///
-       typedef std::shared_ptr<html::StartTag> TagPtr;
-       typedef std::deque<TagPtr> TagDeque;
-       ///
-       template <typename T>
-       TagPtr makeTagPtr(T const & tag) { return std::make_shared<T>(tag); }
-       ///
-       TagDeque pending_tags_;
-       ///
-       TagDeque tag_stack_;
-};
+xml::EndFontTag xhtmlEndFontTag(xml::FontTypes type);
 
 ///
 void xhtmlParagraphs(Text const & text,
                       Buffer const & buf,
-                      XHTMLStream & xs,
+                      XMLStream & xs,
                       OutputParams const & runparams);
 
 /// \return a string appropriate for setting alignment in CSS
 /// Does NOT return "justify" for "block"
 std::string alignmentToCSS(LyXAlignment align);
 
-namespace html {
-///
-docstring escapeChar(char_type c, XHTMLStream::EscapeSettings e);
-/// converts a string to a form safe for links, etc
-docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e);
-/// cleans \param str for use as an atttribute by replacing
-/// all non-alnum by "_"
-docstring cleanAttr(docstring const & str);
-/// \p c must be ASCII
-docstring escapeChar(char c, XHTMLStream::EscapeSettings e);
-
-} // namespace html
 } // namespace lyx
 
 #endif
diff --git a/src/sgml.cpp b/src/sgml.cpp
deleted file mode 100644 (file)
index 2facb3e..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/**
- * \file sgml.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author José Matos
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "sgml.h"
-
-#include "Buffer.h"
-#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/docstream.h"
-#include "support/lstrings.h"
-#include "support/textutils.h"
-
-#include <atomic>
-#include <map>
-#include <QThreadStorage>
-
-using namespace std;
-using namespace lyx::support;
-
-namespace lyx {
-
-
-docstring sgml::escapeChar(char_type c)
-{
-       docstring str;
-       switch (c) {
-       case ' ':
-               str += " ";
-               break;
-       case '&':
-               str += "&amp;";
-               break;
-       case '<':
-               str += "&lt;";
-               break;
-       case '>':
-               str += "&gt;";
-               break;
-#if 0
-       case '$':
-               str += "&dollar;";
-               break;
-       case '#':
-               str += "&num;";
-               break;
-       case '%':
-               str += "&percnt;";
-               break;
-       case '[':
-               str += "&lsqb;";
-               break;
-       case ']':
-               str += "&rsqb;";
-               break;
-       case '{':
-               str += "&lcub;";
-               break;
-       case '}':
-               str += "&rcub;";
-               break;
-       case '~':
-               str += "&tilde;";
-               break;
-       case '"':
-               str += "&quot;";
-               break;
-       case '\\':
-               str += "&bsol;";
-               break;
-#endif
-       default:
-               str += c;
-               break;
-       }
-       return str;
-}
-
-
-docstring sgml::escapeString(docstring const & raw)
-{
-       docstring bin;
-       bin.reserve(raw.size() * 2); // crude approximation is sufficient
-       for (size_t i = 0; i != raw.size(); ++i)
-               bin += sgml::escapeChar(raw[i]);
-
-       return bin;
-}
-
-
-docstring const sgml::uniqueID(docstring const & label)
-{
-       // thread-safe
-       static atomic_uint seed(1000);
-       return label + convert<docstring>(++seed);
-}
-
-
-docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams,
-       docstring const & orig)
-{
-       // The standard DocBook SGML declaration only allows letters,
-       // digits, '-' and '.' in a name.
-       // Since users might change that declaration one has to cater
-       // for additional allowed characters.
-       // This routine replaces illegal characters by '-' or '.'
-       // and adds a number for uniqueness.
-       // If you know what you are doing, you can set allowed==""
-       // to disable this mangling.
-       DocumentClass const & tclass = buf.params().documentClass();
-       docstring const allowed = from_ascii(
-               runparams.flavor == OutputParams::XML ? ".-_:" : tclass.options());
-
-       if (allowed.empty())
-               return orig;
-
-       docstring::const_iterator it  = orig.begin();
-       docstring::const_iterator end = orig.end();
-
-       docstring content;
-
-       typedef map<docstring, docstring> MangledMap;
-       static QThreadStorage<MangledMap> tMangledNames;
-       static QThreadStorage<int> tMangleID;
-
-       MangledMap & mangledNames = tMangledNames.localData();
-
-       MangledMap::const_iterator const known = mangledNames.find(orig);
-       if (known != mangledNames.end())
-               return known->second;
-
-       // make sure it starts with a letter
-       if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size())
-               content += "x";
-
-       bool mangle = false;
-       for (; it != end; ++it) {
-               char_type c = *it;
-               if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.'
-                     || allowed.find(c) < allowed.size())
-                       content += c;
-               else if (c == '_' || c == ' ') {
-                       mangle = true;
-                       content += "-";
-               }
-               else if (c == ':' || c == ',' || c == ';' || c == '!') {
-                       mangle = true;
-                       content += ".";
-               }
-               else {
-                       mangle = true;
-               }
-       }
-
-       if (mangle) {
-               int & mangleID = tMangleID.localData();
-               content += "-" + convert<docstring>(mangleID++);
-       } else if (isDigitASCII(content[content.size() - 1]))
-               content += ".";
-
-       mangledNames[orig] = content;
-
-       return content;
-}
-
-
-void sgml::openTag(odocstream & os, string const & name, string const & attribute)
-{
-       // FIXME UNICODE
-       // This should be fixed in layout files later.
-       string param = subst(attribute, "<", "\"");
-       param = subst(param, ">", "\"");
-
-       // Note: we ignore the name if it 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
-       // 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") {
-               os << '<' << from_ascii(name);
-               if (!param.empty())
-                       os << ' ' << from_ascii(param);
-               os << '>';
-       }
-}
-
-
-void sgml::closeTag(odocstream & os, string const & name)
-{
-       if (!name.empty() && name != "!-- --" && name != "dummy")
-               os << "</" << from_ascii(name) << '>';
-}
-
-
-void sgml::openTag(Buffer const & buf, odocstream & os,
-       OutputParams const & runparams, Paragraph const & par)
-{
-       Layout const & style = par.layout();
-       string const & name = style.latexname();
-       string param = style.latexparam();
-       Counters & counters = buf.params().documentClass().counters();
-
-       string id = par.getID(buf, runparams);
-
-       string attribute;
-       if (!id.empty()) {
-               if (param.find('#') != string::npos) {
-                       string::size_type pos = param.find("id=<");
-                       string::size_type end = param.find(">");
-                       if( pos != string::npos && end != string::npos)
-                               param.erase(pos, end-pos + 1);
-               }
-               attribute = id + ' ' + param;
-       } else {
-               if (param.find('#') != string::npos) {
-                       // FIXME UNICODE
-                       if (!style.counter.empty())
-                               // This uses InternalUpdate at the moment becuase sgml output
-                               // does not do anything with tracked counters, and it would need
-                               // to track layouts if it did want to use them.
-                               counters.step(style.counter, InternalUpdate);
-                       else
-                               counters.step(from_ascii(name), InternalUpdate);
-                       int i = counters.value(from_ascii(name));
-                       attribute = subst(param, "#", convert<string>(i));
-               } else {
-                       attribute = param;
-               }
-       }
-       openTag(os, name, attribute);
-}
-
-
-void sgml::closeTag(odocstream & os, Paragraph const & par)
-{
-       Layout const & style = par.layout();
-       closeTag(os, style.latexname());
-}
-
-
-} // namespace lyx
diff --git a/src/sgml.h b/src/sgml.h
deleted file mode 100644 (file)
index a46c9fa..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// -*- C++ -*-
-/**
- * \file sgml.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author José Matos
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef SGML_H
-#define SGML_H
-
-#include "support/docstring.h"
-
-namespace lyx {
-
-class Buffer;
-class Paragraph;
-class OutputParams;
-
-namespace sgml {
-
-/**
- * Escape the given character, if necessary,
- * to an SGML entity.
- */
-docstring escapeChar(char_type c);
-
-/// Escape a word instead of a single character
-docstring escapeString(docstring const & raw);
-
-/// replaces illegal characters from SGML/XML ID attributes
-docstring cleanID(Buffer const & buf, OutputParams const & runparams,
-                   docstring const & orig);
-
-/// returns a unique numeric id
-docstring const uniqueID(docstring const & label);
-
-/// Opens tag
-void openTag(odocstream & os, std::string const & name,
-           std::string const & attribute = std::string());
-
-/// Open tag
-void openTag(Buffer const & buf, odocstream & os,
-            OutputParams const & runparams, Paragraph const & par);
-
-/// Close tag
-void closeTag(odocstream & os, std::string const & name);
-
-/// Close tag
-void closeTag(odocstream & os, Paragraph const & par);
-
-} // namespace sgml
-} // namespace lyx
-
-#endif // SGML_H
index ca6edc38d0ef2e0e85742652fb8a0c80761e24f2..f57061614f0fa367db9a8026fd54091c5657ddac 100644 (file)
@@ -5,6 +5,7 @@
 #include "LyXRC.h"
 
 #include "support/Messages.h"
+#include "xml.h"
 
 using namespace std;
 
@@ -49,4 +50,10 @@ string alignmentToCSS(LyXAlignment)
        return string();
 }
 
+namespace xml {
+docstring StartTag::writeTag() const { return docstring(); }
+docstring StartTag::writeEndTag() const { return docstring(); }
+bool StartTag::operator==(FontTag const & rhs) const { return rhs == *this; }
+}
+
 } // namespace lyx
index c850cd97c113cfcf0b25b8f434378c4da82631bf..fc5098d1f17468a62935aa8bd5110a5a5332b25a 100644 (file)
@@ -114,4 +114,10 @@ string alignmentToCSS(LyXAlignment)
 void lyx_exit(int)
 {}
 
+namespace xml {
+docstring StartTag::writeTag() const { return docstring(); }
+docstring StartTag::writeEndTag() const { return docstring(); }
+bool StartTag::operator==(FontTag const & rhs) const { return rhs == *this; }
+}
+
 } // namespace lyx
diff --git a/src/xml.cpp b/src/xml.cpp
new file mode 100644 (file)
index 0000000..2c30f15
--- /dev/null
@@ -0,0 +1,690 @@
+/**
+ * \file xml.cpp
+ * This file is part of LyX, the document processor.
+ * License details can be found in the file COPYING.
+ *
+ * \author José Matos
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "xml.h"
+
+#include "Buffer.h"
+#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/docstream.h"
+#include "support/lstrings.h"
+#include "support/textutils.h"
+
+#include <atomic>
+#include <map>
+#include <functional>
+#include <QThreadStorage>
+#include <support/lassert.h>
+
+using namespace std;
+using namespace lyx::support;
+
+namespace lyx {
+namespace xml {
+
+
+docstring escapeChar(char_type c, XMLStream::EscapeSettings e)
+{
+       docstring str;
+       switch (e) { // For HTML: always ESCAPE_NONE. For XML: it depends, hence the parameter.
+               case XMLStream::ESCAPE_NONE:
+                       str += c;
+                       break;
+               case XMLStream::ESCAPE_ALL:
+                       if (c == '<') {
+                               str += "&lt;";
+                               break;
+                       } else if (c == '>') {
+                               str += "&gt;";
+                               break;
+                       }
+                       // fall through
+               case XMLStream::ESCAPE_AND:
+                       if (c == '&')
+                               str += "&amp;";
+                       else
+                               str     +=c ;
+                       break;
+       }
+       return str;
+}
+
+
+// escape what needs escaping
+docstring xmlize(docstring const &str, XMLStream::EscapeSettings e) {
+       odocstringstream d;
+       docstring::const_iterator it = str.begin();
+       docstring::const_iterator en = str.end();
+       for (; it != en; ++it)
+               d << escapeChar(*it, e);
+       return d.str();
+}
+
+
+docstring escapeChar(char c, XMLStream::EscapeSettings e) {
+       LATTEST(static_cast<unsigned char>(c) < 0x80);
+       return escapeChar(static_cast<char_type>(c), e);
+}
+
+
+docstring cleanAttr(docstring const & str)
+{
+       docstring newname;
+       docstring::const_iterator it = str.begin();
+       docstring::const_iterator en = str.end();
+       for (; it != en; ++it) {
+               char_type const c = *it;
+               newname += isAlnumASCII(c) ? c : char_type('_');
+       }
+       return newname;
+}
+
+
+docstring StartTag::writeTag() const {
+       docstring output = '<' + tag_;
+       if (!attr_.empty()) {
+               docstring attributes = xml::xmlize(attr_, XMLStream::ESCAPE_NONE);
+               attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(),
+                                                          [](int c) {return !std::isspace(c);}));
+               if (!attributes.empty()) {
+                       output += ' ' + attributes;
+               }
+       }
+       output += ">";
+       return output;
+}
+
+
+docstring StartTag::writeEndTag() const {
+       return from_utf8("</") + tag_ + from_utf8(">");
+}
+
+
+bool StartTag::operator==(FontTag const &rhs) const {
+       return rhs == *this;
+}
+
+
+docstring EndTag::writeEndTag() const {
+       return from_utf8("</") + tag_ + from_utf8(">");
+}
+
+
+docstring CompTag::writeTag() const {
+       docstring output = '<' + from_utf8(tag_);
+       if (!attr_.empty()) {
+               // Erase the beginning of the attributes if it contains space characters: this function deals with that
+               // automatically.
+               docstring attributes = xmlize(from_utf8(attr_), XMLStream::ESCAPE_NONE);
+               attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(),
+                                                          [](int c) {return !std::isspace(c);}));
+               if (!attributes.empty()) {
+                       output += ' ' + attributes;
+               }
+       }
+       output += " />";
+       return output;
+}
+
+
+bool FontTag::operator==(StartTag const & tag) const
+{
+       FontTag const * const ftag = tag.asFontTag();
+       if (!ftag)
+               return false;
+       return (font_type_ == ftag->font_type_);
+}
+
+} // namespace xml
+
+
+void XMLStream::writeError(std::string const &s) const {
+       LYXERR0(s);
+       os_ << from_utf8("<!-- Output Error: " + s + " -->\n");
+}
+
+
+void XMLStream::writeError(docstring const &s) const {
+       LYXERR0(s);
+       os_ << from_utf8("<!-- Output Error: ") << s << from_utf8(" -->\n");
+}
+
+
+bool XMLStream::closeFontTags() {
+       if (isTagPending(xml::parsep_tag))
+               // we haven't had any content
+               return true;
+
+       // this may be a useless check, since we ought at least to have
+       // the parsep_tag. but it can't hurt too much to be careful.
+       if (tag_stack_.empty())
+               return true;
+
+       // first, we close any open font tags we can close
+       TagPtr *curtag = &tag_stack_.back();
+       while ((*curtag)->asFontTag()) {
+               if (**curtag != xml::parsep_tag)
+                       os_ << (*curtag)->writeEndTag();
+               tag_stack_.pop_back();
+               // this shouldn't happen, since then the font tags
+               // weren't in any other tag.
+               LASSERT(!tag_stack_.empty(), return true);
+               curtag = &tag_stack_.back();
+       }
+
+       if (**curtag == xml::parsep_tag)
+               return true;
+
+       // so we've hit a non-font tag.
+       writeError("Tags still open in closeFontTags(). Probably not a problem,\n"
+                                          "but you might want to check these tags:");
+       TagDeque::const_reverse_iterator it = tag_stack_.rbegin();
+       TagDeque::const_reverse_iterator const en = tag_stack_.rend();
+       for (; it != en; ++it) {
+               if (**it == xml::parsep_tag)
+                       break;
+               writeError((*it)->tag_);
+       }
+       return false;
+}
+
+
+void XMLStream::startDivision(bool keep_empty) {
+       pending_tags_.push_back(makeTagPtr(xml::StartTag(xml::parsep_tag)));
+       if (keep_empty)
+               clearTagDeque();
+}
+
+
+void XMLStream::endDivision() {
+       if (isTagPending(xml::parsep_tag)) {
+               // this case is normal. it just means we didn't have content,
+               // so the parsep_tag never got moved onto the tag stack.
+               while (!pending_tags_.empty()) {
+                       // clear all pending tags up to and including the parsep tag.
+                       // note that we work from the back, because we want to get rid
+                       // of everything that hasn't been used.
+                       TagPtr const cur_tag = pending_tags_.back();
+                       pending_tags_.pop_back();
+                       if (*cur_tag == xml::parsep_tag)
+                               break;
+               }
+
+#ifdef XHTML_DEBUG
+               dumpTagStack("EndDivision");
+#endif
+
+               return;
+       }
+
+       if (!isTagOpen(xml::parsep_tag)) {
+               writeError("No division separation tag found in endDivision().");
+               return;
+       }
+
+       // this case is also normal, if the parsep tag is the last one
+       // on the stack. otherwise, it's an error.
+       while (!tag_stack_.empty()) {
+               TagPtr const cur_tag = tag_stack_.back();
+               tag_stack_.pop_back();
+               if (*cur_tag == xml::parsep_tag)
+                       break;
+               writeError("Tag `" + cur_tag->tag_ + "' still open at end of paragraph. Closing.");
+               os_ << cur_tag->writeEndTag();
+       }
+
+#ifdef XHTML_DEBUG
+       dumpTagStack("EndDivision");
+#endif
+}
+
+
+void XMLStream::clearTagDeque() {
+       while (!pending_tags_.empty()) {
+               TagPtr const & tag = pending_tags_.front();
+               if (*tag != xml::parsep_tag)
+                       // tabs?
+                       os_ << tag->writeTag();
+               tag_stack_.push_back(tag);
+               pending_tags_.pop_front();
+       }
+}
+
+
+XMLStream &XMLStream::operator<<(docstring const &d) {
+       clearTagDeque();
+       os_ << xml::xmlize(d, escape_);
+       escape_ = ESCAPE_ALL;
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(const char *s) {
+       clearTagDeque();
+       docstring const d = from_ascii(s);
+       os_ << xml::xmlize(d, escape_);
+       escape_ = ESCAPE_ALL;
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(char_type c) {
+       clearTagDeque();
+       os_ << xml::escapeChar(c, escape_);
+       escape_ = ESCAPE_ALL;
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(char c) {
+       clearTagDeque();
+       os_ << xml::escapeChar(c, escape_);
+       escape_ = ESCAPE_ALL;
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(int i) {
+       clearTagDeque();
+       os_ << i;
+       escape_ = ESCAPE_ALL;
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(EscapeSettings e) {
+       escape_ = e;
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(xml::StartTag const &tag) {
+       if (tag.tag_.empty())
+               return *this;
+       pending_tags_.push_back(makeTagPtr(tag));
+       if (tag.keepempty_)
+               clearTagDeque();
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(xml::ParTag const &tag) {
+       if (tag.tag_.empty())
+               return *this;
+       pending_tags_.push_back(makeTagPtr(tag));
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(xml::CompTag const &tag) {
+       if (tag.tag_.empty())
+               return *this;
+       clearTagDeque();
+       os_ << tag.writeTag();
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(xml::FontTag const &tag) {
+       if (tag.tag_.empty())
+               return *this;
+       pending_tags_.push_back(makeTagPtr(tag));
+       return *this;
+}
+
+
+XMLStream &XMLStream::operator<<(xml::CR const &) {
+       os_ << from_ascii("\n");
+       return *this;
+}
+
+
+bool XMLStream::isTagOpen(xml::StartTag const &stag) const {
+       auto sit = tag_stack_.begin();
+       auto sen = tag_stack_.cend();
+       for (; sit != sen; ++sit)
+               if (**sit == stag)
+                       return true;
+       return false;
+}
+
+
+bool XMLStream::isTagOpen(xml::EndTag const &etag) const {
+       auto sit = tag_stack_.begin();
+       auto sen = tag_stack_.cend();
+       for (; sit != sen; ++sit)
+               if (etag == **sit)
+                       return true;
+       return false;
+}
+
+
+bool XMLStream::isTagPending(xml::StartTag const &stag) const {
+       auto sit = pending_tags_.begin();
+       auto sen = pending_tags_.cend();
+       for (; sit != sen; ++sit)
+               if (**sit == stag)
+                       return true;
+       return false;
+}
+
+
+// this is complicated, because we want to make sure that
+// everything is properly nested. the code ought to make
+// sure of that, but we won't assert (yet) if we run into
+// a problem. we'll just output error messages and try our
+// best to make things work.
+XMLStream &XMLStream::operator<<(xml::EndTag const &etag) {
+       if (etag.tag_.empty())
+               return *this;
+
+       // if this tag is pending, we can simply discard it.
+       if (!pending_tags_.empty()) {
+               if (etag == *pending_tags_.back()) {
+                       // we have <tag></tag>, so we discard it and remove it
+                       // from the pending_tags_.
+                       pending_tags_.pop_back();
+                       return *this;
+               }
+
+               // there is a pending tag that isn't the one we are trying
+               // to close.
+
+               // is this tag itself pending?
+               // non-const iterators because we may call erase().
+               TagDeque::iterator dit = pending_tags_.begin();
+               TagDeque::iterator const den = pending_tags_.end();
+               for (; dit != den; ++dit) {
+                       if (etag == **dit) {
+                               // it was pending, so we just erase it
+                               writeError("Tried to close pending tag `" + to_utf8(etag.tag_)
+                                                  + "' when other tags were pending. Last pending tag is `"
+                                                  + to_utf8(pending_tags_.back()->writeTag())
+                                                  + "'. Tag discarded.");
+                               pending_tags_.erase(dit);
+                               return *this;
+                       }
+               }
+               // so etag isn't itself pending. is it even open?
+               if (!isTagOpen(etag)) {
+                       writeError("Tried to close `" + to_utf8(etag.tag_)
+                                          + "' when tag was not open. Tag discarded.");
+                       return *this;
+               }
+               // ok, so etag is open.
+               // our strategy will be as below: we will do what we need to
+               // do to close this tag.
+               string estr = "Closing tag `" + to_utf8(etag.tag_)
+                                         + "' when other tags are pending. Discarded pending tags:\n";
+               for (dit = pending_tags_.begin(); dit != den; ++dit)
+                       estr += to_utf8(xml::xmlize((*dit)->writeTag(), XMLStream::ESCAPE_ALL)) + "\n";
+               writeError(estr);
+               // clear the pending tags...
+               pending_tags_.clear();
+               // ...and then just fall through.
+       }
+
+       // make sure there are tags to be closed
+       if (tag_stack_.empty()) {
+               writeError("Tried to close `" + etag.tag_
+                                  + "' when no tags were open!");
+               return *this;
+       }
+
+       // is the tag we are closing the last one we opened?
+       if (etag == *tag_stack_.back()) {
+               // output it...
+               os_ << etag.writeEndTag();
+               // ...and forget about it
+               tag_stack_.pop_back();
+               return *this;
+       }
+
+       // we are trying to close a tag other than the one last opened.
+       // let's first see if this particular tag is still open somehow.
+       if (!isTagOpen(etag)) {
+               writeError("Tried to close `" + etag.tag_
+                                  + "' when tag was not open. Tag discarded.");
+               return *this;
+       }
+
+       // so the tag was opened, but other tags have been opened since
+       // and not yet closed.
+       // if it's a font tag, though...
+       if (etag.asFontTag()) {
+               // it won't be a problem if the other tags open since this one
+               // are also font tags.
+               TagDeque::const_reverse_iterator rit = tag_stack_.rbegin();
+               TagDeque::const_reverse_iterator ren = tag_stack_.rend();
+               for (; rit != ren; ++rit) {
+                       if (etag == **rit)
+                               break;
+                       if (!(*rit)->asFontTag()) {
+                               // we'll just leave it and, presumably, have to close it later.
+                               writeError("Unable to close font tag `" + etag.tag_
+                                                  + "' due to open non-font tag `" + (*rit)->tag_ + "'.");
+                               return *this;
+                       }
+               }
+
+               // so we have e.g.:
+               //    <em>this is <strong>bold
+               // and are being asked to closed em. we want:
+               //    <em>this is <strong>bold</strong></em><strong>
+               // first, we close the intervening tags...
+               TagPtr *curtag = &tag_stack_.back();
+               // ...remembering them in a stack.
+               TagDeque fontstack;
+               while (etag != **curtag) {
+                       os_ << (*curtag)->writeEndTag();
+                       fontstack.push_back(*curtag);
+                       tag_stack_.pop_back();
+                       curtag = &tag_stack_.back();
+               }
+               os_ << etag.writeEndTag();
+               tag_stack_.pop_back();
+
+               // ...and restore the other tags.
+               rit = fontstack.rbegin();
+               ren = fontstack.rend();
+               for (; rit != ren; ++rit)
+                       pending_tags_.push_back(*rit);
+               return *this;
+       }
+
+       // it wasn't a font tag.
+       // so other tags were opened before this one and not properly closed.
+       // so we'll close them, too. that may cause other issues later, but it
+       // at least guarantees proper nesting.
+       writeError("Closing tag `" + etag.tag_
+                          + "' when other tags are open, namely:");
+       TagPtr *curtag = &tag_stack_.back();
+       while (etag != **curtag) {
+               writeError((*curtag)->tag_);
+               if (**curtag != xml::parsep_tag)
+                       os_ << (*curtag)->writeEndTag();
+               tag_stack_.pop_back();
+               curtag = &tag_stack_.back();
+       }
+       // curtag is now the one we actually want.
+       os_ << (*curtag)->writeEndTag();
+       tag_stack_.pop_back();
+
+       return *this;
+}
+
+
+docstring xml::escapeString(docstring const & raw, XMLStream::EscapeSettings e)
+{
+       docstring bin;
+       bin.reserve(raw.size() * 2); // crude approximation is sufficient
+       for (size_t i = 0; i != raw.size(); ++i)
+               bin += xml::escapeChar(raw[i], e);
+
+       return bin;
+}
+
+
+docstring const xml::uniqueID(docstring const & label)
+{
+       // thread-safe
+       static atomic_uint seed(1000);
+       return label + convert<docstring>(++seed);
+}
+
+
+docstring xml::cleanID(docstring const &orig)
+{
+       // The standard xml:id only allows letters,
+       // digits, '-' and '.' in a name.
+       // This routine replaces illegal characters by '-' or '.'
+       // and adds a number for uniqueness if need be.
+       docstring const allowed = from_ascii(".-_");
+
+       // Use a cache of already mangled names: the alterations may merge several IDs as one. This ensures that the IDs
+       // are not mixed up in the document.
+       typedef map<docstring, docstring> MangledMap;
+       static QThreadStorage<MangledMap> tMangledNames;
+       static QThreadStorage<int> tMangleID;
+
+       MangledMap & mangledNames = tMangledNames.localData();
+
+       // If the name is already known, just return it.
+       MangledMap::const_iterator const known = mangledNames.find(orig);
+       if (known != mangledNames.end())
+               return known->second;
+
+       // Start creating the mangled name by iterating over the characters.
+       docstring content;
+       docstring::const_iterator it  = orig.begin();
+       docstring::const_iterator end = orig.end();
+
+       // Make sure it starts with a letter.
+       if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size())
+               content += "x";
+
+       // Do the mangling.
+       bool mangle = false; // Indicates whether the ID had to be changed, i.e. if ID no more ensured to be unique.
+       for (; it != end; ++it) {
+               char_type c = *it;
+               if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.'
+                     || allowed.find(c) < allowed.size())
+                       content += c;
+               else if (c == '_' || c == ' ') {
+                       mangle = true;
+                       content += "-";
+               }
+               else if (c == ':' || c == ',' || c == ';' || c == '!') {
+                       mangle = true;
+                       content += ".";
+               }
+               else {
+                       mangle = true;
+                       content += "-";
+               }
+       }
+
+       if (mangle) {
+               int & mangleID = tMangleID.localData();
+               content += "-" + convert<docstring>(mangleID++);
+       } else if (isDigitASCII(content[content.size() - 1]))
+               content += ".";
+
+       mangledNames[orig] = content;
+
+       return content;
+}
+
+
+void xml::openTag(odocstream & os, string const & name, string const & attribute)
+{
+    // FIXME UNICODE
+    // This should be fixed in layout files later.
+    string param = subst(attribute, "<", "\"");
+    param = subst(param, ">", "\"");
+
+    // Note: we ignore the name if it 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
+    // 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") {
+        os << '<' << from_ascii(name);
+        if (!param.empty())
+            os << ' ' << from_ascii(param);
+        os << '>';
+    }
+}
+
+
+void xml::closeTag(odocstream & os, string const & name)
+{
+    if (!name.empty() && name != "!-- --" && name != "dummy")
+        os << "</" << from_ascii(name) << '>';
+}
+
+
+void xml::openTag(Buffer const & buf, odocstream & os,
+                   OutputParams const & runparams, Paragraph const & par)
+{
+    Layout const & style = par.layout();
+    string const & name = style.latexname();
+    string param = style.latexparam();
+    Counters & counters = buf.params().documentClass().counters();
+
+    string id = par.getID(buf, runparams);
+
+    string attribute;
+    if (!id.empty()) {
+        if (param.find('#') != string::npos) {
+            string::size_type pos = param.find("id=<");
+            string::size_type end = param.find(">");
+            if( pos != string::npos && end != string::npos)
+                param.erase(pos, end-pos + 1);
+        }
+        attribute = id + ' ' + param;
+    } else {
+        if (param.find('#') != string::npos) {
+            // FIXME UNICODE
+            if (!style.counter.empty())
+                // This uses InternalUpdate at the moment becuase xml output
+                // does not do anything with tracked counters, and it would need
+                // to track layouts if it did want to use them.
+                counters.step(style.counter, InternalUpdate);
+            else
+                counters.step(from_ascii(name), InternalUpdate);
+            int i = counters.value(from_ascii(name));
+            attribute = subst(param, "#", convert<string>(i));
+        } else {
+            attribute = param;
+        }
+    }
+    openTag(os, name, attribute);
+}
+
+
+void xml::closeTag(odocstream & os, Paragraph const & par)
+{
+    Layout const & style = par.layout();
+    closeTag(os, style.latexname());
+}
+
+
+} // namespace lyx
diff --git a/src/xml.h b/src/xml.h
new file mode 100644 (file)
index 0000000..45fb52f
--- /dev/null
+++ b/src/xml.h
@@ -0,0 +1,355 @@
+// -*- C++ -*-
+/**
+ * \file xml.h
+ * This file is part of LyX, the document processor.
+ * License details can be found in the file COPYING.
+ *
+ * \author José Matos
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef XML_H
+#define XML_H
+
+#include "support/docstring.h"
+
+#include <deque>
+#include <memory>
+
+namespace lyx {
+
+class Buffer;
+class Paragraph;
+class OutputParams;
+
+// Inspiration for the *Tag structs and for XMLStream
+// came from MathStream and its cousins.
+
+namespace xml {
+struct StartTag;
+struct EndTag;
+struct CompTag;
+struct ParTag;
+struct FontTag;
+struct CR;
+}
+
+class XMLStream {
+public:
+    ///
+    explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL) {}
+    ///
+    odocstream & os() { return os_; }
+    ///
+    // int & tab() { return tab_; }
+    /// closes any font tags that are eligible to be closed,
+    /// i.e., last on the tag_stack_.
+    /// \return false if there are open font tags we could not close.
+    /// because they are "blocked" by open non-font tags on the stack.
+    bool closeFontTags();
+    /// sets a mark so we know what tags to close at the end.
+    /// normally called at the start of a paragraph.
+    void startDivision(bool keep_empty);
+    /// clears the mark set by previous method.
+    /// there should not be any other tags open before it on the stack,
+    /// but if there are, we will close them.
+    void endDivision();
+    ///
+    XMLStream & operator<<(docstring const &);
+    ///
+    XMLStream & operator<<(const char *);
+    ///
+    XMLStream & operator<<(char_type);
+    ///
+    XMLStream & operator<<(int);
+    ///
+    XMLStream & operator<<(char);
+    ///
+    XMLStream & operator<<(xml::StartTag const &);
+    ///
+    XMLStream & operator<<(xml::EndTag const &);
+    ///
+    XMLStream & operator<<(xml::CompTag const &);
+    ///
+    XMLStream & operator<<(xml::ParTag const &);
+    ///
+    XMLStream & operator<<(xml::FontTag const &);
+    ///
+    XMLStream & operator<<(xml::CR const &);
+    ///
+    enum EscapeSettings {
+        ESCAPE_NONE,
+        ESCAPE_AND, // meaning &
+        ESCAPE_ALL  // meaning <, >, &, at present
+    };
+    /// Sets what we are going to escape on the NEXT write.
+    /// Everything is reset for the next time.
+    XMLStream & operator<<(EscapeSettings);
+    /// This routine is for debugging the tag stack, etc. Code
+    /// for it is disabled by default, however, so you will need
+    /// to enable it if you want to use it.
+    void dumpTagStack(std::string const & msg);
+private:
+    ///
+    void clearTagDeque();
+    ///
+    bool isTagOpen(xml::StartTag const &) const;
+    ///
+    bool isTagOpen(xml::EndTag const &) const;
+    ///
+    bool isTagPending(xml::StartTag const &) const;
+    ///
+    void writeError(std::string const &) const;
+    ///
+    void writeError(docstring const &) const;
+    ///
+    odocstream & os_;
+    ///
+    EscapeSettings escape_;
+    // What we would really like to do here is simply use a
+    // deque<StartTag>. But we want to store both StartTags and
+    // sub-classes thereof on this stack, which means we run into the
+    // so-called polymorphic class problem with the STL. We therefore have
+    // to use a deque<StartTag *>, which leads to the question who will
+    // own these pointers and how they will be deleted, so we use shared
+    // pointers.
+    ///
+    typedef std::shared_ptr<xml::StartTag> TagPtr;
+    typedef std::deque<TagPtr> TagDeque;
+    ///
+    template <typename T>
+    TagPtr makeTagPtr(T const & tag) { return std::make_shared<T>(tag); }
+    ///
+    TagDeque pending_tags_;
+    ///
+    TagDeque tag_stack_;
+};
+
+namespace xml {
+
+/// Escape the given character, if necessary, to an entity.
+docstring escapeChar(char_type c, XMLStream::EscapeSettings e);
+
+/// Escape the given character, if necessary, to an entity.
+docstring escapeChar(char c, XMLStream::EscapeSettings e);
+
+/// Escape a word instead of a single character
+docstring escapeString(docstring const & raw, XMLStream::EscapeSettings e=XMLStream::ESCAPE_ALL);
+
+/// Converts a string to a form safe for links, etc.
+docstring xmlize(docstring const &str, XMLStream::EscapeSettings e);
+
+/// cleans \param str for use as an attribute by replacing all non-altnum by "_"
+docstring cleanAttr(docstring const & str);
+
+/// \p c must be ASCII
+docstring escapeChar(char c, XMLStream::EscapeSettings e);
+
+/// replaces illegal characters from ID attributes
+docstring cleanID(docstring const &orig);
+
+/// returns a unique numeric ID
+docstring const uniqueID(docstring const & label);
+
+struct FontTag;
+struct EndFontTag;
+
+/// Attributes will be escaped automatically and so should NOT
+/// be escaped before being passed to the constructor.
+struct StartTag
+{
+    ///
+    explicit StartTag(std::string const & tag) : tag_(from_ascii(tag)), keepempty_(false) {}
+    ///
+    explicit StartTag(docstring const & tag) : tag_(tag), keepempty_(false) {}
+    ///
+    explicit StartTag(docstring const & tag, docstring const & attr,
+                      bool keepempty = false)
+            : tag_(tag), attr_(attr), keepempty_(keepempty) {}
+    ///
+    explicit StartTag(std::string const & tag, std::string const & attr,
+                      bool keepempty = false)
+            : tag_(from_ascii(tag)), attr_(from_ascii(attr)), keepempty_(keepempty) {}
+    ///
+    explicit StartTag(std::string const & tag, docstring const & attr,
+                      bool keepempty = false)
+            : tag_(from_ascii(tag)), attr_(attr), keepempty_(keepempty) {}
+    ///
+    virtual ~StartTag() {}
+    /// <tag_ attr_>
+    virtual docstring writeTag() const;
+    /// </tag_>
+    virtual docstring writeEndTag() const;
+    ///
+    virtual FontTag const * asFontTag() const { return 0; }
+    ///
+    virtual bool operator==(StartTag const & rhs) const
+    { return tag_ == rhs.tag_; }
+    ///
+    virtual bool operator!=(StartTag const & rhs) const
+    { return !(*this == rhs); }
+    ///
+    virtual bool operator==(FontTag const & rhs) const;
+    ///
+    docstring tag_;
+    ///
+    docstring attr_;
+    /// whether to keep things like "<tag></tag>" or discard them
+    /// you would want this for td, e.g, but maybe not for a div
+    bool keepempty_;
+};
+
+
+///
+struct EndTag
+{
+    ///
+    explicit EndTag(std::string tag) : tag_(from_ascii(tag)) {}
+    ///
+    explicit EndTag(docstring tag) : tag_(tag) {}
+    ///
+    virtual ~EndTag() {}
+    /// </tag_>
+    virtual docstring writeEndTag() const;
+    ///
+    bool operator==(StartTag const & rhs) const
+    { return tag_ == rhs.tag_; }
+    ///
+    bool operator!=(StartTag const & rhs) const
+    { return !(*this == rhs); }
+    ///
+    virtual EndFontTag const * asFontTag() const { return 0; }
+    ///
+    docstring tag_;
+};
+
+
+/// Tags like <img />
+/// Attributes will be escaped automatically and so should NOT
+/// be escaped before being passed to the constructor.
+struct CompTag
+{
+    ///
+    explicit CompTag(std::string const & tag)
+            : tag_(tag) {}
+    ///
+    explicit CompTag(std::string const & tag, std::string const & attr)
+            : tag_(tag), attr_(attr) {}
+    /// <tag_ attr_ />
+    docstring writeTag() const;
+    ///
+    std::string tag_;
+    ///
+    std::string attr_;
+};
+
+
+/// A special case of StartTag, used exclusively for tags that wrap paragraphs.
+/// parid is only used for HTML output; XML is supposed to use attr for this. TODO: REMOVE PARID.
+struct ParTag : public StartTag
+{
+    ///
+    explicit ParTag(std::string const & tag, const std::string & attr): StartTag(tag, from_utf8(attr)) {}
+    ///
+    explicit ParTag(std::string const & tag, const std::string & attr, const std::string & parid):
+            StartTag(tag, from_utf8(attr + (parid.empty() ? (" id='" + parid + "'") : ""))) {}
+    ///
+    ~ParTag() {}
+};
+
+
+///
+enum FontTypes {
+    // ranges
+    FT_EMPH,
+    FT_NOUN,
+    FT_UBAR,
+    FT_DBAR,
+    FT_WAVE,
+    FT_SOUT,
+    FT_XOUT,
+    // bold
+    FT_BOLD,
+    // shapes
+    FT_UPRIGHT,
+    FT_ITALIC,
+    FT_SLANTED,
+    FT_SMALLCAPS,
+    // families
+    FT_ROMAN,
+    FT_SANS,
+    FT_TYPE,
+    // sizes
+    FT_SIZE_TINY,
+    FT_SIZE_SCRIPT,
+    FT_SIZE_FOOTNOTE,
+    FT_SIZE_SMALL,
+    FT_SIZE_NORMAL,
+    FT_SIZE_LARGE,
+    FT_SIZE_LARGER,
+    FT_SIZE_LARGEST,
+    FT_SIZE_HUGE,
+    FT_SIZE_HUGER,
+    FT_SIZE_INCREASE,
+    FT_SIZE_DECREASE
+
+    // When updating this list, also update fontToTag in both output_docbook.cpp and output_xhtml.cpp,
+    // fontToRole in output_docbook.cpp, and fontToAttribute in output_xhtml.cpp.
+};
+
+
+///
+struct FontTag : public StartTag
+{
+    ///
+    FontTag(docstring const & tag, FontTypes type): StartTag(tag), font_type_(type) {}
+    ///
+    FontTag(docstring const & tag, docstring const & attr, FontTypes type): StartTag(tag, attr), font_type_(type) {}
+    ///
+    FontTag const * asFontTag() const override { return this; }
+    ///
+    bool operator==(StartTag const &) const override;
+    ///
+    FontTypes font_type_;
+};
+
+
+///
+struct EndFontTag : public EndTag
+{
+    ///
+    EndFontTag(docstring const & tag, FontTypes type): EndTag(tag), font_type_(type) {}
+    ///
+    EndFontTag const * asFontTag() const override { return this; }
+    ///
+    FontTypes font_type_;
+};
+
+
+// trivial struct for output of newlines
+struct CR{};
+
+// an illegal tag for internal use
+xml::StartTag const parsep_tag("&LyX_parsep_tag&");
+
+/// Open tag
+void openTag(odocstream & os, std::string const & name,
+             std::string const & attribute = std::string());
+
+/// Open tag
+void openTag(Buffer const & buf, odocstream & os,
+             OutputParams const & runparams, Paragraph const & par);
+
+/// Close tag
+void closeTag(odocstream & os, std::string const & name);
+
+/// Close tag
+void closeTag(odocstream & os, Paragraph const & par);
+
+} // namespace xml
+
+} // namespace lyx
+
+#endif // XML_H