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
This commit is contained in:
Richard Heck 2010-01-19 22:08:04 +00:00
parent df3acef80f
commit 3e654186d2
25 changed files with 136 additions and 132 deletions

View File

@ -2414,7 +2414,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
if (!runparams.for_toc && runparams.html_make_pars) { if (!runparams.for_toc && runparams.html_make_pars) {
// generate a magic label for this paragraph // generate a magic label for this paragraph
string const attr = "id='" + magicLabel() + "'"; string const attr = "id='" + magicLabel() + "'";
xs << CompTag("a", attr); xs << html::CompTag("a", attr);
} }
FontInfo font_old = FontInfo font_old =
@ -2427,20 +2427,20 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
// emphasis // emphasis
if (font_old.emph() != font.fontInfo().emph()) { if (font_old.emph() != font.fontInfo().emph()) {
if (font.fontInfo().emph() == FONT_ON) { if (font.fontInfo().emph() == FONT_ON) {
xs << StartTag("em"); xs << html::StartTag("em");
emph_flag = true; emph_flag = true;
} else if (emph_flag && i != initial) { } else if (emph_flag && i != initial) {
xs << EndTag("em"); xs << html::EndTag("em");
emph_flag = false; emph_flag = false;
} }
} }
// bold // bold
if (font_old.series() != font.fontInfo().series()) { if (font_old.series() != font.fontInfo().series()) {
if (font.fontInfo().series() == BOLD_SERIES) { if (font.fontInfo().series() == BOLD_SERIES) {
xs << StartTag("strong"); xs << html::StartTag("strong");
bold_flag = true; bold_flag = true;
} else if (bold_flag && i != initial) { } else if (bold_flag && i != initial) {
xs << EndTag("strong"); xs << html::EndTag("strong");
bold_flag = false; bold_flag = false;
} }
} }

View File

@ -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 // handle jumping to ids. If we don't do that, though, we can just put the
// id into the span tag. // id into the span tag.
string const attrs = "id='" + to_utf8(getParam("key")) + "'"; string const attrs = "id='" + to_utf8(getParam("key")) + "'";
xs << CompTag("a", attrs); xs << html::CompTag("a", attrs);
xs << StartTag("span", "class='bibitemlabel'"); xs << html::StartTag("span", "class='bibitemlabel'");
xs << bibLabel(); xs << bibLabel();
xs << EndTag("span"); xs << html::EndTag("span");
return docstring(); return docstring();
} }

View File

@ -920,10 +920,10 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
bool const numbers = bool const numbers =
(engine == ENGINE_BASIC || engine == ENGINE_NATBIB_NUMERICAL); (engine == ENGINE_BASIC || engine == ENGINE_NATBIB_NUMERICAL);
xs << StartTag("h2", "class='bibtex'") xs << html::StartTag("h2", "class='bibtex'")
<< _("References") << _("References")
<< EndTag("h2") << html::EndTag("h2")
<< StartTag("div", "class='bibtex'"); << html::StartTag("div", "class='bibtex'");
// Now we loop over the entries // Now we loop over the entries
vector<docstring>::const_iterator vit = cites.begin(); vector<docstring>::const_iterator vit = cites.begin();
@ -933,11 +933,11 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
if (biit == bibinfo.end()) if (biit == bibinfo.end())
continue; continue;
BibTeXInfo const & entry = biit->second; BibTeXInfo const & entry = biit->second;
xs << StartTag("div", "class='bibtexentry'"); xs << html::StartTag("div", "class='bibtexentry'");
// FIXME XHTML // FIXME XHTML
// The same name/id problem we have elsewhere. // The same name/id problem we have elsewhere.
string const attr = "id='" + to_utf8(entry.key()) + "'"; string const attr = "id='" + to_utf8(entry.key()) + "'";
xs << CompTag("a", attr); xs << html::CompTag("a", attr);
docstring citekey; docstring citekey;
if (numbers) if (numbers)
citekey = entry.citeNumber(); citekey = entry.citeNumber();
@ -954,19 +954,19 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
if (citekey.empty()) if (citekey.empty())
citekey = entry.key(); citekey = entry.key();
} }
xs << StartTag("span", "class='bibtexlabel'") xs << html::StartTag("span", "class='bibtexlabel'")
<< citekey << citekey
<< EndTag("span"); << html::EndTag("span");
// FIXME Right now, we are calling BibInfo::getInfo on the key, // FIXME Right now, we are calling BibInfo::getInfo on the key,
// which will give us all the cross-referenced info. But for every // 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 repitition. This should be fixed.
xs << StartTag("span", "class='bibtexinfo'") xs << html::StartTag("span", "class='bibtexinfo'")
<< bibinfo.getInfo(entry.key()) << bibinfo.getInfo(entry.key())
<< EndTag("span") << html::EndTag("span")
<< EndTag("div"); << html::EndTag("div");
xs.cr(); xs.cr();
} }
xs << EndTag("div"); xs << html::EndTag("div");
return docstring(); return docstring();
} }

