mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
DocBook: fix line issues around programlisting.
This commit is contained in:
parent
9d3a717ef1
commit
654559feb8
@ -5,6 +5,5 @@
|
||||
<title>Test document</title>
|
||||
<para>This is a programlisting: </para>
|
||||
<programlisting>First line of programlisting
|
||||
Second line of programlisting
|
||||
</programlisting>
|
||||
Second line of programlisting</programlisting>
|
||||
</article>
|
@ -3332,7 +3332,8 @@ std::tuple<vector<xml::FontTag>, vector<xml::EndFontTag>> computeDocBookFontSwit
|
||||
std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
|
||||
OutputParams const & runparams,
|
||||
Font const & outerfont,
|
||||
pos_type initial) const
|
||||
pos_type initial,
|
||||
bool is_last_par) const
|
||||
{
|
||||
// Track whether we have opened these tags
|
||||
DocBookFontState fs;
|
||||
@ -3409,7 +3410,9 @@ std::vector<docstring> Paragraph::simpleDocBookOnePar(Buffer const & buf,
|
||||
// I'm worried about what happens if a branch, say, is itself
|
||||
// wrapped in some font stuff. I think that will not work.
|
||||
xs->closeFontTags();
|
||||
if (runparams.docbook_in_listing)
|
||||
|
||||
// In listings, new lines are very important. Avoid generating one for the last line.
|
||||
if (runparams.docbook_in_listing && !is_last_par)
|
||||
*xs << xml::CR();
|
||||
|
||||
// Finalise the last (and most likely only) paragraph.
|
||||
|
@ -213,7 +213,8 @@ public:
|
||||
std::vector<docstring> simpleDocBookOnePar(Buffer const & buf,
|
||||
OutputParams const & runparams,
|
||||
Font const & outerfont,
|
||||
pos_type initial = 0) const;
|
||||
pos_type initial = 0,
|
||||
bool is_last_par = false) const;
|
||||
|
||||
/// \return any material that has had to be deferred until after the
|
||||
/// paragraph has closed.
|
||||
|
@ -485,6 +485,9 @@ void InsetListings::docbook(XMLStream & xs, OutputParams const & rp) const
|
||||
{
|
||||
InsetLayout const & il = getLayout();
|
||||
|
||||
if (!xs.isLastTagCR())
|
||||
xs << xml::CR();
|
||||
|
||||
// Forge the attributes.
|
||||
string attrs;
|
||||
if (!il.docbookattr().empty())
|
||||
@ -517,6 +520,7 @@ void InsetListings::docbook(XMLStream & xs, OutputParams const & rp) const
|
||||
// Done with the listing.
|
||||
xs.endDivision();
|
||||
xs << xml::EndTag(il.docbooktag());
|
||||
xs << xml::CR();
|
||||
}
|
||||
|
||||
|
||||
|
@ -504,8 +504,6 @@ void makeParagraph(
|
||||
// or we're not in the last paragraph, anyway.
|
||||
// (ii) We didn't open it and docbook_in_par is true,
|
||||
// but we are in the first par, and there is a next par.
|
||||
auto nextpar = par;
|
||||
++nextpar;
|
||||
bool const close_par = open_par && (!runparams.docbook_in_par);
|
||||
|
||||
// Determine if this paragraph has some real content. Things like new pages are not caught
|
||||
@ -513,7 +511,9 @@ void makeParagraph(
|
||||
// Thus, remove all spaces (including new lines: \r, \n) before checking for emptiness.
|
||||
// std::all_of allows doing this check without having to copy the string.
|
||||
// Open and close tags around each contained paragraph.
|
||||
auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0);
|
||||
auto nextpar = par;
|
||||
++nextpar;
|
||||
auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end);
|
||||
for (auto & parXML : pars) {
|
||||
if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) {
|
||||
if (open_par)
|
||||
|
Loading…
Reference in New Issue
Block a user