mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Clean up XHTML output a bit.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38185 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2378db75c1
commit
461c973d62
@ -977,11 +977,11 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
|
||||
// which will give us all the cross-referenced info. But for every
|
||||
// entry, so there's a lot of repitition. This should be fixed.
|
||||
xs << html::StartTag("span", "class='bibtexinfo'")
|
||||
<< XHTMLStream::ESCAPE_AND
|
||||
<< bibinfo.getInfo(entry.key(), buffer(), true)
|
||||
<< html::EndTag("span")
|
||||
<< html::EndTag("div");
|
||||
xs.cr();
|
||||
<< XHTMLStream::ESCAPE_AND
|
||||
<< bibinfo.getInfo(entry.key(), buffer(), true)
|
||||
<< html::EndTag("span")
|
||||
<< html::EndTag("div")
|
||||
<< html::CR();
|
||||
}
|
||||
xs << html::EndTag("div");
|
||||
return docstring();
|
||||
|
@ -730,13 +730,11 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
// close last entry or entries, depending.
|
||||
if (level == 3) {
|
||||
// close this sub-sub-entry
|
||||
xs << html::EndTag("li");
|
||||
xs.cr();
|
||||
xs << html::EndTag("li") << html::CR();
|
||||
// is this another sub-sub-entry within the same sub-entry?
|
||||
if (!eit->same_sub(last)) {
|
||||
// close this level
|
||||
xs << html::EndTag("ul");
|
||||
xs.cr();
|
||||
xs << html::EndTag("ul") << html::CR();
|
||||
level = 2;
|
||||
}
|
||||
}
|
||||
@ -747,13 +745,11 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
// sub-entry. In that case, we do not want to close anything.
|
||||
if (level == 2 && !eit->same_sub(last)) {
|
||||
// close sub-entry
|
||||
xs << html::EndTag("li");
|
||||
xs.cr();
|
||||
xs << html::EndTag("li") << html::CR();
|
||||
// is this another sub-entry with the same main entry?
|
||||
if (!eit->same_main(last)) {
|
||||
// close this level
|
||||
xs << html::EndTag("ul");
|
||||
xs.cr();
|
||||
xs << html::EndTag("ul") << html::CR();
|
||||
level = 1;
|
||||
}
|
||||
}
|
||||
@ -762,8 +758,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
// close the entry.
|
||||
if (level == 1 && !eit->same_main(last)) {
|
||||
// close entry
|
||||
xs << html::EndTag("li");
|
||||
xs.cr();
|
||||
xs << html::EndTag("li") << html::CR();
|
||||
}
|
||||
}
|
||||
|
||||
@ -809,8 +804,8 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
<< XHTMLStream::ESCAPE_NONE << sub;
|
||||
if (!subsub.empty()) {
|
||||
// it's actually a subsubentry, so we need to start that list
|
||||
xs.cr();
|
||||
xs << html::StartTag("ul", "class='subsubentry'")
|
||||
xs << html::CR()
|
||||
<< html::StartTag("ul", "class='subsubentry'")
|
||||
<< html::StartTag("li", "class='subsubentry'")
|
||||
<< XHTMLStream::ESCAPE_NONE << subsub;
|
||||
level = 3;
|
||||
@ -830,15 +825,15 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
xs << html::StartTag("li", "class='main'") << main;
|
||||
if (!sub.empty()) {
|
||||
// there's a sub-entry, too
|
||||
xs.cr();
|
||||
xs << html::StartTag("ul", "class='subentry'")
|
||||
xs << html::CR()
|
||||
<< html::StartTag("ul", "class='subentry'")
|
||||
<< html::StartTag("li", "class='subentry'")
|
||||
<< XHTMLStream::ESCAPE_NONE << sub;
|
||||
level = 2;
|
||||
if (!subsub.empty()) {
|
||||
// and a sub-sub-entry
|
||||
xs.cr();
|
||||
xs << html::StartTag("ul", "class='subsubentry'")
|
||||
xs << html::CR()
|
||||
<< html::StartTag("ul", "class='subsubentry'")
|
||||
<< html::StartTag("li", "class='subsubentry'")
|
||||
<< XHTMLStream::ESCAPE_NONE << subsub;
|
||||
level = 3;
|
||||
@ -855,12 +850,10 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
}
|
||||
// now we have to close all the open levels
|
||||
while (level > 0) {
|
||||
xs << html::EndTag("li") << html::EndTag("ul");
|
||||
xs.cr();
|
||||
xs << html::EndTag("li") << html::EndTag("ul") << html::CR();
|
||||
--level;
|
||||
}
|
||||
xs << html::EndTag("div");
|
||||
xs.cr();
|
||||
xs << html::EndTag("div") << html::CR();
|
||||
return ods.str();
|
||||
}
|
||||
|
||||
|
@ -199,8 +199,7 @@ int InsetLine::docbook(odocstream & os, OutputParams const &) const
|
||||
|
||||
docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const
|
||||
{
|
||||
xs << html::CompTag("hr");
|
||||
xs.cr();
|
||||
xs << html::CompTag("hr") << html::CR();
|
||||
return docstring();
|
||||
}
|
||||
|
||||
|
@ -177,8 +177,7 @@ int InsetNewline::docbook(odocstream & os, OutputParams const &) const
|
||||
|
||||
docstring InsetNewline::xhtml(XHTMLStream & xs, OutputParams const &) const
|
||||
{
|
||||
xs << html::CompTag("br");
|
||||
xs.cr();
|
||||
xs << html::CR() << html::CompTag("br") << html::CR();
|
||||
return docstring();
|
||||
}
|
||||
|
||||
|
@ -132,13 +132,13 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
continue;
|
||||
|
||||
if (depth > lastdepth) {
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
// open as many tags as we need to open to get to this level
|
||||
// this includes the tag for the current level
|
||||
for (int i = lastdepth + 1; i <= depth; ++i) {
|
||||
stringstream attr;
|
||||
attr << "class='lyxtoc-" << i << "'";
|
||||
xs << html::StartTag("div", attr.str());
|
||||
xs << html::StartTag("div", attr.str()) << html::CR();
|
||||
}
|
||||
lastdepth = depth;
|
||||
}
|
||||
@ -146,18 +146,18 @@ 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 << html::EndTag("div");
|
||||
xs << html::EndTag("div") << html::CR();
|
||||
// now open our tag
|
||||
stringstream attr;
|
||||
attr << "class='lyxtoc-" << depth << "'";
|
||||
xs << html::StartTag("div", attr.str());
|
||||
xs << html::StartTag("div", attr.str()) << html::CR();
|
||||
lastdepth = depth;
|
||||
} else {
|
||||
// no change of level, so close and open
|
||||
xs << html::EndTag("div");
|
||||
xs << html::EndTag("div") << html::CR();
|
||||
stringstream attr;
|
||||
attr << "class='lyxtoc-" << depth << "'";
|
||||
xs << html::StartTag("div", attr.str());
|
||||
xs << html::StartTag("div", attr.str()) << html::CR();
|
||||
}
|
||||
|
||||
// Now output TOC info for this entry
|
||||
@ -182,8 +182,8 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
xs << html::EndTag("a");
|
||||
}
|
||||
for (int i = lastdepth; i > 0; --i)
|
||||
xs << html::EndTag("div");
|
||||
xs << html::EndTag("div");
|
||||
xs << html::EndTag("div") << html::CR();
|
||||
xs << html::EndTag("div") << html::CR();
|
||||
return ods.str();
|
||||
}
|
||||
|
||||
|
@ -2887,11 +2887,9 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
|
||||
if (isMultiColumn(cell))
|
||||
attr << " colspan='" << columnSpan(cell) << "'";
|
||||
|
||||
xs << html::StartTag(celltag, attr.str());
|
||||
xs.cr();
|
||||
xs << html::StartTag(celltag, attr.str()) << html::CR();
|
||||
ret += cellInset(cell)->xhtml(xs, runparams);
|
||||
xs << html::EndTag(celltag);
|
||||
xs.cr();
|
||||
xs << html::EndTag(celltag) << html::CR();
|
||||
++cell;
|
||||
}
|
||||
xs << html::EndTag("tr");
|
||||
@ -2917,17 +2915,19 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
|
||||
align = "right";
|
||||
break;
|
||||
}
|
||||
xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'");
|
||||
xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'")
|
||||
<< html::CR();
|
||||
if (haveLTCaption()) {
|
||||
xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'");
|
||||
xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'")
|
||||
<< html::CR();
|
||||
for (row_type r = 0; r < nrows(); ++r)
|
||||
if (row_info[r].caption)
|
||||
ret += xhtmlRow(xs, r, runparams);
|
||||
xs << html::EndTag("div");
|
||||
xs << html::EndTag("div") << html::CR();
|
||||
}
|
||||
}
|
||||
|
||||
xs << html::StartTag("table");
|
||||
xs << html::StartTag("table") << html::CR();
|
||||
|
||||
// output header info
|
||||
bool const havefirsthead = haveLTFirstHead();
|
||||
@ -2936,40 +2936,42 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
|
||||
// in XHTML. this test accomplishes that.
|
||||
bool const havehead = !havefirsthead && haveLTHead();
|
||||
if (havehead || havefirsthead) {
|
||||
xs << html::StartTag("thead");
|
||||
xs << html::StartTag("thead") << html::CR();
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if ((havefirsthead && row_info[r].endfirsthead)
|
||||
|| (havehead && row_info[r].endhead)) {
|
||||
ret += xhtmlRow(xs, r, runparams, true);
|
||||
}
|
||||
}
|
||||
xs << html::EndTag("thead");
|
||||
xs << html::EndTag("thead") << html::CR();
|
||||
}
|
||||
// output footer info
|
||||
bool const havelastfoot = haveLTLastFoot();
|
||||
// as before.
|
||||
bool const havefoot = !havelastfoot && haveLTFoot();
|
||||
if (havefoot || havelastfoot) {
|
||||
xs << html::StartTag("tfoot");
|
||||
xs << html::StartTag("tfoot") << html::CR();
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if ((havelastfoot && row_info[r].endlastfoot)
|
||||
|| (havefoot && row_info[r].endfoot)) {
|
||||
ret += xhtmlRow(xs, r, runparams);
|
||||
}
|
||||
}
|
||||
xs << html::EndTag("tfoot");
|
||||
xs << html::EndTag("tfoot") << html::CR();
|
||||
}
|
||||
|
||||
xs << html::StartTag("tbody");
|
||||
xs << html::StartTag("tbody") << html::CR();
|
||||
for (row_type r = 0; r < nrows(); ++r) {
|
||||
if (isValidRow(r)) {
|
||||
ret += xhtmlRow(xs, r, runparams);
|
||||
}
|
||||
}
|
||||
xs << html::EndTag("tbody")
|
||||
<< html::EndTag("table");
|
||||
<< html::CR()
|
||||
<< html::EndTag("table")
|
||||
<< html::CR();
|
||||
if (is_long_tabular)
|
||||
xs << html::EndTag("div");
|
||||
xs << html::EndTag("div") << html::CR();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2154,8 +2154,8 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
|
||||
FileName const & mathimg = pimage->filename();
|
||||
xs << html::StartTag(tag)
|
||||
<< html::CompTag("img", "src=\"" + mathimg.onlyFileName() + "\"")
|
||||
<< html::EndTag(tag);
|
||||
xs.cr();
|
||||
<< html::EndTag(tag)
|
||||
<< html::CR();
|
||||
// add the file to the list of files to be exported
|
||||
op.exportdata->addExternalFile("xhtml", mathimg);
|
||||
success = true;
|
||||
@ -2182,8 +2182,8 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
|
||||
xs << html::StartTag(tag, "class='math'")
|
||||
<< XHTMLStream::ESCAPE_AND
|
||||
<< latex
|
||||
<< html::EndTag(tag);
|
||||
xs.cr();
|
||||
<< html::EndTag(tag)
|
||||
<< html::CR();
|
||||
}
|
||||
return docstring();
|
||||
}
|
||||
|
@ -948,7 +948,7 @@ void extractLims(MathData & ar)
|
||||
|
||||
void extractStructure(MathData & ar, ExternalMath kind)
|
||||
{
|
||||
//lyxerr << "\nStructure from: " << ar << endl;
|
||||
lyxerr << "\nStructure from: " << ar << endl;
|
||||
if (kind != MATHML && kind != HTML)
|
||||
splitScripts(ar);
|
||||
extractDelims(ar);
|
||||
@ -965,7 +965,7 @@ void extractStructure(MathData & ar, ExternalMath kind)
|
||||
extractLims(ar);
|
||||
extractStrings(ar);
|
||||
}
|
||||
//lyxerr << "\nStructure to: " << ar << endl;
|
||||
lyxerr << "\nStructure to: " << ar << endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,13 +197,6 @@ XHTMLStream::XHTMLStream(odocstream & os)
|
||||
{}
|
||||
|
||||
|
||||
void XHTMLStream::cr()
|
||||
{
|
||||
// tabs?
|
||||
os_ << from_ascii("\n");
|
||||
}
|
||||
|
||||
|
||||
void XHTMLStream::writeError(std::string const & s)
|
||||
{
|
||||
LYXERR0(s);
|
||||
@ -326,7 +319,15 @@ XHTMLStream & XHTMLStream::operator<<(html::CompTag const & tag)
|
||||
clearTagDeque();
|
||||
// tabs?
|
||||
os_ << tag.asTag();
|
||||
cr();
|
||||
*this << html::CR();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
XHTMLStream & XHTMLStream::operator<<(html::CR const &)
|
||||
{
|
||||
// tabs?
|
||||
os_ << from_ascii("\n");
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -612,7 +613,7 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
|
||||
// FIXME We should see if there's a label to be output and
|
||||
// do something with it.
|
||||
if (par != pbegin)
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
|
||||
// If we are already in a paragraph, and this is the first one, then we
|
||||
// do not want to open the paragraph tag.
|
||||
@ -637,11 +638,10 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
|
||||
|| (!opened && runparams.html_in_par && par == pbegin && nextpar != pend);
|
||||
if (needclose) {
|
||||
closeTag(xs, lay);
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
}
|
||||
if (!deferred.empty()) {
|
||||
xs << XHTMLStream::ESCAPE_NONE << deferred;
|
||||
xs.cr();
|
||||
xs << XHTMLStream::ESCAPE_NONE << deferred << html::CR();
|
||||
}
|
||||
}
|
||||
return pend;
|
||||
@ -657,12 +657,12 @@ ParagraphList::const_iterator makeBibliography(Buffer const & buf,
|
||||
{
|
||||
// FIXME XHTML
|
||||
// Use TextClass::htmlTOCLayout() to figure out how we should look.
|
||||
xs << html::StartTag("h2", "class='bibliography'");
|
||||
xs << pbegin->layout().labelstring(false);
|
||||
xs << html::EndTag("h2");
|
||||
xs.cr();
|
||||
xs << html::StartTag("h2", "class='bibliography'")
|
||||
<< pbegin->layout().labelstring(false);
|
||||
<< html::EndTag("h2");
|
||||
xs << html::CR();
|
||||
xs << html::StartTag("div", "class='bibliography'");
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
makeParagraphs(buf, xs, runparams, text, pbegin, pend);
|
||||
xs << html::EndTag("div");
|
||||
return pend;
|
||||
@ -690,7 +690,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
|
||||
|
||||
// open tag for this environment
|
||||
openTag(xs, bstyle);
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
|
||||
// we will on occasion need to remember a layout from before.
|
||||
Layout const * lastlay = 0;
|
||||
@ -747,20 +747,20 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
|
||||
xs << lbl;
|
||||
closeLabelTag(xs, style);
|
||||
}
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
}
|
||||
} else { // some kind of list
|
||||
if (style.labeltype == LABEL_MANUAL) {
|
||||
openLabelTag(xs, style);
|
||||
sep = par->firstWordLyXHTML(xs, runparams);
|
||||
closeLabelTag(xs, style);
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
}
|
||||
else {
|
||||
openLabelTag(xs, style);
|
||||
xs << par->params().labelString();
|
||||
closeLabelTag(xs, style);
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
}
|
||||
}
|
||||
} // end label output
|
||||
@ -784,7 +784,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
|
||||
lastlay = &style;
|
||||
} else
|
||||
closeItemTag(xs, style);
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
}
|
||||
// The other possibility is that the depth has increased, in which
|
||||
// case we need to recurse.
|
||||
@ -814,7 +814,7 @@ ParagraphList::const_iterator makeEnvironmentHtml(Buffer const & buf,
|
||||
if (lastlay != 0)
|
||||
closeItemTag(xs, *lastlay);
|
||||
closeTag(xs, bstyle);
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
return pend;
|
||||
}
|
||||
|
||||
@ -845,7 +845,7 @@ void makeCommand(Buffer const & buf,
|
||||
pbegin->simpleLyXHTMLOnePar(buf, xs, runparams,
|
||||
text.outerFont(distance(begin, pbegin)));
|
||||
closeTag(xs, style);
|
||||
xs.cr();
|
||||
xs << html::CR();
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
@ -83,6 +83,9 @@ struct CompTag {
|
||||
std::string attr_;
|
||||
};
|
||||
|
||||
// trivial struct for output of newlines
|
||||
struct CR{};
|
||||
|
||||
} // namespace html
|
||||
|
||||
class XHTMLStream {
|
||||
@ -90,8 +93,6 @@ public:
|
||||
///
|
||||
explicit XHTMLStream(odocstream & os);
|
||||
///
|
||||
void cr();
|
||||
///
|
||||
odocstream & os() { return os_; }
|
||||
///
|
||||
// int & tab() { return tab_; }
|
||||
@ -117,6 +118,8 @@ public:
|
||||
///
|
||||
XHTMLStream & operator<<(html::CompTag const &);
|
||||
///
|
||||
XHTMLStream & operator<<(html::CR const &);
|
||||
///
|
||||
enum EscapeSettings {
|
||||
ESCAPE_NONE,
|
||||
ESCAPE_AND, // meaning &
|
||||
|
Loading…
Reference in New Issue
Block a user