View File

@ -492,10 +492,10 @@ docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) cons
if (!style.empty()) if (!style.empty())
attrs += " style='" + style + "'"; attrs += " style='" + style + "'";
xs << StartTag("div", attrs); xs << html::StartTag("div", attrs);
XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag; XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag;
docstring defer = InsetText::insetAsXHTML(xs, runparams, opts); docstring defer = InsetText::insetAsXHTML(xs, runparams, opts);
xs << EndTag("div"); xs << html::EndTag("div");
xs << defer; xs << defer;
return docstring(); return docstring();
} }

View File

@ -268,9 +268,9 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const
if (!type_.empty()) if (!type_.empty())
attr += " float-caption-" + type_; attr += " float-caption-" + type_;
attr += "'"; attr += "'";
xs << StartTag("div", attr); xs << html::StartTag("div", attr);
docstring def = getCaptionAsHTML(xs, rp); docstring def = getCaptionAsHTML(xs, rp);
xs << EndTag("div"); xs << html::EndTag("div");
return def; return def;
} }

View File

@ -291,11 +291,11 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
odocstringstream ods; odocstringstream ods;
XHTMLStream newxs(ods); XHTMLStream newxs(ods);
newxs << StartTag(htmltype, attr); newxs << html::StartTag(htmltype, attr);
InsetText::XHTMLOptions const opts = InsetText::XHTMLOptions const opts =
InsetText::WriteLabel | InsetText::WriteInnerTag; InsetText::WriteLabel | InsetText::WriteInnerTag;
docstring deferred = InsetText::insetAsXHTML(newxs, rp, opts); docstring deferred = InsetText::insetAsXHTML(newxs, rp, opts);
newxs << EndTag(htmltype); newxs << html::EndTag(htmltype);
if (rp.inFloat == OutputParams::NONFLOAT) if (rp.inFloat == OutputParams::NONFLOAT)
// In this case, this float needs to be deferred, but we'll put it // In this case, this float needs to be deferred, but we'll put it

View File

@ -214,10 +214,10 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const &) const {
odocstringstream ods; odocstringstream ods;
XHTMLStream xs(ods); XHTMLStream xs(ods);
xs << StartTag("div", "class='toc'"); xs << html::StartTag("div", "class='toc'");
xs << StartTag("div", tocattr) xs << html::StartTag("div", tocattr)
<< toclabel << toclabel
<< EndTag("div"); << html::EndTag("div");
Toc::const_iterator it = toc.begin(); Toc::const_iterator it = toc.begin();
Toc::const_iterator const en = toc.end(); Toc::const_iterator const en = toc.end();
@ -225,17 +225,17 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const &) const {
Paragraph const & par = it->dit().innerParagraph(); Paragraph const & par = it->dit().innerParagraph();
string const attr = "class='lyxtoc-" + toctype + "'"; string const attr = "class='lyxtoc-" + toctype + "'";
Font const dummy; Font const dummy;
xs << StartTag("div", attr); xs << html::StartTag("div", attr);
string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'"; string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'";
xs << it->str() << " " xs << it->str() << " "
<< StartTag("a", parattr) << html::StartTag("a", parattr)
// FIXME XHTML // FIXME XHTML
// There ought to be a simple way to customize this. // There ought to be a simple way to customize this.
<< XHTMLStream::NextRaw() << "&seArr;" << XHTMLStream::NextRaw() << "&seArr;"
<< EndTag("a"); << html::EndTag("a");
xs << EndTag("div"); xs << html::EndTag("div");
} }
xs << EndTag("div"); xs << html::EndTag("div");
return ods.str(); return ods.str();
} }

View File

