SF.net SVN: docutils:[10280 ] trunk/docutils

milde--- via Docutils-checkins <[email protected]> Wed, 07 Jan 2026 07:51:17 +0000
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 10280
          http://sourceforge.net/p/docutils/code/10280
Author:   milde
Date:     2026-01-07 07:51:16 +0000 (Wed, 07 Jan 2026)
Log Message:
-----------
Fix "input_offset" in tables.

When parsing the cell content of grid tables and simple tables,
the "input_offset" passed to the nested parser was off by one line.

This led to wrong "lineno" and "content_offset" attributes in Directive
class instances and to wrong line numbers in system-messages.

Fixes bug #517.

TODO: the reported line numbers for CSV table content are still wrong.

Modified Paths:
--------------
    trunk/docutils/HISTORY.rst
    trunk/docutils/docutils/parsers/rst/states.py
    trunk/docutils/test/test_parsers/test_rst/test_tables.py

Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst	2026-01-06 17:29:53 UTC (rev 10279)
+++ trunk/docutils/HISTORY.rst	2026-01-07 07:51:16 UTC (rev 10280)
@@ -22,11 +22,15 @@
   - Add source and line info to <rubric> elements.
 
 * docutils/parsers/rst/directives/tables.py,
-  docutils/parsers/rst/states.py
 
   - Add source and line info to <table> elements.
 
+* docutils/parsers/rst/states.py
 
+  - Add source and line info to <table> elements.
+  - Fix bug #517: wrong "input_offset" when parsing table cell content.
+
+
 Release 0.22.4 (2025-12-18)
 ===========================
 

Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py	2026-01-06 17:29:53 UTC (rev 10279)
+++ trunk/docutils/docutils/parsers/rst/states.py	2026-01-07 07:51:16 UTC (rev 10280)
@@ -1950,7 +1950,7 @@
             entry = nodes.entry(**attributes)
             row += entry
             if ''.join(cellblock):
-                self.nested_parse(cellblock, input_offset=tableline+offset,
+                self.nested_parse(cellblock, input_offset=tableline+offset-1,
                                   node=entry)
         return row
 

Modified: trunk/docutils/test/test_parsers/test_rst/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_tables.py	2026-01-06 17:29:53 UTC (rev 10279)
+++ trunk/docutils/test/test_parsers/test_rst/test_tables.py	2026-01-07 07:51:16 UTC (rev 10280)
@@ -752,6 +752,29 @@
         Paragraph.
 """],
 ["""\
+=================================  ========
+The ERROR should point to line 2.  .. tip::
+=================================  ========
+""",
+"""\
+<document source="test data">
+    <table>
+        <tgroup cols="2">
+            <colspec colwidth="33">
+            <colspec colwidth="8">
+            <tbody>
+                <row>
+                    <entry>
+                        <paragraph>
+                            The ERROR should point to line 2.
+                    <entry>
+                        <system_message level="3" line="2" source="test data" type="ERROR">
+                            <paragraph>
+                                Content block expected for the "tip" directive; none found.
+                            <literal_block xml:space="preserve">
+                                .. tip::
+"""],
+["""\
 ============  ============
 A table with  two columns
 and           two rows.

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.