Fixing #12372: leverage preview to have images in DocBook instead of LaTeX code

Thibaut Cuvelier tcuvelier at lyx.org
Wed Oct 13 12:33:47 UTC 2021


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-DocBook-add-the-DocBookRenderAsImage-tag.patch
Type: application/x-patch
Size: 4194 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-Factor-out-the-generation-of-the-code-to-create-a-pr.patch
Type: application/x-patch
Size: 2145 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0009.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-DocBook-don-t-use-a-surrounding-para-for-rendered-in.patch
Type: application/x-patch
Size: 2212 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0010.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0008-DocBook-generate-images-for-layouts-that-request-it.patch
Type: application/x-patch
Size: 4103 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0011.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-DocBook-overall-structure-for-rendered-insets.patch
Type: application/x-patch
Size: 4787 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0012.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-DocBook-add-assertion-to-help-debugging.patch
Type: application/x-patch
Size: 826 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0013.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Factor-out-the-list-of-macro-definitions-for-InsetPr.patch
Type: application/x-patch
Size: 3847 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0014.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-Typos-and-comment-improvements.patch
Type: application/x-patch
Size: 3234 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211013/feec82ab/attachment-0015.bin>


More information about the lyx-devel mailing list