@ -951,7 +951,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
<< params().filename << "' for output. File missing?"); << params().filename << "' for output. File missing?");
string const attr = "src='" + params().filename.absFilename() string const attr = "src='" + params().filename.absFilename()
+ "' alt='image: " + output_file + "'"; + "' alt='image: " + output_file + "'";
xs << CompTag("img", attr); xs << html::CompTag("img", attr);
return docstring(); return docstring();
} }
@ -961,7 +961,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
// Speaking of which: Do the cropping, rotating, etc. // Speaking of which: Do the cropping, rotating, etc.
string const attr = "src='" + output_file + "' alt='image: " string const attr = "src='" + output_file + "' alt='image: "
+ output_file + "'"; + output_file + "'";
xs << CompTag("img", attr); xs << html::CompTag("img", attr);
return docstring(); return docstring();
} }

View File

@ -186,9 +186,9 @@ docstring InsetHyperlink::xhtml(XHTMLStream & xs, OutputParams const &) const
{ {
docstring const & target = getParam("target"); docstring const & target = getParam("target");
docstring const & name = getParam("name"); 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 << (name.empty() ? target : name);
xs << EndTag("a"); xs << html::EndTag("a");
return docstring(); return docstring();
} }

View File

@ -668,11 +668,11 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const &rp) const
bool const listing = isListings(params()); bool const listing = isListings(params());
if (listing || isVerbatim(params())) { if (listing || isVerbatim(params())) {
if (listing) if (listing)
xs << StartTag("pre"); xs << html::StartTag("pre");
// FIXME: We don't know the encoding of the file, default to UTF-8. // FIXME: We don't know the encoding of the file, default to UTF-8.
xs << includedFilename(buffer(), params()).fileContents("UTF-8"); xs << includedFilename(buffer(), params()).fileContents("UTF-8");
if (listing) if (listing)
xs << EndTag("pre"); xs << html::EndTag("pre");
return docstring(); return docstring();
} }

View File

