Dear list, Subject: https://www.lyx.org/trac/ticket/12372
In the last few weeks, I've been working on a fix for #12372. Basically, the user complained that some random LaTeX code is not properly rendered in the DocBook output. The problem is that this is really arbitrary LaTeX code quite remote from what DocBook can natively encode: even if you write a parser for this, you could not encode it into DocBook. As a reminder, the current ePub output is based on DocBook, so it's quite important to have as many things output properly in DocBook (that's the origin of the user request, after all). The only solution I could find is to use the existing mechanism to generate preview images. This way, the LaTeX code is transformed into an intelligible form (i.e. an image), while still keeping the original LaTeX code if someone wants to modify the image without access to the original LyX document (this property is quite important to me). The implementation does not rely directly on InsetPreview, because I don't want to force users to have previews to have content shown into their DocBook file. Instead, I refactored part of this code to be able to reuse it in other parts of the code. Specific layouts can opt into the mechanism to have their contents transformed into an image when outputting DocBook. Currently, this is only used for this tree layout, but I believe more layouts could benefit from this (otherwise, I wouldn't have implemented anything). What do you think of the attached patch? I tried to avoid copy-paste as much as possible between users of the preview functionality. All the best, Thibaut
From aee23686df74605e10dcbb21d5aa5e6665a2eb88 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Mon, 27 Sep 2021 03:30:45 +0200 Subject: [PATCH 1/8] DocBook: add the DocBookRenderAsImage tag. --- lib/layouts/linguistics.module | 1 + lib/scripts/layout2layout.py | 7 +++++-- src/TextClass.cpp | 2 +- src/insets/InsetLayout.cpp | 5 +++++ src/insets/InsetLayout.h | 4 ++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/layouts/linguistics.module b/lib/layouts/linguistics.module index afbc7331a9..3405748a23 100644 --- a/lib/layouts/linguistics.module +++ b/lib/layouts/linguistics.module @@ -276,6 +276,7 @@ InsetLayout Flex:Structure_Tree \useforestlibrary*{linguistics} }{} EndPreamble + DocBookRenderAsImage true End diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index e7eb307d56..7e40bfbe12 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -11,7 +11,7 @@ # This script will update a .layout file to current format # The latest layout format is also defined in src/TextClass.cpp -currentFormat = 94 +currentFormat = 95 # Incremented to format 4, 6 April 2007, lasgouttes @@ -319,6 +319,9 @@ currentFormat = 94 # Incremented to format 94, 19 September 2021 by tcuvelier # Add DocBookFloatType, DocBookCaption +# Incremented to format 95, 27 September 2021 by tcuvelier +# Add DocBookRenderAsImage + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). @@ -569,7 +572,7 @@ def convert(lines, end_format): i += 1 continue - if 87 <= format <= 94: + if 87 <= format <= 95: # nothing to do. i += 1 continue diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 9546cee961..a04a6f6f1a 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -59,7 +59,7 @@ namespace lyx { // You should also run the development/tools/updatelayouts.py script, // to update the format of all of our layout files. // -int const LAYOUT_FORMAT = 94; // tcuvelier: DocBookFloatType, DocBookCaption +int const LAYOUT_FORMAT = 95; // tcuvelier: DocBookRenderAsImage // Layout format for the current lyx file format. Controls which format is diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index 769a77402b..64258a8483 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -111,6 +111,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, IL_DOCBOOKINNERTAGTYPE, IL_DOCBOOKINNERATTR, IL_DOCBOOKNOFONTINSIDE, + IL_DOCBOOKRENDERASIMAGE, IL_INTOC, IL_ISTOCCAPTION, IL_LABELFONT, @@ -170,6 +171,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, { "docbookitemwrappertagtype", IL_DOCBOOKITEMWRAPPERTAGTYPE }, { "docbooknofontinside", IL_DOCBOOKNOFONTINSIDE }, { "docbooknotinpara", IL_DOCBOOKNOTINPARA }, + { "docbookrenderasimage", IL_DOCBOOKRENDERASIMAGE }, { "docbooksection", IL_DOCBOOKSECTION }, { "docbooktag", IL_DOCBOOKTAG }, { "docbooktagtype", IL_DOCBOOKTAGTYPE }, @@ -580,6 +582,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, break; case IL_DOCBOOKNOFONTINSIDE: lex >> docbooknofontinside_; + break; + case IL_DOCBOOKRENDERASIMAGE: + lex >> docbookrenderasimage_; break; case IL_REQUIRES: { lex.eatLine(); diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index da003a95b0..ed3c9a96ba 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -192,6 +192,8 @@ public: /// bool docbooknofontinside() const { return docbooknofontinside_; } /// + bool docbookrenderasimage() const { return docbookrenderasimage_; } + /// std::set<std::string> required() const { return required_; } /// bool isMultiPar() const { return multipar_; } @@ -361,6 +363,8 @@ private: /// bool docbooknofontinside_ = false; /// + bool docbookrenderasimage_ = false; + /// std::set<std::string> required_; /// bool multipar_ = true; -- 2.30.1.windows.1
From be1d6ecd38e702639c5c78bf3cecb0d6f19de8fa Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Wed, 13 Oct 2021 03:01:54 +0200 Subject: [PATCH 7/8] Factor out the generation of the code to create a preview. This will be soon reused in InsetText to generate images for DocBook. --- src/insets/InsetPreview.cpp | 16 +++++++++++----- src/insets/InsetPreview.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/insets/InsetPreview.cpp b/src/insets/InsetPreview.cpp index e08fdcd39b..c4f1b8d83d 100644 --- a/src/insets/InsetPreview.cpp +++ b/src/insets/InsetPreview.cpp @@ -107,19 +107,25 @@ MacroNameSet gatherMacroDefinitions(const Buffer* buffer, const Inset * inset) } -void InsetPreview::preparePreview(DocIterator const & pos) const +docstring insetToLaTeXSnippet(const Buffer* buffer, const Inset * inset) { odocstringstream str; otexstream os(str); - OutputParams runparams(&pos.buffer()->params().encoding()); - latex(os, runparams); + OutputParams runparams(&buffer->params().encoding()); + inset->latex(os, runparams); - MacroNameSet defs = gatherMacroDefinitions(pos.buffer(), this); + MacroNameSet defs = gatherMacroDefinitions(buffer, inset); docstring macro_preamble; for (const auto& def : defs) macro_preamble.append(def); - docstring const snippet = macro_preamble + str.str(); + return macro_preamble + str.str(); +} + + +void InsetPreview::preparePreview(DocIterator const & pos) const +{ + docstring const snippet = insetToLaTeXSnippet(pos.buffer(), this); preview_->addPreview(snippet, *pos.buffer()); } diff --git a/src/insets/InsetPreview.h b/src/insets/InsetPreview.h index 55353e72d7..db2a2af96b 100644 --- a/src/insets/InsetPreview.h +++ b/src/insets/InsetPreview.h @@ -90,6 +90,8 @@ protected: /// gathers the list of macro definitions used in the given inset MacroNameSet gatherMacroDefinitions(const Buffer* buffer, const Inset * inset); +/// returns the LaTeX snippet to compute the preview of the given inset +docstring insetToLaTeXSnippet(const Buffer* buffer, const Inset * inset); } // namespace lyx -- 2.30.1.windows.1
From 15fd9dfa3cbfd7fc0475d9763eaea508ecfb988a Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Thu, 7 Oct 2021 00:07:21 +0200 Subject: [PATCH 2/8] DocBook: don't use a surrounding <para> for rendered insets. --- src/output_docbook.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 114c258304..50b66fbac0 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -360,11 +360,13 @@ void makeParagraph( // Plain layouts must be ignored. special_case |= buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars; + // Equations do not deserve their own paragraph (DocBook allows them outside paragraphs). // Exception: any case that generates an <inlineequation> must still get a paragraph to be valid. - special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) { + auto isEquationSpecialCase = [](InsetList::Element inset) { return inset.inset && inset.inset->asInsetMath() && inset.inset->asInsetMath()->getType() != hullSimple; - }); + }; + special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), isEquationSpecialCase); // Things that should not get into their own paragraph. (Only valid for DocBook.) static std::set<InsetCode> lyxCodeSpecialCases = { @@ -420,6 +422,12 @@ void makeParagraph( }; special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), isFlexSpecialCase); + // If the insets should be rendered as images, enter the special case. + auto isRenderedAsImageSpecialCase = [](InsetList::Element inset) { + return inset.inset && inset.inset->getLayout().docbookrenderasimage(); + }; + special_case |= nInsets == parSize && std::all_of(par->insetList().begin(), par->insetList().end(), isRenderedAsImageSpecialCase); + // Open a paragraph if it is allowed, we are not already within a paragraph, and the insets in the paragraph do // not forbid paragraphs (aka special cases). bool const open_par = runparams.docbook_make_pars -- 2.30.1.windows.1
From f18c984ac4d408deb2dcc2d8d8d9d4ef172b0673 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Wed, 13 Oct 2021 03:02:19 +0200 Subject: [PATCH 8/8] DocBook: generate images for layouts that request it. --- src/insets/InsetText.cpp | 45 ++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 5dad3ab7c4..8c2b2c49cc 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -10,11 +10,16 @@ #include <config.h> -#include "InsetLayout.h" #include "InsetText.h" +#include "mathed/MacroTable.h" + #include "insets/InsetArgument.h" #include "insets/InsetLayout.h" +#include "insets/InsetPreview.h" + +#include "graphics/PreviewImage.h" +#include "graphics/PreviewLoader.h" #include "buffer_funcs.h" #include "Buffer.h" @@ -26,6 +31,7 @@ #include "CutAndPaste.h" #include "DispatchResult.h" #include "ErrorList.h" +#include "Exporter.h" #include "FuncRequest.h" #include "FuncStatus.h" #include "InsetList.h" @@ -61,6 +67,7 @@ #include "support/lassert.h" #include "support/lstrings.h" #include "support/Changer.h" +#include "support/FileName.h" #include <algorithm> #include <stack> @@ -72,9 +79,6 @@ using namespace lyx::support; namespace lyx { -using graphics::PreviewLoader; - - ///////////////////////////////////////////////////////////////////// InsetText::InsetText(Buffer * buf, UsePlain type) @@ -628,8 +632,9 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op InsetLayout const &il = getLayout(); - // Maybe this is an <info> paragraph that should not be generated at all (i.e. right now, its place is somewhere - // else, typically outside the current paragraph). + // Maybe this is an <info> paragraph that should not be generated + // at all (i.e. right now, its place is somewhere else, typically outside + // the current paragraph). if (!rp.docbook_generate_info && il.docbookininfo() != "never") return; @@ -648,14 +653,36 @@ void InsetText::docbookRenderAsImage(XMLStream & xs, OutputParams const & rp, XH { LASSERT(getLayout().docbookrenderasimage(), return); + // Generate the LaTeX code to compile in order to get the image. + // This code actually does the same as an InsetPreview, but without + // an InsetPreview. + // Also, the image must be generated before the DocBook output is finished, + // unlike a preview that is not immediately required for display. + docstring const latex_snippet = insetToLaTeXSnippet(&buffer(), this); + std::string const snippet = support::trim(to_utf8(latex_snippet)); + // TODO: no real support for Unicode. This code is very similar to RenderPreview::addPreview, the same gotcha applies. + + graphics::PreviewLoader* loader = buffer().loader(); + loader->add(snippet); + loader->startLoading(true); // Generate the image and wait until done. + graphics::PreviewImage const * img = loader->preview(snippet); + LASSERT(img != nullptr, return); + support::FileName const & filename = img->filename(); + + // Copy the image into the right folder. + rp.exportdata->addExternalFile("docbook", filename, filename.onlyFileName()); + // TODO: deal with opts. What exactly is the WriterOuterTag here, for instance? + // Start writing the DocBook code for the image. xs << xml::StartTag("mediaobject") << xml::CR(); // Output the rendered inset. xs << xml::StartTag("imageobject") - << xml::CR(); - xs << xml::EndTag("imageobject") + << xml::CR() + << xml::StartTag("imagedata", std::string("fileref='") + filename.onlyFileName() + "'") + << xml::CR() + << xml::EndTag("imageobject") << xml::CR(); // Output the raw content. @@ -944,7 +971,7 @@ void InsetText::appendParagraphs(ParagraphList & plist) void InsetText::addPreview(DocIterator const & text_inset_pos, - PreviewLoader & loader) const + graphics::PreviewLoader & loader) const { ParagraphList::const_iterator pit = paragraphs().begin(); ParagraphList::const_iterator pend = paragraphs().end(); -- 2.30.1.windows.1
From 5997d83204a69d36643f1d2534b42fcec48024b7 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Thu, 7 Oct 2021 02:27:54 +0200 Subject: [PATCH 3/8] DocBook: overall structure for rendered insets. --- src/insets/InsetText.cpp | 53 ++++++++++++++++++++++++++++++++++++---- src/insets/InsetText.h | 8 ++++-- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 635a83f7f7..5dad3ab7c4 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -606,7 +606,6 @@ int InsetText::plaintext(odocstringstream & os, } - void InsetText::docbook(XMLStream & xs, OutputParams const & rp) const { docbook(xs, rp, WriteEverything); @@ -615,8 +614,7 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp) const void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions opts) const { - // we will always want to output all our paragraphs when we are - // called this way. + // Always output all the paragraphs. OutputParams runparams = rp; runparams.par_begin = 0; runparams.par_end = text().paragraphs().size(); @@ -628,13 +626,58 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op return; } - InsetLayout const & il = getLayout(); + InsetLayout const &il = getLayout(); // Maybe this is an <info> paragraph that should not be generated at all (i.e. right now, its place is somewhere // else, typically outside the current paragraph). if (!rp.docbook_generate_info && il.docbookininfo() != "never") return; + // Maybe this inset must be rendered before being output. + if (il.docbookrenderasimage()) { + docbookRenderAsImage(xs, runparams, opts); + return; + } + + // If none of the special cases before apply, output the inset. + docbookText(xs, runparams, opts); +} + + +void InsetText::docbookRenderAsImage(XMLStream & xs, OutputParams const & rp, XHTMLOptions opts) const +{ + LASSERT(getLayout().docbookrenderasimage(), return); + + // TODO: deal with opts. What exactly is the WriterOuterTag here, for instance? + xs << xml::StartTag("mediaobject") + << xml::CR(); + + // Output the rendered inset. + xs << xml::StartTag("imageobject") + << xml::CR(); + xs << xml::EndTag("imageobject") + << xml::CR(); + + // Output the raw content. + xs << xml::StartTag("textobject") + << xml::CR() + << xml::StartTag("programlisting", "language='latex' role='" + getLayout().latexname() + "'"); + docbookText(xs, rp, opts); + xs << xml::EndTag("programlisting") + << xml::CR() + << xml::EndTag("textobject") + << xml::CR(); + + xs << xml::EndTag("mediaobject") + << xml::CR(); +} + + +void InsetText::docbookText(XMLStream & xs, OutputParams const & rp, XHTMLOptions opts) const +{ + InsetLayout const &il = getLayout(); + OutputParams runparams = rp; + // In some cases, the input parameters must be overridden for outer tags. bool writeOuterTag = opts & WriteOuterTag; if (writeOuterTag) { @@ -667,7 +710,7 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op if (par.getInset(i) && par.getInset(i)->lyxCode() == ARG_CODE) { InsetArgument const *arg = par.getInset(i)->asInsetArgument(); if (arg->docbookargumentaftermaintag()) - appendedArguments.insert(par.getInset(i)->asInsetArgument()); + appendedArguments.insert(par.getInset(i)->asInsetArgument()); } } } diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 29457aad99..564702cd98 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -93,9 +93,9 @@ public: /// docstring insetAsXHTML(XMLStream &, OutputParams const &, XHTMLOptions) const; - /// + /// Outputs the inset as DocBook, with the given options regarding outer tags. void docbook(XMLStream &, OutputParams const &, XHTMLOptions opts) const; - /// + /// Outputs the whole inset as DocBook. void docbook(XMLStream &, OutputParams const &) const override; /// void validate(LaTeXFeatures & features) const override; @@ -238,6 +238,10 @@ protected: /// void iterateForToc(DocIterator const & cdit, bool output_active, UpdateType utype, TocBackend & backend) const; + /// Outputs an inset that must be first rendered (with the given options regarding outer tags). + void docbookRenderAsImage(XMLStream & xs, OutputParams const & rp, XHTMLOptions opts) const; + /// Outputs the text of the inset with the correct DocBook tags (with the given options regarding outer tags). + void docbookText(XMLStream & xs, OutputParams const & rp, XHTMLOptions opts) const; private: /// Open the toc item for paragraph pit. Returns the paragraph index where /// it should end. -- 2.30.1.windows.1
From 97794014173c051b5ada71b50a9de7b716c01df3 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Thu, 7 Oct 2021 02:34:07 +0200 Subject: [PATCH 4/8] DocBook: add assertion to help debugging. --- src/output_docbook.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 50b66fbac0..e234d9d652 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -754,6 +754,8 @@ DocBookDocumentSectioning hasDocumentSectioning(ParagraphList const ¶graphs, bool documentHasSections = false; while (bpit < epit) { + LASSERT(bpit < paragraphs.size(), return make_tuple(documentHasSections, bpit)); + Layout const &style = paragraphs[bpit].layout(); documentHasSections |= isLayoutSectioningOrSimilar(style); -- 2.30.1.windows.1
From b0437dd6f387654302f8ed4b57c47382a3982b9b Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Fri, 8 Oct 2021 03:14:18 +0200 Subject: [PATCH 5/8] Factor out the list of macro definitions for InsetPreview. This will be soon reused in InsetText to generate images for DocBook. --- src/DocIterator.h | 4 ++-- src/insets/InsetPreview.cpp | 41 ++++++++++++++++++++++--------------- src/insets/InsetPreview.h | 5 +++++ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/DocIterator.h b/src/DocIterator.h index 5e6ae6c166..cfb31f487f 100644 --- a/src/DocIterator.h +++ b/src/DocIterator.h @@ -28,8 +28,8 @@ class MathAtom; class Paragraph; class Text; -DocIterator doc_iterator_begin(Buffer const * buf, Inset const * inset = 0); -DocIterator doc_iterator_end(Buffer const * buf, Inset const * inset = 0); +DocIterator doc_iterator_begin(Buffer const * buf, Inset const * inset = nullptr); +DocIterator doc_iterator_end(Buffer const * buf, Inset const * inset = nullptr); class DocIterator diff --git a/src/insets/InsetPreview.cpp b/src/insets/InsetPreview.cpp index d1a0343fbc..e08fdcd39b 100644 --- a/src/insets/InsetPreview.cpp +++ b/src/insets/InsetPreview.cpp @@ -79,36 +79,45 @@ void InsetPreview::addPreview(DocIterator const & inset_pos, } -void InsetPreview::preparePreview(DocIterator const & pos) const +MacroNameSet gatherMacroDefinitions(const Buffer* buffer, const Inset * inset) { - odocstringstream str; - otexstream os(str); - OutputParams runparams(&pos.buffer()->params().encoding()); - latex(os, runparams); - - // collect macros at this position + // Collect macros for this inset. + // Not done yet: this function returns a list of macro *definitions*. MacroNameSet macros; - pos.buffer()->listMacroNames(macros); + buffer->listMacroNames(macros); - // look for math insets and collect definitions for the used macros + // Look for math insets and collect definitions for the used macros. MacroNameSet defs; - DocIterator dit = doc_iterator_begin(pos.buffer(), this); - DocIterator const dend = doc_iterator_end(pos.buffer(), this); + DocIterator const dbeg = doc_iterator_begin(buffer, inset); + DocIterator dit = dbeg; + DocIterator const dend = doc_iterator_end(buffer, inset); if (!dit.nextInset()) dit.forwardInset(); + for (; dit != dend; dit.forwardInset()) { InsetMath * im = dit.nextInset()->asInsetMath(); InsetMathHull * hull = im ? im->asHullInset() : nullptr; if (!hull) continue; for (idx_type idx = 0; idx < hull->nargs(); ++idx) - hull->usedMacros(hull->cell(idx), pos, macros, defs); + hull->usedMacros(hull->cell(idx), dbeg, macros, defs); } - MacroNameSet::iterator it = defs.begin(); - MacroNameSet::iterator end = defs.end(); + + return defs; +} + + +void InsetPreview::preparePreview(DocIterator const & pos) const +{ + odocstringstream str; + otexstream os(str); + OutputParams runparams(&pos.buffer()->params().encoding()); + latex(os, runparams); + + MacroNameSet defs = gatherMacroDefinitions(pos.buffer(), this); docstring macro_preamble; - for (; it != end; ++it) - macro_preamble.append(*it); + for (const auto& def : defs) + macro_preamble.append(def); docstring const snippet = macro_preamble + str.str(); preview_->addPreview(snippet, *pos.buffer()); diff --git a/src/insets/InsetPreview.h b/src/insets/InsetPreview.h index f36ea56fa5..55353e72d7 100644 --- a/src/insets/InsetPreview.h +++ b/src/insets/InsetPreview.h @@ -20,6 +20,7 @@ namespace lyx { class Dimension; +class MacroNameSet; class RenderPreview; namespace graphics { @@ -87,6 +88,10 @@ protected: }; +/// gathers the list of macro definitions used in the given inset +MacroNameSet gatherMacroDefinitions(const Buffer* buffer, const Inset * inset); + + } // namespace lyx -- 2.30.1.windows.1
From dfe921986539a4a67b11b160813bbbdda8549822 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Wed, 13 Oct 2021 03:01:11 +0200 Subject: [PATCH 6/8] Typos and comment improvements. --- src/Buffer.cpp | 10 ++++++---- src/insets/RenderPreview.cpp | 2 +- src/output_docbook.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index a713f8dd55..e78a443a88 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2106,8 +2106,7 @@ Buffer::ExportStatus Buffer::makeDocBookFile(FileName const & fname, updateBuffer(); updateMacroInstances(OutputUpdate); - ExportStatus const retval = - writeDocBookSource(ofs, runparams, output); + ExportStatus const retval = writeDocBookSource(ofs, runparams, output); if (retval == ExportKilled) return ExportKilled; @@ -4371,6 +4370,9 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir void Buffer::setMathFlavor(OutputParams & op) const { + // Passes the way to generate formulae to the XHTML output code. + // In particular, this function has no impact on the DocBook code, as it + // uses another mechanism to handle math flavours. switch (params().html_math_output) { case BufferParams::MathML: op.math_flavor = OutputParams::MathAsMathML; @@ -4414,7 +4416,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir Converters converters = theConverters(); bool need_nice_file = false; if (find(backs.begin(), backs.end(), format) == backs.end()) { - // Get shortest path to format + // Get the shortest path to format converters.buildGraph(); Graph::EdgePath path; for (string const & sit : backs) { @@ -4580,7 +4582,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir result_file = changeExtension(d->exportFileName().absFileName(), ext); else result_file = dest_filename; - // We need to copy referenced files (e. g. included graphics + // We need to copy referenced files (e.g. included graphics // if format == "dvi") to the result dir. vector<ExportedFile> const extfiles = runparams.exportdata->externalFiles(format); diff --git a/src/insets/RenderPreview.cpp b/src/insets/RenderPreview.cpp index 5dff4108d1..b0eb1f7838 100644 --- a/src/insets/RenderPreview.cpp +++ b/src/insets/RenderPreview.cpp @@ -123,7 +123,7 @@ graphics::PreviewImage const * RenderPreview::getPreviewImage(Buffer const & buffer) const { graphics::PreviewLoader const * loader = buffer.loader(); - LASSERT(loader, return 0); + LASSERT(loader, return nullptr); return loader->preview(snippet_); } diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index e234d9d652..f35b82e8f2 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -802,7 +802,7 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, set<pit_type> abstractWithLayout; set<pit_type> abstractNoLayout; - // Find the first non empty paragraph by mutating bpit. + // Find the first nonempty paragraph by mutating bpit. while (bpit < epit) { Paragraph const &par = paragraphs[bpit]; if (par.empty() || hasOnlyNotes(par)) -- 2.30.1.windows.1
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel