From: Thibaut Cuvelier Date: Thu, 27 Jul 2023 01:12:56 +0000 (+0200) Subject: XHTML: remove deferred text in InsetListings, fixing 12007. X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9a163399fb995e8d1bbcfbac8d444140ab1e1f8c;p=features.git XHTML: remove deferred text in InsetListings, fixing 12007. --- diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index fa3834063f..bd61986243 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -440,48 +440,42 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const docstring InsetListings::xhtml(XMLStream & os, OutputParams const & rp) const { - odocstringstream ods; - XMLStream out(ods); - bool const isInline = params().isInline(); if (isInline) - out << xml::CompTag("br"); + os << xml::CompTag("br"); else { - out << xml::StartTag("div", "class='float-listings'"); + os << xml::StartTag("div", "class='float-listings'"); docstring caption = getCaptionHTML(rp); if (!caption.empty()) - out << xml::StartTag("div", "class='listings-caption'") - << XMLStream::ESCAPE_NONE - << caption << xml::EndTag("div"); + os << xml::StartTag("div", "class='listings-caption'") + << XMLStream::ESCAPE_NONE + << caption << xml::EndTag("div"); } - InsetLayout const & il = getLayout(); - string const & tag = il.htmltag(); - string attr = "class ='listings"; + string const & tag = getLayout().htmltag(); + string attr = "class='listings"; string const lang = params().getParamValue("language"); if (!lang.empty()) attr += " " + lang; attr += "'"; - out << xml::StartTag(tag, attr); + os << xml::StartTag(tag, attr); OutputParams newrp = rp; newrp.html_disable_captions = true; // We don't want to convert dashes here. That's the only conversion we // do for XHTML, so this is safe. newrp.pass_thru = true; - docstring def = InsetText::insetAsXHTML(out, newrp, InsetText::JustText); - out << xml::EndTag(tag); + docstring def = InsetText::insetAsXHTML(os, newrp, InsetText::JustText); + os << xml::EndTag(tag); if (isInline) { - out << xml::CompTag("br"); - // escaping will already have been done - os << XMLStream::ESCAPE_NONE << ods.str(); + os << xml::CompTag("br"); } else { - out << xml::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; + if (!def.empty()) { + os << '\n' << def; + } + os << xml::EndTag("div"); } - return def; + return {}; }