@ -182,7 +182,7 @@ docstring InsetIndex::xhtml(XHTMLStream & xs, OutputParams const &) const
// our own interior paragraph, which doesn't get printed // our own interior paragraph, which doesn't get printed
std::string const magic = paragraphs().front().magicLabel(); std::string const magic = paragraphs().front().magicLabel();
std::string const attr = "id='" + magic + "'"; std::string const attr = "id='" + magic + "'";
xs << CompTag("a", attr); xs << html::CompTag("a", attr);
return docstring(); return docstring();
} }
@ -701,11 +701,11 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
odocstringstream ods; odocstringstream ods;
XHTMLStream xs(ods); XHTMLStream xs(ods);
xs << StartTag("div", "class='index'"); xs << html::StartTag("div", "class='index'");
xs << StartTag(lay.htmltag(), lay.htmlattr()) xs << html::StartTag(lay.htmltag(), lay.htmlattr())
<< _("Index") << _("Index")
<< EndTag(lay.htmltag()); << html::EndTag(lay.htmltag());
xs << StartTag("ul", "class='main'"); xs << html::StartTag("ul", "class='main'");
Font const dummy; Font const dummy;
vector<IndexEntry>::const_iterator eit = entries.begin(); vector<IndexEntry>::const_iterator eit = entries.begin();
@ -725,12 +725,12 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// close last entry or entries, depending. // close last entry or entries, depending.
if (level == 3) { if (level == 3) {
// close this sub-sub-entry // close this sub-sub-entry
xs << EndTag("li"); xs << html::EndTag("li");
xs.cr(); xs.cr();
// is this another sub-sub-entry within the same sub-entry? // is this another sub-sub-entry within the same sub-entry?
if (!eit->same_sub(last)) { if (!eit->same_sub(last)) {
// close this level // close this level
xs << EndTag("ul"); xs << html::EndTag("ul");
xs.cr(); xs.cr();
level = 2; 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. // sub-entry. In that case, we do not want to close anything.
if (level == 2 && !eit->same_sub(last)) { if (level == 2 && !eit->same_sub(last)) {
// close sub-entry // close sub-entry
xs << EndTag("li"); xs << html::EndTag("li");
xs.cr(); xs.cr();
// is this another sub-entry with the same main entry? // is this another sub-entry with the same main entry?
if (!eit->same_main(last)) { if (!eit->same_main(last)) {
// close this level // close this level
xs << EndTag("ul"); xs << html::EndTag("ul");
xs.cr(); xs.cr();
level = 1; level = 1;
} }
@ -757,7 +757,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// close the entry. // close the entry.
if (level == 1 && !eit->same_main(last)) { if (level == 1 && !eit->same_main(last)) {
// close entry // close entry
xs << EndTag("li"); xs << html::EndTag("li");
xs.cr(); xs.cr();
} }
} }
@ -786,7 +786,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
if (level == 3) { if (level == 3) {
// another subsubentry // another subsubentry
xs << StartTag("li", "class='subsubentry'") xs << html::StartTag("li", "class='subsubentry'")
<< XHTMLStream::NextRaw() << subsub; << XHTMLStream::NextRaw() << subsub;
} else if (level == 2) { } else if (level == 2) {
// there are two ways we can be here: // 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 // note that in this case, too, though, the sub-entry might already
// have a sub-sub-entry. // have a sub-sub-entry.
if (eit->sub != last.sub) if (eit->sub != last.sub)
xs << StartTag("li", "class='subentry'") xs << html::StartTag("li", "class='subentry'")
<< XHTMLStream::NextRaw() << sub; << XHTMLStream::NextRaw() << sub;
if (!subsub.empty()) { if (!subsub.empty()) {
// it's actually a subsubentry, so we need to start that list // it's actually a subsubentry, so we need to start that list
xs.cr(); xs.cr();
xs << StartTag("ul", "class='subsubentry'") xs << html::StartTag("ul", "class='subsubentry'")
<< StartTag("li", "class='subsubentry'") << html::StartTag("li", "class='subsubentry'")
<< XHTMLStream::NextRaw() << subsub; << XHTMLStream::NextRaw() << subsub;
level = 3; 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 // note that in this case, too, though, the main entry might already
// have a sub-entry, or even a sub-sub-entry. // have a sub-entry, or even a sub-sub-entry.
if (eit->main != last.main) if (eit->main != last.main)
xs << StartTag("li", "class='main'") << main; xs << html::StartTag("li", "class='main'") << main;
if (!sub.empty()) { if (!sub.empty()) {
// there's a sub-entry, too // there's a sub-entry, too
xs.cr(); xs.cr();
xs << StartTag("ul", "class='subentry'") xs << html::StartTag("ul", "class='subentry'")
<< StartTag("li", "class='subentry'") << html::StartTag("li", "class='subentry'")
<< XHTMLStream::NextRaw() << sub; << XHTMLStream::NextRaw() << sub;
level = 2; level = 2;
if (!subsub.empty()) { if (!subsub.empty()) {
// and a sub-sub-entry // and a sub-sub-entry
xs.cr(); xs.cr();
xs << StartTag("ul", "class='subsubentry'") xs << html::StartTag("ul", "class='subsubentry'")
<< StartTag("li", "class='subsubentry'") << html::StartTag("li", "class='subsubentry'")
<< XHTMLStream::NextRaw() << subsub; << XHTMLStream::NextRaw() << subsub;
level = 3; level = 3;
} }
@ -844,17 +844,17 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// finally, then, we can output the index link itself // finally, then, we can output the index link itself
string const parattr = "href='#" + par.magicLabel() + "'"; string const parattr = "href='#" + par.magicLabel() + "'";
xs << (entry_number == 0 ? ":" : ","); xs << (entry_number == 0 ? ":" : ",");
xs << " " << StartTag("a", parattr) xs << " " << html::StartTag("a", parattr)
<< ++entry_number << EndTag("a"); << ++entry_number << html::EndTag("a");
last = *eit; last = *eit;
} }
// now we have to close all the open levels // now we have to close all the open levels
while (level > 0) { while (level > 0) {
xs << EndTag("li") << EndTag("ul"); xs << html::EndTag("li") << html::EndTag("ul");
xs.cr(); xs.cr();
--level; --level;
} }
xs << EndTag("div"); xs << html::EndTag("div");
xs.cr(); xs.cr();
return ods.str(); return ods.str();
} }

View File

@ -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 // problem with some browsers, though, I'm sure. (Guess which!) So we will
// have to figure out what to do about this later. // have to figure out what to do about this later.
string const attr = "id=\"" + html::cleanAttr(to_utf8(getParam("name"))) + "\""; string const attr = "id=\"" + html::cleanAttr(to_utf8(getParam("name"))) + "\"";
xs << CompTag("a", attr); xs << html::CompTag("a", attr);
return docstring(); return docstring();
} }

View File

@ -88,7 +88,7 @@ int InsetLine::docbook(odocstream & os, OutputParams const &) const
docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const
{ {
xs << CompTag("hr"); xs << html::CompTag("hr");
xs.cr(); xs.cr();
return docstring(); return docstring();
} }

View File

@ -275,27 +275,27 @@ docstring InsetListings::xhtml(XHTMLStream & os, OutputParams const & rp) const
bool const isInline = params().isInline(); bool const isInline = params().isInline();
if (isInline) if (isInline)
out << CompTag("br"); out << html::CompTag("br");
else { else {
out << StartTag("div", "class='float float-listings'"); out << html::StartTag("div", "class='float float-listings'");
docstring caption = getCaptionHTML(rp); docstring caption = getCaptionHTML(rp);
if (!caption.empty()) if (!caption.empty())
out << StartTag("div", "class='float-caption'") out << html::StartTag("div", "class='float-caption'")
<< caption << EndTag("div"); << caption << html::EndTag("div");
} }
out << StartTag("pre"); out << html::StartTag("pre");
OutputParams newrp = rp; OutputParams newrp = rp;
newrp.html_disable_captions = true; newrp.html_disable_captions = true;
docstring def = InsetText::insetAsXHTML(out, newrp, InsetText::JustText); docstring def = InsetText::insetAsXHTML(out, newrp, InsetText::JustText);
out << EndTag("pre"); out << html::EndTag("pre");
if (isInline) { if (isInline) {
out << CompTag("br"); out << html::CompTag("br");
// escaping will already have been done // escaping will already have been done
os << XHTMLStream::NextRaw() << ods.str(); os << XHTMLStream::NextRaw() << ods.str();
} else { } else {
out << EndTag("div"); out << html::EndTag("div");
// In this case, this needs to be deferred, but we'll put it // In this case, this needs to be deferred, but we'll put it
// before anything the text itself deferred. // before anything the text itself deferred.
def = ods.str() + '\n' + def; def = ods.str() + '\n' + def;

View File

@ -176,7 +176,7 @@ int InsetNewline::docbook(odocstream & os, OutputParams const &) const
docstring InsetNewline::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetNewline::xhtml(XHTMLStream & xs, OutputParams const &) const
{ {
xs << CompTag("br"); xs << html::CompTag("br");
xs.cr(); xs.cr();
return docstring(); return docstring();
} }

View File

@ -250,7 +250,7 @@ int InsetNewpage::docbook(odocstream & os, OutputParams const &) const
docstring InsetNewpage::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetNewpage::xhtml(XHTMLStream & xs, OutputParams const &) const
{ {
xs << CompTag("br"); xs << html::CompTag("br");
return docstring(); return docstring();
} }

View File

@ -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. // some sort of counter with the label, and we don't have that yet.
docstring const ref = html::cleanAttr(getParam("reference")); docstring const ref = html::cleanAttr(getParam("reference"));
string const attr = "href=\"#" + to_utf8(ref) + "\""; string const attr = "href=\"#" + to_utf8(ref) + "\"";
xs << StartTag("a", attr); xs << html::StartTag("a", attr);
xs << ref; xs << ref;
xs << EndTag("a"); xs << html::EndTag("a");
return docstring(); return docstring();
} }

View File

@ -89,10 +89,10 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
if (toc.empty()) if (toc.empty())
return docstring(); return docstring();
xs << StartTag("div", "class='toc'"); xs << html::StartTag("div", "class='toc'");
xs << StartTag("div", tocattr) xs << html::StartTag("div", tocattr)
<< _("Table of Contents") << _("Table of Contents")
<< EndTag("div"); << html::EndTag("div");
Toc::const_iterator it = toc.begin(); Toc::const_iterator it = toc.begin();
Toc::const_iterator const en = toc.end(); Toc::const_iterator const en = toc.end();
int lastdepth = 0; int lastdepth = 0;
@ -109,7 +109,7 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
for (int i = lastdepth + 1; i <= depth; ++i) { for (int i = lastdepth + 1; i <= depth; ++i) {
stringstream attr; stringstream attr;
attr << "class='lyxtoc-" << i << "'"; attr << "class='lyxtoc-" << i << "'";
xs << StartTag("div", attr.str()); xs << html::StartTag("div", attr.str());
} }
lastdepth = depth; 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 // close as many as we have to close to get back to this level
// this includes closing the last tag at this level // this includes closing the last tag at this level
for (int i = lastdepth; i >= depth; --i) for (int i = lastdepth; i >= depth; --i)
xs << EndTag("div"); xs << html::EndTag("div");
// now open our tag // now open our tag
stringstream attr; stringstream attr;
attr << "class='lyxtoc-" << depth << "'"; attr << "class='lyxtoc-" << depth << "'";
xs << StartTag("div", attr.str()); xs << html::StartTag("div", attr.str());
lastdepth = depth; lastdepth = depth;
} else { } else {
// no change of level, so close and open // no change of level, so close and open
xs << EndTag("div"); xs << html::EndTag("div");
stringstream attr; stringstream attr;
attr << "class='lyxtoc-" << depth << "'"; attr << "class='lyxtoc-" << depth << "'";
xs << StartTag("div", attr.str()); xs << html::StartTag("div", attr.str());
} }
string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'"; string const parattr = "href='#" + par.magicLabel() + "' class='tocarrow'";
OutputParams ours = op; OutputParams ours = op;
ours.for_toc = true; ours.for_toc = true;
par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy); par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy);
xs << " "; xs << " ";
xs << StartTag("a", parattr); xs << html::StartTag("a", parattr);
// FIXME XHTML // FIXME XHTML
// There ought to be a simple way to customize this. // There ought to be a simple way to customize this.
xs << XHTMLStream::NextRaw() << "&seArr;"; xs << XHTMLStream::NextRaw() << "&seArr;";
xs << EndTag("a"); xs << html::EndTag("a");
} }
for (int i = lastdepth; i > 0; --i) for (int i = lastdepth; i > 0; --i)
xs << EndTag("div"); xs << html::EndTag("div");
xs << EndTag("div"); xs << html::EndTag("div");
return ods.str(); return ods.str();
} }

