mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
Revert "XHTML: remove <section> support."
This reverts commit 52216b73
This commit is contained in:
parent
c8e2c17a58
commit
15dbc2b9ab
@ -590,6 +590,7 @@ void xhtmlParagraphs(Text const & text,
|
|||||||
ParagraphList::const_iterator const pend =
|
ParagraphList::const_iterator const pend =
|
||||||
(epit == (int) paragraphs.size()) ?
|
(epit == (int) paragraphs.size()) ?
|
||||||
paragraphs.end() : paragraphs.iterator_at(epit);
|
paragraphs.end() : paragraphs.iterator_at(epit);
|
||||||
|
std::stack<int> headerLevels;
|
||||||
|
|
||||||
while (bpit < epit) {
|
while (bpit < epit) {
|
||||||
ParagraphList::const_iterator par = paragraphs.iterator_at(bpit);
|
ParagraphList::const_iterator par = paragraphs.iterator_at(bpit);
|
||||||
@ -608,6 +609,33 @@ void xhtmlParagraphs(Text const & text,
|
|||||||
ParagraphList::const_iterator const lastpar = par;
|
ParagraphList::const_iterator const lastpar = par;
|
||||||
ParagraphList::const_iterator send;
|
ParagraphList::const_iterator send;
|
||||||
|
|
||||||
|
// Think about adding <section> and/or </section>s.
|
||||||
|
if (style.category() == from_utf8("Sectioning")) {
|
||||||
|
int level = style.toclevel;
|
||||||
|
|
||||||
|
// Need to close a previous section if it has the same level or a higher one (close <section> if opening a
|
||||||
|
// <h2> after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
|
||||||
|
// - current: h2; back: h1; do not close any <section>
|
||||||
|
// - current: h1; back: h2; close two <section> (first the <h2>, then the <h1>, so a new <h1> can come)
|
||||||
|
while (!headerLevels.empty() && level <= headerLevels.top()) {
|
||||||
|
// Output the tag only if it corresponds to a legit section.
|
||||||
|
int stackLevel = headerLevels.top();
|
||||||
|
if (stackLevel != Layout::NOT_IN_TOC && level > 1) { // <h1> is the document title.
|
||||||
|
xs << xml::EndTag("section");
|
||||||
|
xs << xml::CR();
|
||||||
|
}
|
||||||
|
headerLevels.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open the new section: first push it onto the stack, then output it in XHTML.
|
||||||
|
headerLevels.push(level);
|
||||||
|
// Some sectioning-like elements should not be output (such as FrontMatter).
|
||||||
|
if (level != Layout::NOT_IN_TOC && level > 1) { // <h1> is the document title.
|
||||||
|
xs << xml::StartTag("section");
|
||||||
|
xs << xml::CR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (style.latextype) {
|
switch (style.latextype) {
|
||||||
case LATEX_COMMAND: {
|
case LATEX_COMMAND: {
|
||||||
// The files with which we are working never have more than
|
// The files with which we are working never have more than
|
||||||
@ -644,6 +672,15 @@ void xhtmlParagraphs(Text const & text,
|
|||||||
}
|
}
|
||||||
bpit += distance(lastpar, par);
|
bpit += distance(lastpar, par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If need be, close <section>s, but only at the end of the document (otherwise, dealt with at the beginning
|
||||||
|
// of the loop).
|
||||||
|
while (!headerLevels.empty() && headerLevels.top() > Layout::NOT_IN_TOC) {
|
||||||
|
docstring tag = from_utf8("</section>");
|
||||||
|
headerLevels.pop();
|
||||||
|
xs << XMLStream::ESCAPE_NONE << tag;
|
||||||
|
xs << xml::CR();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user