[docutils:bugs] #517 content_offset in directives inside grid/simple tables are off

Günter Milde via Docutils-develop <[email protected]> Wed, 07 Jan 2026 13:13:47 -0000
Newsgroups gmane.text.docutils.devel
Message-ID </p/docutils/bugs/517/2640e115f228e1c50ef2fa516de0c858c476b45a.bugs@docutils.p.sourceforge.net>
This is a multi-part message in MIME format.
--===============4408970413595620699==
Content-Type: multipart/related; boundary="===============5452948614938369779=="

This is a multi-part message in MIME format.
--===============5452948614938369779==
Content-Type: multipart/alternative; boundary="===============4374099377914982488=="
MIME-Version: 1.0

--===============4374099377914982488==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

- **status**: open --> open-fixed
- **Comment**:

The fix is out.
Sorry for the confusion: I intended to publish 2 commits with one `git svn dcommit`
but only the first came through.



---

**[bugs:#517] content_offset in directives inside grid/simple tables are off**

**Status:** open-fixed
**Created:** Sat Dec 27, 2025 05:07 PM UTC by Felix Fontein
**Last Updated:** Tue Jan 06, 2026 08:59 PM UTC
**Owner:** nobody


When parsing a directive in a grid table or simple table, the directive's `content_offset` is off by one. (When nesting such a table in another such a table, it's off by one for every nesting level.)

For example, for the following code block directives, `content_offset` is always off from the real content line where the code block's content is in:

```rst
content_offset is off by 1:

+----------------------+
| .. code-block:: yaml |
|                      |
|    - foo             |
+----------------------+

content_offset is off by 2:

+------------------------+
|+----------------------+|
|| .. code-block:: yaml ||
||                      ||
||    - foo             ||
|+----------------------+|
+------------------------+

content_offset is off by 3:

+--------------------------+
|+------------------------+|
||+----------------------+||
||| .. code-block:: yaml |||
|||                      |||
|||    - foo             |||
||+----------------------+||
|+------------------------+|
+--------------------------+

content_offset is off by 1:

=====  =====
col 1  col 2
=====  =====
1      .. code-block:: yaml

          - foo
=====  =====

content_offset is off by 2:

=====  =====
col 1  col 2
=====  =====
1      =====  =====
       col 1  col 2
       =====  =====
       1      .. code-block:: yaml

                 - foo
       =====  =====
=====  =====
```

(I've noticed this when registering an own code block directive to find the actual location - row and column - of the code block's contents, to be able to give more precise error messages when linting.)


---

Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/docutils/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
--===============4374099377914982488==
MIME-Version: 1.0
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit

<div class="markdown_content"><ul>
<li><strong>status</strong>: open --&gt; open-fixed</li>
<li><strong>Comment</strong>:</li>
</ul>
<p>The fix is out.<br/>
Sorry for the confusion: I intended to publish 2 commits with one <code>git svn dcommit</code><br/>
but only the first came through.</p>
<hr/>
<p><strong><a class="alink" href="https://sourceforge.net/p/docutils/bugs/517/">[bugs:#517]</a> content_offset in directives inside grid/simple tables are off</strong></p>
<p><strong>Status:</strong> open-fixed<br/>
<strong>Created:</strong> Sat Dec 27, 2025 05:07 PM UTC by Felix Fontein<br/>
<strong>Last Updated:</strong> Tue Jan 06, 2026 08:59 PM UTC<br/>
<strong>Owner:</strong> nobody</p>
<p>When parsing a directive in a grid table or simple table, the directive's <code>content_offset</code> is off by one. (When nesting such a table in another such a table, it's off by one for every nesting level.)</p>
<p>For example, for the following code block directives, <code>content_offset</code> is always off from the real content line where the code block's content is in:</p>
<div class="codehilite"><pre><span></span><code>content_offset is off by 1:

+----------------------+
<span class="o">|</span> .. code-block:: yaml |
<span class="o">|</span>                      |
<span class="o">|</span>    - foo             |
+----------------------+

content_offset is off by 2:

+------------------------+
|+----------------------+|
|| .. code-block:: yaml ||
||                      ||
||    - foo             ||
|+----------------------+|
+------------------------+

content_offset is off by 3:

+--------------------------+
|+------------------------+|
||+----------------------+||
||| .. code-block:: yaml |||
|||                      |||
|||    - foo             |||
||+----------------------+||
|+------------------------+|
+--------------------------+

content_offset is off by 1:

=====  =====
col 1  col 2
=====  =====
1      .. code-block:: yaml

          <span class="m">-</span> foo
=====  =====

content_offset is off by 2:

=====  =====
col 1  col 2
=====  =====
1      =====  =====
       col 1  col 2
       =====  =====
       1      .. code-block:: yaml

                 <span class="m">-</span> foo
       =====  =====
=====  =====
</code></pre></div>

<p>(I've noticed this when registering an own code block directive to find the actual location - row and column - of the code block's contents, to be able to give more precise error messages when linting.)</p>
<hr/>
<p>Sent from sourceforge.net because [email protected] is subscribed to <a href="https://sourceforge.net/p/docutils/bugs/">https://sourceforge.net/p/docutils/bugs/</a></p>
<p>To unsubscribe from further messages, a project admin can change settings at <a href="https://sourceforge.net/p/docutils/admin/bugs/options.">https://sourceforge.net/p/docutils/admin/bugs/options.</a>  Or, if this is a mailing list, you can unsubscribe from the mailing list.</p></div>
--===============4374099377914982488==--

--===============5452948614938369779==--


--===============4408970413595620699==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============4408970413595620699==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline