From 828290bc9d3abecba90943708741cf6106594e8b Mon Sep 17 00:00:00 2001 From: Jan Breuer Date: Fri, 19 Jan 2024 13:06:46 +0100 Subject: [PATCH 1/2] Remove further unnecessary colSpan and rowSpan --- linuxdoc/rstFlatTable.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/linuxdoc/rstFlatTable.py b/linuxdoc/rstFlatTable.py index e4ef66d..d2c7a5a 100755 --- a/linuxdoc/rstFlatTable.py +++ b/linuxdoc/rstFlatTable.py @@ -35,6 +35,7 @@ def setup(app): app.add_directive("flat-table", FlatTable) roles.register_local_role('cspan', c_span) roles.register_local_role('rspan', r_span) + app.connect('doctree-resolved', FlatTableProcessor) return dict( version = __version__, @@ -347,3 +348,17 @@ def parseCellItem(self, cellItem): elem.parent.remove(elem) continue return cspan, rspan, cellItem[:] + +# ============================================================================== +class FlatTableProcessor: +# ============================================================================== + + u"""Remove colSpan and rowSpan from the document after the doctree-resolved + phase.""" + + def __init__(self, app, doctree: nodes.document, docname: str) -> None: + self.process(doctree) + + def process(self, doctree: nodes.document) -> None: + for node in list(doctree.findall(lambda item: isinstance(item, (colSpan, rowSpan)))): + node.parent.remove(node) From 65c85631d13f5e43b8136f86914d421cf783966e Mon Sep 17 00:00:00 2001 From: Jan Breuer Date: Fri, 19 Jan 2024 13:17:57 +0100 Subject: [PATCH 2/2] doc: remove limitation for cspan and rspan in translations --- docs/linuxdoc-howto/table-markup.rst | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/docs/linuxdoc-howto/table-markup.rst b/docs/linuxdoc-howto/table-markup.rst index 592dbae..9e7ee5c 100644 --- a/docs/linuxdoc-howto/table-markup.rst +++ b/docs/linuxdoc-howto/table-markup.rst @@ -226,25 +226,6 @@ roles: :cspan: [int] additional columns (*morecols*) :rspan: [int] additional rows (*morerows*) - The ``:rspan:`` and ``:cspan:`` are *special* reST-roles_. These directives - are used in the :py:obj:`linuxdoc.rstFlatTable.ListTableBuilder` and - :py:obj:`removed ` while - the table is parsed. These reST-roles must not be in the translation: - - .. code-block:: po - - #: ../index.rst:21 - msgid ":rspan:`1` :cspan:`1` field 2.2 - 3.3" - msgstr "test (fr) field 2.2 - 3.3" - - Most other reST-roles_ should be translated *as-is*: - - .. code-block:: po - - #: ../index.rst:48 - msgid ":math:`a^2 + b^2 = c^2`" - msgstr "test (fr) :math:`a^2 + b^2 = c^2`" - The example below shows how to use this markup. The first level of the staged list is the *table-row*. In the *table-row* there is only one markup allowed, the list of the cells in this *table-row*. Exception are *comments* ( ``..`` )