View File

@ -2639,7 +2639,7 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
docstring ret; docstring ret;
idx_type cell = getFirstCellInRow(row); idx_type cell = getFirstCellInRow(row);
xs << StartTag("tr"); xs << html::StartTag("tr");
for (col_type j = 0; j < column_info.size(); ++j) { for (col_type j = 0; j < column_info.size(); ++j) {
if (isPartOfMultiColumn(row, j)) if (isPartOfMultiColumn(row, j))
continue; continue;
@ -2674,12 +2674,12 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
if (isMultiColumn(cell)) if (isMultiColumn(cell))
attr << " colspan='" << columnSpan(cell) << "'"; attr << " colspan='" << columnSpan(cell) << "'";
xs << StartTag("td", attr.str()); xs << html::StartTag("td", attr.str());
ret += cellInset(cell)->xhtml(xs, runparams); ret += cellInset(cell)->xhtml(xs, runparams);
xs << EndTag("td"); xs << html::EndTag("td");
++cell; ++cell;
} }
xs << EndTag("tr"); xs << html::EndTag("tr");
return ret; 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. // It's unclear to me if we need to mess with the long table stuff.
// We can borrow that too from docbook, if so. // 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) { for (row_type i = 0; i < row_info.size(); ++i) {
if (isValidRow(i)) { if (isValidRow(i)) {
ret += xhtmlRow(xs, i, runparams); ret += xhtmlRow(xs, i, runparams);
} }
} }
xs << EndTag("tbody"); xs << html::EndTag("tbody");
return ret; return ret;
} }
@ -4305,9 +4305,9 @@ docstring InsetTabular::xhtml(XHTMLStream & xs, OutputParams const & rp) const
// FIXME XHTML // FIXME XHTML
// It'd be better to be able to get this from an InsetLayout, but at present // 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. // 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); docstring ret = tabular.xhtml(xs, rp);
xs << EndTag("table"); xs << html::EndTag("table");
return ret; return ret;
} }

