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) {
// 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;
}
}

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
// 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();
}

View File

@ -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<docstring>::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();
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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

View File

@ -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() << "&seArr;"
<< EndTag("a");
xs << EndTag("div");
<< html::EndTag("a");
xs << html::EndTag("div");
}
xs << EndTag("div");
xs << html::EndTag("div");
return ods.str();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<IndexEntry>::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();
}

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
// 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();
}

View File

@ -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();
}

View File

@ -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;

View File

@ -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();
}

View File

@ -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();
}

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.
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();
}

View File

@ -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() << "&seArr;";
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();
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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 <tag></tag>, 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:
// <em>this is <strong>bold</strong></em><strong>
// 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;
}

View File

@ -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<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.
TagDeque pending_tags_;
/// remembers the history, so we can make sure we nest properly.