X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput_xhtml.cpp;h=037988ba69e684ef1a86ddb65fa81601e57c62e3;hb=5fd21db9d4ed2fab4c76f1c9c95ddfa068690208;hp=585ee2cb34e5c5b7d387275b6fee9b56bae73709;hpb=b3ab0190c1d8baa1f9c77bd8fb0fb0d5001cfe13;p=lyx.git diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 585ee2cb34..037988ba69 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -335,6 +335,10 @@ bool XHTMLStream::closeFontTags() // we haven't had any content return true; +#ifdef XHTML_DEBUG + dumpTagStack("Beging Close Font Tags"); +#endif + // this may be a useless check, since we ought at least to have // the parsep_tag. but it can't hurt too much to be careful. if (tag_stack_.empty()) @@ -347,10 +351,14 @@ bool XHTMLStream::closeFontTags() tag_stack_.pop_back(); // this shouldn't happen, since then the font tags // weren't in any other tag. - LBUFERR(!tag_stack_.empty()); + LASSERT(!tag_stack_.empty(), return true); curtag = tag_stack_.back(); } +#ifdef XHTML_DEBUG + dumpTagStack("End Close Font Tags"); +#endif + if (*curtag == parsep_tag) return true; @@ -373,6 +381,9 @@ void XHTMLStream::startDivision(bool keep_empty) pending_tags_.push_back(makeTagPtr(html::StartTag(parsep_tag))); if (keep_empty) clearTagDeque(); +#ifdef XHTML_DEBUG + dumpTagStack("StartDivision"); +#endif } @@ -390,6 +401,11 @@ void XHTMLStream::endDivision() if (*cur_tag == parsep_tag) break; } + +#ifdef XHTML_DEBUG + dumpTagStack("EndDivision"); +#endif + return; } @@ -408,6 +424,10 @@ void XHTMLStream::endDivision() writeError("Tag `" + cur_tag->tag_ + "' still open at end of paragraph. Closing."); os_ << cur_tag->writeEndTag(); } + +#ifdef XHTML_DEBUG + dumpTagStack("EndDivision"); +#endif } @@ -845,12 +865,28 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf, // (i) the current layout permits multiple paragraphs // (ii) we are either not already inside a paragraph (HTMLIsBlock) OR // we are, but this is not the first paragraph - // But we do not want to open the paragraph tag if this paragraph contains + // + // But there is also a special case, and we first see whether we are in it. + // We do not want to open the paragraph tag if this paragraph contains // only one item, and that item is "inline", i.e., not HTMLIsBlock (such - // as a branch). That is the "special case" we handle first. + // as a branch). On the other hand, if that single item has a font change + // applied to it, then we still do need to open the paragraph. + // + // Obviously, this is very fragile. The main reason we need to do this is + // because of branches, e.g., a branch that contains an entire new section. + // We do not really want to wrap that whole thing in a
...
. + bool special_case = false; Inset const * specinset = par->size() == 1 ? par->getInset(0) : 0; - bool const special_case = - specinset && !specinset->getLayout().htmlisblock(); + if (specinset && !specinset->getLayout().htmlisblock()) { + Layout const & style = par->layout(); + FontInfo const first_font = style.labeltype == LABEL_MANUAL ? + style.labelfont : style.font; + FontInfo const our_font = + par->getFont(buf.masterBuffer()->params(), 0, + text.outerFont(distance(begin, par))).fontInfo(); + if (first_font == our_font) + special_case = true; + } bool const open_par = runparams.html_make_pars && (!runparams.html_in_par || par != pbegin) @@ -878,13 +914,14 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf, runparams, text.outerFont(distance(begin, par)), open_par, close_par); - if (!deferred.empty()) { - xs << XHTMLStream::ESCAPE_NONE << deferred << html::CR(); - } if (close_par) { closeTag(xs, lay); xs << html::CR(); } + + if (!deferred.empty()) { + xs << XHTMLStream::ESCAPE_NONE << deferred << html::CR(); + } } return pend; } @@ -1010,8 +1047,9 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf, if (labelfirst) openItemTag(xs, style, par->params()); - par->simpleLyXHTMLOnePar(buf, xs, runparams, + docstring deferred = par->simpleLyXHTMLOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)), true, true, sep); + xs << XHTMLStream::ESCAPE_NONE << deferred; ++par; // We may not want to close the tag yet, in particular: