From 3e654186d22b2a4f3b7b8429d6fcb3952a04fe4d Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 19 Jan 2010 22:08:04 +0000 Subject: [PATCH] Move the StartTag, EndTag, and CompTag classes into the html namespace. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33099 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Paragraph.cpp | 10 ++++---- src/insets/InsetBibitem.cpp | 6 ++--- src/insets/InsetBibtex.cpp | 22 ++++++++--------- src/insets/InsetBox.cpp | 4 +-- src/insets/InsetCaption.cpp | 4 +-- src/insets/InsetFloat.cpp | 4 +-- src/insets/InsetFloatList.cpp | 16 ++++++------ src/insets/InsetGraphics.cpp | 4 +-- src/insets/InsetHyperlink.cpp | 4 +-- src/insets/InsetInclude.cpp | 4 +-- src/insets/InsetIndex.cpp | 46 +++++++++++++++++------------------ src/insets/InsetLabel.cpp | 2 +- src/insets/InsetLine.cpp | 2 +- src/insets/InsetListings.cpp | 16 ++++++------ src/insets/InsetNewline.cpp | 2 +- src/insets/InsetNewpage.cpp | 2 +- src/insets/InsetRef.cpp | 4 +-- src/insets/InsetTOC.cpp | 24 +++++++++--------- src/insets/InsetTabular.cpp | 16 ++++++------ src/insets/InsetText.cpp | 12 ++++----- src/insets/InsetVSpace.cpp | 2 +- src/insets/InsetWrap.cpp | 4 +-- src/mathed/InsetMathHull.cpp | 6 ++--- src/output_xhtml.cpp | 40 +++++++++++++++--------------- src/output_xhtml.h | 12 +++++---- 25 files changed, 136 insertions(+), 132 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index a096caa3c2..ed53d8088c 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -2414,7 +2414,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, if (!runparams.for_toc && runparams.html_make_pars) { // generate a magic label for this paragraph string const attr = "id='" + magicLabel() + "'"; - xs << CompTag("a", attr); + xs << html::CompTag("a", attr); } FontInfo font_old = @@ -2427,20 +2427,20 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, // emphasis if (font_old.emph() != font.fontInfo().emph()) { if (font.fontInfo().emph() == FONT_ON) { - xs << StartTag("em"); + xs << html::StartTag("em"); emph_flag = true; } else if (emph_flag && i != initial) { - xs << EndTag("em"); + xs << html::EndTag("em"); emph_flag = false; } } // bold if (font_old.series() != font.fontInfo().series()) { if (font.fontInfo().series() == BOLD_SERIES) { - xs << StartTag("strong"); + xs << html::StartTag("strong"); bold_flag = true; } else if (bold_flag && i != initial) { - xs << EndTag("strong"); + xs << html::EndTag("strong"); bold_flag = false; } } diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 5eb0d448b4..123c639a62 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -278,10 +278,10 @@ 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='" + to_utf8(getParam("key")) + "'"; - xs << CompTag("a", attrs); - xs << StartTag("span", "class='bibitemlabel'"); + xs << html::CompTag("a", attrs); + xs << html::StartTag("span", "class='bibitemlabel'"); xs << bibLabel(); - xs << EndTag("span"); + xs << html::EndTag("span"); return docstring(); } diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 8d7b33f792..073d2f113b 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -920,10 +920,10 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const bool const numbers = (engine == ENGINE_BASIC || engine == ENGINE_NATBIB_NUMERICAL); - xs << StartTag("h2", "class='bibtex'") + xs << html::StartTag("h2", "class='bibtex'") << _("References") - << EndTag("h2") - << StartTag("div", "class='bibtex'"); + << html::EndTag("h2") + << html::StartTag("div", "class='bibtex'"); // Now we loop over the entries vector::const_iterator vit = cites.begin(); @@ -933,11 +933,11 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const if (biit == bibinfo.end()) continue; BibTeXInfo const & entry = biit->second; - xs << StartTag("div", "class='bibtexentry'"); + xs << html::StartTag("div", "class='bibtexentry'"); // FIXME XHTML // The same name/id problem we have elsewhere. string const attr = "id='" + to_utf8(entry.key()) + "'"; - xs << CompTag("a", attr); + xs << html::CompTag("a", attr); docstring citekey; if (numbers) citekey = entry.citeNumber(); @@ -954,19 +954,19 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const if (citekey.empty()) citekey = entry.key(); } - xs << StartTag("span", "class='bibtexlabel'") + xs << html::StartTag("span", "class='bibtexlabel'") << citekey - << EndTag("span"); + << html::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 << StartTag("span", "class='bibtexinfo'") + xs << html::StartTag("span", "class='bibtexinfo'") << bibinfo.getInfo(entry.key()) - << EndTag("span") - << EndTag("div"); + << html::EndTag("span") + << html::EndTag("div"); xs.cr(); } - xs << EndTag("div"); + xs << html::EndTag("div"); return docstring(); } diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 1ad78ea2bf..77e6a5b396 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -492,10 +492,10 @@ docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) cons if (!style.empty()) attrs += " style='" + style + "'"; - xs << StartTag("div", attrs); + xs << html::StartTag("div", attrs); XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag; docstring defer = InsetText::insetAsXHTML(xs, runparams, opts); - xs << EndTag("div"); + xs << html::EndTag("div"); xs << defer; return docstring(); } diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 7eb0889dd7..acee0126bc 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -268,9 +268,9 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const if (!type_.empty()) attr += " float-caption-" + type_; attr += "'"; - xs << StartTag("div", attr); + xs << html::StartTag("div", attr); docstring def = getCaptionAsHTML(xs, rp); - xs << EndTag("div"); + xs << html::EndTag("div"); return def; } diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index b6a67b0675..b3c8a50861 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -291,11 +291,11 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const odocstringstream ods; XHTMLStream newxs(ods); - newxs << StartTag(htmltype, attr); + newxs << html::StartTag(htmltype, attr); InsetText::XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag; docstring deferred = InsetText::insetAsXHTML(newxs, rp, opts); - newxs << EndTag(htmltype); + newxs << html::EndTag(htmltype); if (rp.inFloat == OutputParams::NONFLOAT) // In this case, this float needs to be deferred, but we'll put it diff --git a/src/insets/InsetFloatList.cpp b/src/insets/InsetFloatList.cpp index 23796fcf7d..5ff9dbf8c0 100644 --- a/src/insets/InsetFloatList.cpp +++ b/src/insets/InsetFloatList.cpp @@ -214,10 +214,10 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const &) const { odocstringstream ods; XHTMLStream xs(ods); - xs << StartTag("div", "class='toc'"); - xs << StartTag("div", tocattr) + xs << html::StartTag("div", "class='toc'"); + xs << html::StartTag("div", tocattr) << toclabel - << EndTag("div"); + << html::EndTag("div"); Toc::const_iterator it = toc.begin(); Toc::const_iterator const en = toc.end(); @@ -225,17 +225,17 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const &) const { Paragraph const & par = it->dit().innerParagraph(); string const attr = "class='lyxtoc-" + toctype + "'"; Font const dummy; - xs << StartTag("div", attr); + xs << html::StartTag("div", attr); string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'"; xs << it->str() << " " - << StartTag("a", parattr) + << html::StartTag("a", parattr) // FIXME XHTML // There ought to be a simple way to customize this. << XHTMLStream::NextRaw() << "⇘" - << EndTag("a"); - xs << EndTag("div"); + << html::EndTag("a"); + xs << html::EndTag("div"); } - xs << EndTag("div"); + xs << html::EndTag("div"); return ods.str(); } diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 2e63412103..ec085707b4 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -951,7 +951,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 << CompTag("img", attr); + xs << html::CompTag("img", attr); return docstring(); } @@ -961,7 +961,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const // Speaking of which: Do the cropping, rotating, etc. string const attr = "src='" + output_file + "' alt='image: " + output_file + "'"; - xs << CompTag("img", attr); + xs << html::CompTag("img", attr); return docstring(); } diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp index 79908011fa..88513443a7 100644 --- a/src/insets/InsetHyperlink.cpp +++ b/src/insets/InsetHyperlink.cpp @@ -186,9 +186,9 @@ docstring InsetHyperlink::xhtml(XHTMLStream & xs, OutputParams const &) const { docstring const & target = getParam("target"); docstring const & name = getParam("name"); - xs << StartTag("a", to_utf8("href=\"" + target + "\"")); + xs << html::StartTag("a", to_utf8("href=\"" + target + "\"")); xs << (name.empty() ? target : name); - xs << EndTag("a"); + xs << html::EndTag("a"); return docstring(); } diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 25edd2e61e..e65cdd637f 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -668,11 +668,11 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const &rp) const bool const listing = isListings(params()); if (listing || isVerbatim(params())) { if (listing) - xs << StartTag("pre"); + xs << html::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 << EndTag("pre"); + xs << html::EndTag("pre"); return docstring(); } diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index 8f4b3d99e4..3fe758265f 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -182,7 +182,7 @@ docstring InsetIndex::xhtml(XHTMLStream & xs, OutputParams const &) const // our own interior paragraph, which doesn't get printed std::string const magic = paragraphs().front().magicLabel(); std::string const attr = "id='" + magic + "'"; - xs << CompTag("a", attr); + xs << html::CompTag("a", attr); return docstring(); } @@ -701,11 +701,11 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const odocstringstream ods; XHTMLStream xs(ods); - xs << StartTag("div", "class='index'"); - xs << StartTag(lay.htmltag(), lay.htmlattr()) + xs << html::StartTag("div", "class='index'"); + xs << html::StartTag(lay.htmltag(), lay.htmlattr()) << _("Index") - << EndTag(lay.htmltag()); - xs << StartTag("ul", "class='main'"); + << html::EndTag(lay.htmltag()); + xs << html::StartTag("ul", "class='main'"); Font const dummy; vector::const_iterator eit = entries.begin(); @@ -725,12 +725,12 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const // close last entry or entries, depending. if (level == 3) { // close this sub-sub-entry - xs << EndTag("li"); + xs << html::EndTag("li"); xs.cr(); // is this another sub-sub-entry within the same sub-entry? if (!eit->same_sub(last)) { // close this level - xs << EndTag("ul"); + xs << html::EndTag("ul"); xs.cr(); level = 2; } @@ -742,12 +742,12 @@ 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 << EndTag("li"); + xs << html::EndTag("li"); xs.cr(); // is this another sub-entry with the same main entry? if (!eit->same_main(last)) { // close this level - xs << EndTag("ul"); + xs << html::EndTag("ul"); xs.cr(); level = 1; } @@ -757,7 +757,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const // close the entry. if (level == 1 && !eit->same_main(last)) { // close entry - xs << EndTag("li"); + xs << html::EndTag("li"); xs.cr(); } } @@ -786,7 +786,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const if (level == 3) { // another subsubentry - xs << StartTag("li", "class='subsubentry'") + xs << html::StartTag("li", "class='subsubentry'") << XHTMLStream::NextRaw() << subsub; } else if (level == 2) { // there are two ways we can be here: @@ -800,13 +800,13 @@ 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 << StartTag("li", "class='subentry'") + xs << html::StartTag("li", "class='subentry'") << XHTMLStream::NextRaw() << sub; if (!subsub.empty()) { // it's actually a subsubentry, so we need to start that list xs.cr(); - xs << StartTag("ul", "class='subsubentry'") - << StartTag("li", "class='subsubentry'") + xs << html::StartTag("ul", "class='subsubentry'") + << html::StartTag("li", "class='subsubentry'") << XHTMLStream::NextRaw() << subsub; level = 3; } @@ -822,19 +822,19 @@ 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 << StartTag("li", "class='main'") << main; + xs << html::StartTag("li", "class='main'") << main; if (!sub.empty()) { // there's a sub-entry, too xs.cr(); - xs << StartTag("ul", "class='subentry'") - << StartTag("li", "class='subentry'") + xs << html::StartTag("ul", "class='subentry'") + << html::StartTag("li", "class='subentry'") << XHTMLStream::NextRaw() << sub; level = 2; if (!subsub.empty()) { // and a sub-sub-entry xs.cr(); - xs << StartTag("ul", "class='subsubentry'") - << StartTag("li", "class='subsubentry'") + xs << html::StartTag("ul", "class='subsubentry'") + << html::StartTag("li", "class='subsubentry'") << XHTMLStream::NextRaw() << subsub; level = 3; } @@ -844,17 +844,17 @@ 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 << " " << StartTag("a", parattr) - << ++entry_number << EndTag("a"); + xs << " " << html::StartTag("a", parattr) + << ++entry_number << html::EndTag("a"); last = *eit; } // now we have to close all the open levels while (level > 0) { - xs << EndTag("li") << EndTag("ul"); + xs << html::EndTag("li") << html::EndTag("ul"); xs.cr(); --level; } - xs << EndTag("div"); + xs << html::EndTag("div"); xs.cr(); return ods.str(); } diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index b4199a2bd6..1177d2db5b 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -227,7 +227,7 @@ docstring InsetLabel::xhtml(XHTMLStream & xs, OutputParams const &) const // problem with some browsers, though, I'm sure. (Guess which!) So we will // have to figure out what to do about this later. string const attr = "id=\"" + html::cleanAttr(to_utf8(getParam("name"))) + "\""; - xs << CompTag("a", attr); + xs << html::CompTag("a", attr); return docstring(); } diff --git a/src/insets/InsetLine.cpp b/src/insets/InsetLine.cpp index b2fc3b6ab0..da589953ec 100644 --- a/src/insets/InsetLine.cpp +++ b/src/insets/InsetLine.cpp @@ -88,7 +88,7 @@ int InsetLine::docbook(odocstream & os, OutputParams const &) const docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const { - xs << CompTag("hr"); + xs << html::CompTag("hr"); xs.cr(); return docstring(); } diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index ba7de456e1..78a97b875b 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -275,27 +275,27 @@ docstring InsetListings::xhtml(XHTMLStream & os, OutputParams const & rp) const bool const isInline = params().isInline(); if (isInline) - out << CompTag("br"); + out << html::CompTag("br"); else { - out << StartTag("div", "class='float float-listings'"); + out << html::StartTag("div", "class='float float-listings'"); docstring caption = getCaptionHTML(rp); if (!caption.empty()) - out << StartTag("div", "class='float-caption'") - << caption << EndTag("div"); + out << html::StartTag("div", "class='float-caption'") + << caption << html::EndTag("div"); } - out << StartTag("pre"); + out << html::StartTag("pre"); OutputParams newrp = rp; newrp.html_disable_captions = true; docstring def = InsetText::insetAsXHTML(out, newrp, InsetText::JustText); - out << EndTag("pre"); + out << html::EndTag("pre"); if (isInline) { - out << CompTag("br"); + out << html::CompTag("br"); // escaping will already have been done os << XHTMLStream::NextRaw() << ods.str(); } else { - out << EndTag("div"); + out << html::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; diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index 4d0f7ef9da..c74d16f89a 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -176,7 +176,7 @@ int InsetNewline::docbook(odocstream & os, OutputParams const &) const docstring InsetNewline::xhtml(XHTMLStream & xs, OutputParams const &) const { - xs << CompTag("br"); + xs << html::CompTag("br"); xs.cr(); return docstring(); } diff --git a/src/insets/InsetNewpage.cpp b/src/insets/InsetNewpage.cpp index 35c5b0a5ac..52e20d69e9 100644 --- a/src/insets/InsetNewpage.cpp +++ b/src/insets/InsetNewpage.cpp @@ -250,7 +250,7 @@ int InsetNewpage::docbook(odocstream & os, OutputParams const &) const docstring InsetNewpage::xhtml(XHTMLStream & xs, OutputParams const &) const { - xs << CompTag("br"); + xs << html::CompTag("br"); return docstring(); } diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 7e0eb6db33..1adf008aea 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -123,9 +123,9 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const // some sort of counter with the label, and we don't have that yet. docstring const ref = html::cleanAttr(getParam("reference")); string const attr = "href=\"#" + to_utf8(ref) + "\""; - xs << StartTag("a", attr); + xs << html::StartTag("a", attr); xs << ref; - xs << EndTag("a"); + xs << html::EndTag("a"); return docstring(); } diff --git a/src/insets/InsetTOC.cpp b/src/insets/InsetTOC.cpp index 50d713a119..00f1786cba 100644 --- a/src/insets/InsetTOC.cpp +++ b/src/insets/InsetTOC.cpp @@ -89,10 +89,10 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const if (toc.empty()) return docstring(); - xs << StartTag("div", "class='toc'"); - xs << StartTag("div", tocattr) + xs << html::StartTag("div", "class='toc'"); + xs << html::StartTag("div", tocattr) << _("Table of Contents") - << EndTag("div"); + << html::EndTag("div"); Toc::const_iterator it = toc.begin(); Toc::const_iterator const en = toc.end(); int lastdepth = 0; @@ -109,7 +109,7 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const for (int i = lastdepth + 1; i <= depth; ++i) { stringstream attr; attr << "class='lyxtoc-" << i << "'"; - xs << StartTag("div", attr.str()); + xs << html::StartTag("div", attr.str()); } lastdepth = depth; } @@ -117,33 +117,33 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const // 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 << EndTag("div"); + xs << html::EndTag("div"); // now open our tag stringstream attr; attr << "class='lyxtoc-" << depth << "'"; - xs << StartTag("div", attr.str()); + xs << html::StartTag("div", attr.str()); lastdepth = depth; } else { // no change of level, so close and open - xs << EndTag("div"); + xs << html::EndTag("div"); stringstream attr; attr << "class='lyxtoc-" << depth << "'"; - xs << StartTag("div", attr.str()); + xs << html::StartTag("div", attr.str()); } string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'"; OutputParams ours = op; ours.for_toc = true; par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy); xs << " "; - xs << StartTag("a", parattr); + xs << html::StartTag("a", parattr); // FIXME XHTML // There ought to be a simple way to customize this. xs << XHTMLStream::NextRaw() << "⇘"; - xs << EndTag("a"); + xs << html::EndTag("a"); } for (int i = lastdepth; i > 0; --i) - xs << EndTag("div"); - xs << EndTag("div"); + xs << html::EndTag("div"); + xs << html::EndTag("div"); return ods.str(); } diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 31a7cc1936..390b08eedc 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2639,7 +2639,7 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row, docstring ret; idx_type cell = getFirstCellInRow(row); - xs << StartTag("tr"); + xs << html::StartTag("tr"); for (col_type j = 0; j < column_info.size(); ++j) { if (isPartOfMultiColumn(row, j)) continue; @@ -2674,12 +2674,12 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row, if (isMultiColumn(cell)) attr << " colspan='" << columnSpan(cell) << "'"; - xs << StartTag("td", attr.str()); + xs << html::StartTag("td", attr.str()); ret += cellInset(cell)->xhtml(xs, runparams); - xs << EndTag("td"); + xs << html::EndTag("td"); ++cell; } - xs << EndTag("tr"); + xs << html::EndTag("tr"); return ret; } @@ -2690,13 +2690,13 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const // It's unclear to me if we need to mess with the long table stuff. // We can borrow that too from docbook, if so. - xs << StartTag("tbody"); + xs << html::StartTag("tbody"); for (row_type i = 0; i < row_info.size(); ++i) { if (isValidRow(i)) { ret += xhtmlRow(xs, i, runparams); } } - xs << EndTag("tbody"); + xs << html::EndTag("tbody"); return ret; } @@ -4305,9 +4305,9 @@ docstring InsetTabular::xhtml(XHTMLStream & xs, OutputParams const & rp) const // FIXME XHTML // It'd be better to be able to get this from an InsetLayout, but at present // InsetLayouts do not seem really to work for things that aren't InsetTexts. - xs << StartTag("table"); + xs << html::StartTag("table"); docstring ret = tabular.xhtml(xs, rp); - xs << EndTag("table"); + xs << html::EndTag("table"); return ret; } diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index cb6734aa67..5f1be86e0a 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -500,7 +500,7 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & runpara InsetLayout const & il = getLayout(); if (opts & WriteOuterTag) - xs << StartTag(il.htmltag(), il.htmlattr()); + xs << html::StartTag(il.htmltag(), il.htmlattr()); if ((opts & WriteLabel) && !il.counter().empty()) { BufferParams const & bp = buffer().masterBuffer()->params(); Counters & cntrs = bp.documentClass().counters(); @@ -511,23 +511,23 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & runpara cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code()); // FIXME is this check necessary? if (!lbl.empty()) { - xs << StartTag(il.htmllabeltag(), il.htmllabelattr()); + xs << html::StartTag(il.htmllabeltag(), il.htmllabelattr()); xs << lbl; - xs << EndTag(il.htmllabeltag()); + xs << html::EndTag(il.htmllabeltag()); } } } if (opts & WriteInnerTag) - xs << StartTag(il.htmlinnertag(), il.htmlinnerattr()); + xs << html::StartTag(il.htmlinnertag(), il.htmlinnerattr()); OutputParams ours = runparams; if (!il.isMultiPar() || opts == JustText) ours.html_make_pars = false; xhtmlParagraphs(text_, buffer(), xs, ours); if (opts & WriteInnerTag) - xs << EndTag(il.htmlinnertag()); + xs << html::EndTag(il.htmlinnertag()); if (opts & WriteOuterTag) - xs << EndTag(il.htmltag()); + xs << html::EndTag(il.htmltag()); return docstring(); } diff --git a/src/insets/InsetVSpace.cpp b/src/insets/InsetVSpace.cpp index b499b0bcc9..3d271a672d 100644 --- a/src/insets/InsetVSpace.cpp +++ b/src/insets/InsetVSpace.cpp @@ -241,7 +241,7 @@ docstring InsetVSpace::xhtml(XHTMLStream &, OutputParams const &) const XHTMLStream xds(ods); string const len = space_.asHTMLLength(); string const attr = "style='height:" + (len.empty() ? "1em" : len) + "'"; - xds << StartTag("div", attr, true) << EndTag("div"); + xds << html::StartTag("div", attr, true) << html::EndTag("div"); return ods.str(); } diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index e92fdb76cd..6ebabf1ca5 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -220,11 +220,11 @@ docstring InsetWrap::xhtml(XHTMLStream & xs, OutputParams const & rp) const string const len = params_.width.asHTMLString(); string const width = len.empty() ? "50%" : len; string const attr = "class='wrap' style='width: " + len + ";'"; - xs << StartTag("div", attr); + xs << html::StartTag("div", attr); docstring const deferred = InsetText::insetAsXHTML(xs, rp, InsetText::WriteInnerTag); if (!len.empty()) - xs << EndTag("div"); + xs << html::EndTag("div"); return deferred; } diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 57137db2f2..cf21d152f5 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -1777,13 +1777,13 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const &) const { if (getType() == hullSimple) - xs << StartTag("math", "xmlns=\"http://www.w3.org/1998/Math/MathML\"", true); + xs << html::StartTag("math", "xmlns=\"http://www.w3.org/1998/Math/MathML\"", true); else - xs << StartTag("math", + xs << html::StartTag("math", "display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\"", true); MathStream ms(xs.os()); InsetMathGrid::mathmlize(ms); - xs << EndTag("math"); + xs << html::EndTag("math"); return docstring(); } diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 60df83400d..57711fe778 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -140,7 +140,6 @@ bool isFontTag(string const & s) { return s == "em" || s == "strong"; // others? } -} // namespace html docstring StartTag::asTag() const @@ -176,6 +175,9 @@ docstring CompTag::asTag() const return from_utf8(output); } +} // namespace html + + //////////////////////////////////////////////////////////////// /// @@ -207,7 +209,7 @@ bool XHTMLStream::closeFontTags() if (tag_stack_.empty()) return true; // first, we close any open font tags we can close - StartTag curtag = tag_stack_.back(); + html::StartTag curtag = tag_stack_.back(); while (html::isFontTag(curtag.tag_)) { os_ << curtag.asEndTag(); tag_stack_.pop_back(); @@ -237,7 +239,7 @@ bool XHTMLStream::closeFontTags() void XHTMLStream::clearTagDeque() { while (!pending_tags_.empty()) { - StartTag const & tag = pending_tags_.front(); + html::StartTag const & tag = pending_tags_.front(); // tabs? os_ << tag.asTag(); tag_stack_.push_back(tag); @@ -299,7 +301,7 @@ XHTMLStream & XHTMLStream::operator<<(NextRaw const &) } -XHTMLStream & XHTMLStream::operator<<(StartTag const & tag) +XHTMLStream & XHTMLStream::operator<<(html::StartTag const & tag) { if (tag.tag_.empty()) return *this; @@ -310,7 +312,7 @@ XHTMLStream & XHTMLStream::operator<<(StartTag const & tag) } -XHTMLStream & XHTMLStream::operator<<(CompTag const & tag) +XHTMLStream & XHTMLStream::operator<<(html::CompTag const & tag) { if (tag.tag_.empty()) return *this; @@ -339,7 +341,7 @@ bool XHTMLStream::isTagOpen(string const & stag) // 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<<(EndTag const & etag) +XHTMLStream & XHTMLStream::operator<<(html::EndTag const & etag) { if (etag.tag_.empty()) return *this; @@ -353,7 +355,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag) // first make sure we're not closing an empty tag if (!pending_tags_.empty()) { - StartTag const & stag = pending_tags_.back(); + html::StartTag const & stag = pending_tags_.back(); if (etag.tag_ == stag.tag_) { // we have , so we discard it and remove it // from the pending_tags_. @@ -436,7 +438,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag) // and are being asked to closed em. we want: // this is bold // first, we close the intervening tags... - StartTag curtag = tag_stack_.back(); + html::StartTag curtag = tag_stack_.back(); // ...remembering them in a stack. TagStack fontstack; while (curtag.tag_ != etag.tag_) { @@ -463,7 +465,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag) // at least guarantees proper nesting. writeError("Closing tag `" + etag.tag_ + "' when other tags are open, namely:"); - StartTag curtag = tag_stack_.back(); + html::StartTag curtag = tag_stack_.back(); while (curtag.tag_ != etag.tag_) { writeError(curtag.tag_); os_ << curtag.asEndTag(); @@ -485,37 +487,37 @@ namespace { inline void openTag(XHTMLStream & xs, Layout const & lay) { - xs << StartTag(lay.htmltag(), lay.htmlattr()); + xs << html::StartTag(lay.htmltag(), lay.htmlattr()); } inline void closeTag(XHTMLStream & xs, Layout const & lay) { - xs << EndTag(lay.htmltag()); + xs << html::EndTag(lay.htmltag()); } inline void openLabelTag(XHTMLStream & xs, Layout const & lay) { - xs << StartTag(lay.htmllabeltag(), lay.htmllabelattr()); + xs << html::StartTag(lay.htmllabeltag(), lay.htmllabelattr()); } inline void closeLabelTag(XHTMLStream & xs, Layout const & lay) { - xs << EndTag(lay.htmllabeltag()); + xs << html::EndTag(lay.htmllabeltag()); } inline void openItemTag(XHTMLStream & xs, Layout const & lay) { - xs << StartTag(lay.htmlitemtag(), lay.htmlitemattr(), true); + xs << html::StartTag(lay.htmlitemtag(), lay.htmlitemattr(), true); } inline void closeItemTag(XHTMLStream & xs, Layout const & lay) { - xs << EndTag(lay.htmlitemtag()); + xs << html::EndTag(lay.htmlitemtag()); } // end of convenience functions @@ -619,14 +621,14 @@ ParagraphList::const_iterator makeBibliography(Buffer const & buf, ParagraphList::const_iterator const & pbegin, ParagraphList::const_iterator const & pend) { - xs << StartTag("h2", "class='bibliography'"); + xs << html::StartTag("h2", "class='bibliography'"); xs << pbegin->layout().labelstring(false); - xs << EndTag("h2"); + xs << html::EndTag("h2"); xs.cr(); - xs << StartTag("div", "class='bibliography'"); + xs << html::StartTag("div", "class='bibliography'"); xs.cr(); makeParagraphs(buf, xs, runparams, text, pbegin, pend); - xs << EndTag("div"); + xs << html::EndTag("div"); return pend; } diff --git a/src/output_xhtml.h b/src/output_xhtml.h index 21ec8f61bb..91b4e68522 100644 --- a/src/output_xhtml.h +++ b/src/output_xhtml.h @@ -27,6 +27,7 @@ class Text; // Inspiration for the *Tag structs and for XHTMLStream // came from MathStream and its cousins. +namespace html { /// Attributes will be escaped automatically and so should NOT /// be escaped before passing to the constructor. struct StartTag { @@ -82,6 +83,7 @@ struct CompTag { std::string attr_; }; +} // namespace HTML class XHTMLStream { public: @@ -107,11 +109,11 @@ public: /// XHTMLStream & operator<<(int); /// - XHTMLStream & operator<<(StartTag const &); + XHTMLStream & operator<<(html::StartTag const &); /// - XHTMLStream & operator<<(EndTag const &); + XHTMLStream & operator<<(html::EndTag const &); /// - XHTMLStream & operator<<(CompTag const &); + XHTMLStream & operator<<(html::CompTag const &); /// A trivial struct that functions as a stream modifier. /// << NextRaw() causes the next string-like thing sent to the /// stream not to be escaped. @@ -130,9 +132,9 @@ private: /// // int tab_; /// - typedef std::deque TagDeque; + typedef std::deque TagDeque; /// - typedef std::vector TagStack; + typedef std::vector TagStack; /// holds start tags until we know there is content in them. TagDeque pending_tags_; /// remembers the history, so we can make sure we nest properly.