View File

@ -500,7 +500,7 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & runpara
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
if (opts & WriteOuterTag) if (opts & WriteOuterTag)
xs << StartTag(il.htmltag(), il.htmlattr()); xs << html::StartTag(il.htmltag(), il.htmlattr());
if ((opts & WriteLabel) && !il.counter().empty()) { if ((opts & WriteLabel) && !il.counter().empty()) {
BufferParams const & bp = buffer().masterBuffer()->params(); BufferParams const & bp = buffer().masterBuffer()->params();
Counters & cntrs = bp.documentClass().counters(); 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()); cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
// FIXME is this check necessary? // FIXME is this check necessary?
if (!lbl.empty()) { if (!lbl.empty()) {
xs << StartTag(il.htmllabeltag(), il.htmllabelattr()); xs << html::StartTag(il.htmllabeltag(), il.htmllabelattr());
xs << lbl; xs << lbl;
xs << EndTag(il.htmllabeltag()); xs << html::EndTag(il.htmllabeltag());
} }
} }
} }
if (opts & WriteInnerTag) if (opts & WriteInnerTag)
xs << StartTag(il.htmlinnertag(), il.htmlinnerattr()); xs << html::StartTag(il.htmlinnertag(), il.htmlinnerattr());
OutputParams ours = runparams; OutputParams ours = runparams;
if (!il.isMultiPar() || opts == JustText) if (!il.isMultiPar() || opts == JustText)
ours.html_make_pars = false; ours.html_make_pars = false;
xhtmlParagraphs(text_, buffer(), xs, ours); xhtmlParagraphs(text_, buffer(), xs, ours);
if (opts & WriteInnerTag) if (opts & WriteInnerTag)
xs << EndTag(il.htmlinnertag()); xs << html::EndTag(il.htmlinnertag());
if (opts & WriteOuterTag) if (opts & WriteOuterTag)
xs << EndTag(il.htmltag()); xs << html::EndTag(il.htmltag());
return docstring(); return docstring();
} }

