X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput_xhtml.cpp;h=080369f104e935535a2be7e6a548416584717b29;hb=175711046db2b986550318fa78d901628de28cb8;hp=252b1d1705be20ad7411c3588b589f8ecd99372e;hpb=0a603c5d0e370c8b9c9e0f5dfa024b6e500b2dd4;p=lyx.git diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 252b1d1705..080369f104 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -172,6 +172,7 @@ string fontToTag(html::FontTypes type) case FT_DBAR: return "u"; case FT_SOUT: + case FT_XOUT: return "del"; case FT_ITALIC: return "i"; @@ -211,6 +212,7 @@ string fontToAttribute(html::FontTypes type) return ""; case FT_DBAR: return "class='dline'"; + case FT_XOUT: case FT_SOUT: return "class='strikeout'"; case FT_WAVE: @@ -326,7 +328,7 @@ void XHTMLStream::writeError(std::string const & s) const namespace { // an illegal tag for internal use static html::StartTag const parsep_tag("&LyX_parsep_tag&"); -} +} // namespace bool XHTMLStream::closeFontTags() @@ -335,6 +337,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()) @@ -351,6 +357,10 @@ bool XHTMLStream::closeFontTags() curtag = tag_stack_.back(); } +#ifdef XHTML_DEBUG + dumpTagStack("End Close Font Tags"); +#endif + if (*curtag == parsep_tag) return true; @@ -373,6 +383,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 +403,11 @@ void XHTMLStream::endDivision() if (*cur_tag == parsep_tag) break; } + +#ifdef XHTML_DEBUG + dumpTagStack("EndDivision"); +#endif + return; } @@ -408,6 +426,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 +867,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 - // only one item, and that item is "inline", i.e., not HTMLIsBlock (such - // as a branch). That is the "special case" we handle first. + // + // 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). 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) @@ -868,13 +906,13 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf, || (!open_par && runparams.html_in_par && par == pbegin && nextpar != pend); if (open_par) { - // We do not issue the paragraph id if we are doing + // We do not issue the paragraph id if we are doing // this for the TOC (or some similar purpose) openParTag(xs, lay, par->params(), runparams.for_toc ? "" : par->magicLabel()); } - docstring const deferred = par->simpleLyXHTMLOnePar(buf, xs, + docstring const deferred = par->simpleLyXHTMLOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)), open_par, close_par); @@ -1075,24 +1113,14 @@ void makeCommand(Buffer const & buf, documentClass().counters().step(style.counter, OutputUpdate); bool const make_parid = !runparams.for_toc && runparams.html_make_pars; - - if (style.labeltype == LABEL_ABOVE) - xs << html::StartTag("div") - << pbegin->params().labelString() - << html::EndTag("div"); - else if (style.labeltype == LABEL_CENTERED) - xs << html::StartTag("div", "style = \"text-align: center;\"") - << pbegin->params().labelString() - << html::EndTag("div"); openParTag(xs, style, pbegin->params(), make_parid ? pbegin->magicLabel() : ""); // Label around sectioning number: // FIXME Probably need to account for LABEL_MANUAL - if (style.labeltype != LABEL_NO_LABEL && - style.labeltype != LABEL_ABOVE && - style.labeltype != LABEL_CENTERED ) { + // FIXME Probably also need now to account for labels ABOVE and CENTERED. + if (style.labeltype != LABEL_NO_LABEL) { openLabelTag(xs, style); xs << pbegin->params().labelString(); closeLabelTag(xs, style);