DocBook: implement CALS tables
Richard Kimberly Heck
rikiheck at lyx.org
Wed Jul 15 20:01:49 UTC 2020
On 7/15/20 2:47 PM, Thibaut Cuvelier wrote:
> On Wed, 15 Jul 2020 at 18:15, Richard Kimberly Heck <rikiheck at lyx.org
> <mailto:rikiheck at lyx.org>> wrote:
>
> On 7/15/20 10:20 AM, Thibaut Cuvelier wrote:
>> From 39389b2776315b3414015de5265bab2c4e3d9087 Mon Sep 17 00:00:00
>> 2001
>> From: Thibaut Cuvelier <tcuvelier at lyx.org> <mailto:tcuvelier at lyx.org>
>> Date: Mon, 13 Jul 2020 03:31:48 +0200
>> Subject: [PATCH] Add support for CALS tables in DocBook.
>>
>> ---
>> development/FORMAT | 4 +
>> lib/lyx2lyx/lyx_2_4.py | 19 +++-
>> src/BufferParams.cpp | 7 ++
>> src/BufferParams.h | 9 ++
>> src/frontends/qt/GuiDocument.cpp | 11 +++
>> src/frontends/qt/ui/OutputUi.ui | 154
>> ++++++++++++++++++++++---------
>> src/insets/InsetTabular.cpp | 135 ++++++++++++++++++++++++---
>> src/insets/InsetTabular.h | 9 +-
>> src/tex2lyx/Preamble.cpp | 2 +
>> src/tex2lyx/Preamble.h | 1 +
>> src/version.h | 4 +-
>> 11 files changed, 291 insertions(+), 64 deletions(-)
>>
>> diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
>> index c4d63cab14..bdf5118dbf 100644
>> --- a/lib/lyx2lyx/lyx_2_4.py
>> +++ b/lib/lyx2lyx/lyx_2_4.py
>> @@ -3922,6 +3922,19 @@ def revert_libertinus_sftt_fonts(document):
>> add_to_preamble(document,
>> ["\\renewcommand*{\\LibertinusMono at scale}{" + str(tt_scale /
>> 100.0) + "}"])
>>
>>
>> +def convert_docbook_table_output(document):
>> + if find_token(document.header, '\\docbook_table_output 0')
>> == -1 and \
>> + find_token(document.header, '\\docbook_table_output
>> 1') == -1:
>> + document.append_local_layout('\\docbook_table_output 0')
>
> This is wrong: You're appending to the 'local layout' information,
> which is why we are then seeing a failure to convert that. (The
> tag is invalid, as layout.) You want to append to the preamble, so:
>
> append_to_preamble(document, '\\docbook_table_output 0')
>
> though, since we have already checked whether it is there
> (add_to_preamble checks that), probably just:
>
> document.preamble.append('\\docbook_table_output 0')
>
> Probably add_to_preamble should be a method of the document
> object, but the lyx2lyx code does not always make a lot of sense.
>
> Riki
>
> Thanks, it looks so dumb! I attached the new version of the patch, is
> it OK to push it as is?
I did not test the output, but it otherwise looks fine. The one thing I
would suggest is that you split the long comment lines, especially. We
try to keep from having lines that are too, too long, as some people use
pretty basic editors for their work.
I should have said this before, but....
> +def convert_docbook_table_output(document):
> + if find_token(document.header, '\\docbook_table_output 0') == -1
> and \
> + find_token(document.header, '\\docbook_table_output 1')
> == -1:
> + document.preamble.append('\\docbook_table_output 0')
I take it that \docbook_table_output should not be there, since it is
new with this format. If that's right, then you don't really need to
test for it, though you can if you want to be paranoid. If so, then
something like:
if find_token(document.header, '\\docbook_table_output') !- -1:
document.warning("Malformed LyX file: \\docbook_table_output
found in format 597!")
else:
document.preamble.append('\\docbook_table_output 0')
would be best. The find_token routine is misleadingly named, in that it
only looks for lines that BEGIN with the given string. (Even more oddly,
find_token_exact does the same thing, but ignores leading
whitespace.)See the lyx2lyx_tools.py and parser_tools.py files for lots
of comments on these routines.
Still, if it were me, I'd just do the append and forget the test.
> +def revert_docbook_table_output(document):
> + i = find_token(document.header, '\\docbook_table_output 0')
> + i = find_token(document.header, '\\docbook_table_output 1') if i
> == -1 else i
> + if i != -1:
> + del document.header[i]
Here, just:
del_token(document.header, "\\docbook_table_output")
should be enough, though you will want to test.
Riki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20200715/02f311f8/attachment.html>
More information about the lyx-devel
mailing list