View File

@ -241,7 +241,7 @@ docstring InsetVSpace::xhtml(XHTMLStream &, OutputParams const &) const
XHTMLStream xds(ods); XHTMLStream xds(ods);
string const len = space_.asHTMLLength(); string const len = space_.asHTMLLength();
string const attr = "style='height:" + (len.empty() ? "1em" : len) + "'"; 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(); return ods.str();
} }

View File

@ -220,11 +220,11 @@ docstring InsetWrap::xhtml(XHTMLStream & xs, OutputParams const & rp) const
string const len = params_.width.asHTMLString(); string const len = params_.width.asHTMLString();
string const width = len.empty() ? "50%" : len; string const width = len.empty() ? "50%" : len;
string const attr = "class='wrap' style='width: " + len + ";'"; string const attr = "class='wrap' style='width: " + len + ";'";
xs << StartTag("div", attr); xs << html::StartTag("div", attr);
docstring const deferred = docstring const deferred =
InsetText::insetAsXHTML(xs, rp, InsetText::WriteInnerTag); InsetText::insetAsXHTML(xs, rp, InsetText::WriteInnerTag);
if (!len.empty()) if (!len.empty())
xs << EndTag("div"); xs << html::EndTag("div");
return deferred; return deferred;
} }

View File

@ -1777,13 +1777,13 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const &) const
{ {
if (getType() == hullSimple) 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 else
xs << StartTag("math", xs << html::StartTag("math",
"display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\"", true); "display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\"", true);
MathStream ms(xs.os()); MathStream ms(xs.os());
InsetMathGrid::mathmlize(ms); InsetMathGrid::mathmlize(ms);
xs << EndTag("math"); xs << html::EndTag("math");
return docstring(); return docstring();
} }

View File

