DocBook change: use a stack of fonts
Thibaut Cuvelier
dourouc05 at gmail.com
Tue Dec 27 02:46:51 UTC 2022
On Tue, 27 Dec 2022 at 03:20, Richard Kimberly Heck <rikiheck at gmail.com>
wrote:
> On 12/26/22 20:13, Thibaut Cuvelier wrote:
> > Dear list,
> >
> > To solve https://www.lyx.org/trac/ticket/12585, I wrote the attached
> > patch. Basically, LyX now considers the order of font tags when
> > closing them, otherwise you get strange results like in the ticket.
> > The bug is quite serious, actually, even though I don't believe many
> > users will hit it.
>
> I struggled with that when writing the original XHTML code. It's hard to
> get right. I know it sometimes would fail. Is this same code also used
> with XHTML now? Or would it need to be adapted for that case?
>
I've tested this case and it looks like the XHTML code did the right thing
there. It's a part I rewrote for DocBook, introducing a few bugs.Here is
the output from XHTML for the same file:
<div class='standard' id='magicparlabel-1'>norm <em>emph
<b>emph-bold</b></em><b> bold</b> norm</div>
I don't understand why it is producing the right output while DocBook did
not. Maybe the pending tags or the special code for font tags from
XMLStream kick in. If that's the case, it's a bit strange that XMLStream
deals with this kind of issue (it feels like XMLStream is doing work at
multiple levels of abstraction).
> I'm no good with tests, but I can review the code. Generally speaking,
> it makes sense to me.
>
> Is [[nodiscard]] something we support now? I've never seen that before.
>
It's actually a C++17 feature, I thought it was an earlier one. I'm
removing it.
The goal is to make users of the function use the returned value: the
compiler throws an error when you're not explicitly using the return value.
For instance, if std::vector::empty is marked as [[nodiscard]], you cannot
mistake the function for clear, because empty has a return value that the
user would have to use.
> > + DocBookFontOperation endTransaction() {
> > + return {.fontsToClose = fontsToClose_, .fontsToOpen =
> > fontsToOpen_};
> > + }
> > +
> What is ".fontsToClose"? What's the dot doing? Is the "=" right? This
> code just confuses me.
>
It looks like the name of this C99 feature is "designated initializers":
when building a struct instance, you can give the name of the fields you
are filling. This is especially useful here to ensure that you are not
mixing the open and close sets (they have the same type).
I can remove it if it's a problem with some compilers. The code would look
like this:
return {fontsToClose_, fontsToOpen_};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20221227/35e17b65/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-DocBook-implement-a-stack-of-fonts.patch
Type: application/octet-stream
Size: 22117 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20221227/35e17b65/attachment-0001.obj>
More information about the lyx-devel
mailing list