DocBook: overall structure for rendered insets.

This commit is contained in:
Thibaut Cuvelier 2021-10-07 02:27:54 +02:00
parent 5c735ce880
commit 82bca97379
2 changed files with 54 additions and 7 deletions

View File

@ -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());
}
}
}

View File

@ -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.