@ -140,7 +140,6 @@ bool isFontTag(string const & s)
{ {
return s == "em" || s == "strong"; // others? return s == "em" || s == "strong"; // others?
} }
} // namespace html
docstring StartTag::asTag() const docstring StartTag::asTag() const
@ -176,6 +175,9 @@ docstring CompTag::asTag() const
return from_utf8(output); return from_utf8(output);
} }
} // namespace html
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
/// ///
@ -207,7 +209,7 @@ bool XHTMLStream::closeFontTags()
if (tag_stack_.empty()) if (tag_stack_.empty())
return true; return true;
// first, we close any open font tags we can close // 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_)) { while (html::isFontTag(curtag.tag_)) {
os_ << curtag.asEndTag(); os_ << curtag.asEndTag();
tag_stack_.pop_back(); tag_stack_.pop_back();
@ -237,7 +239,7 @@ bool XHTMLStream::closeFontTags()
void XHTMLStream::clearTagDeque() void XHTMLStream::clearTagDeque()
{ {
while (!pending_tags_.empty()) { while (!pending_tags_.empty()) {
StartTag const & tag = pending_tags_.front(); html::StartTag const & tag = pending_tags_.front();
// tabs? // tabs?
os_ << tag.asTag(); os_ << tag.asTag();
tag_stack_.push_back(tag); 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()) if (tag.tag_.empty())
return *this; 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()) if (tag.tag_.empty())
return *this; 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 // sure of that, but we won't assert (yet) if we run into
// a problem. we'll just output error messages and try our // a problem. we'll just output error messages and try our
// best to make things work. // best to make things work.
XHTMLStream & XHTMLStream::operator<<(EndTag const & etag) XHTMLStream & XHTMLStream::operator<<(html::EndTag const & etag)
{ {
if (etag.tag_.empty()) if (etag.tag_.empty())
return *this; return *this;
@ -353,7 +355,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
// first make sure we're not closing an empty tag // first make sure we're not closing an empty tag
if (!pending_tags_.empty()) { if (!pending_tags_.empty()) {
StartTag const & stag = pending_tags_.back(); html::StartTag const & stag = pending_tags_.back();
if (etag.tag_ == stag.tag_) { if (etag.tag_ == stag.tag_) {
// we have <tag></tag>, so we discard it and remove it // we have <tag></tag>, so we discard it and remove it
// from the pending_tags_. // from the pending_tags_.
@ -436,7 +438,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
// and are being asked to closed em. we want: // and are being asked to closed em. we want:
// <em>this is <strong>bold</strong></em><strong> // <em>this is <strong>bold</strong></em><strong>
// first, we close the intervening tags... // first, we close the intervening tags...
StartTag curtag = tag_stack_.back(); html::StartTag curtag = tag_stack_.back();
// ...remembering them in a stack. // ...remembering them in a stack.
TagStack fontstack; TagStack fontstack;
while (curtag.tag_ != etag.tag_) { while (curtag.tag_ != etag.tag_) {
@ -463,7 +465,7 @@ XHTMLStream & XHTMLStream::operator<<(EndTag const & etag)
// at least guarantees proper nesting. // at least guarantees proper nesting.
writeError("Closing tag `" + etag.tag_ writeError("Closing tag `" + etag.tag_
+ "' when other tags are open, namely:"); + "' when other tags are open, namely:");
StartTag curtag = tag_stack_.back(); html::StartTag curtag = tag_stack_.back();
while (curtag.tag_ != etag.tag_) { while (curtag.tag_ != etag.tag_) {
writeError(curtag.tag_); writeError(curtag.tag_);
os_ << curtag.asEndTag(); os_ << curtag.asEndTag();
@ -485,37 +487,37 @@ namespace {
inline void openTag(XHTMLStream & xs, Layout const & lay) 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) 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) 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) 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) 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) inline void closeItemTag(XHTMLStream & xs, Layout const & lay)
{ {
xs << EndTag(lay.htmlitemtag()); xs << html::EndTag(lay.htmlitemtag());
} }
// end of convenience functions // end of convenience functions
@ -619,14 +621,14 @@ ParagraphList::const_iterator makeBibliography(Buffer const & buf,
ParagraphList::const_iterator const & pbegin, ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend) ParagraphList::const_iterator const & pend)
{ {
xs << StartTag("h2", "class='bibliography'"); xs << html::StartTag("h2", "class='bibliography'");
xs << pbegin->layout().labelstring(false); xs << pbegin->layout().labelstring(false);
xs << EndTag("h2"); xs << html::EndTag("h2");
xs.cr(); xs.cr();
xs << StartTag("div", "class='bibliography'"); xs << html::StartTag("div", "class='bibliography'");
xs.cr(); xs.cr();
makeParagraphs(buf, xs, runparams, text, pbegin, pend); makeParagraphs(buf, xs, runparams, text, pbegin, pend);
xs << EndTag("div"); xs << html::EndTag("div");
return pend; return pend;
} }

View File

@ -27,6 +27,7 @@ class Text;
// Inspiration for the *Tag structs and for XHTMLStream // Inspiration for the *Tag structs and for XHTMLStream
// came from MathStream and its cousins. // came from MathStream and its cousins.
namespace html {
/// Attributes will be escaped automatically and so should NOT /// Attributes will be escaped automatically and so should NOT
/// be escaped before passing to the constructor. /// be escaped before passing to the constructor.
struct StartTag { struct StartTag {
@ -82,6 +83,7 @@ struct CompTag {
std::string attr_; std::string attr_;
}; };
} // namespace HTML
class XHTMLStream { class XHTMLStream {
public: public:
@ -107,11 +109,11 @@ public:
/// ///
XHTMLStream & operator<<(int); 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. /// A trivial struct that functions as a stream modifier.
/// << NextRaw() causes the next string-like thing sent to the /// << NextRaw() causes the next string-like thing sent to the
/// stream not to be escaped. /// stream not to be escaped.
@ -130,9 +132,9 @@ private:
/// ///
// int tab_; // int tab_;
/// ///
typedef std::deque<StartTag> TagDeque; typedef std::deque<html::StartTag> TagDeque;
/// ///
typedef std::vector<StartTag> TagStack; typedef std::vector<html::StartTag> TagStack;
/// holds start tags until we know there is content in them. /// holds start tags until we know there is content in them.
TagDeque pending_tags_; TagDeque pending_tags_;
/// remembers the history, so we can make sure we nest properly. /// remembers the history, so we can make sure we nest properly.