From: Günter M. <mi...@us...> - 2025-07-30 09:29:11
|
- **status**: open-accepted --> closed-accepted - **Comment**: The patch is in Docutils 0.22 released 2025-07-29. Thanks again. --- **[patches:#211] Doctest nodes have incorrect `line` field ** **Status:** closed-accepted **Group:** None **Created:** Thu Sep 12, 2024 09:39 AM UTC by Hood Chatham **Last Updated:** Mon Nov 11, 2024 05:40 PM UTC **Owner:** nobody For most nodes, `node.line` refers to the source line that the node started on. However, doctest nodes report the end line. This can be fixed with the following patch: ```patch --- a/docutils/docutils/parsers/rst/states.py +++ b/docutils/docutils/parsers/rst/states.py @@ -1587,11 +1587,14 @@ def parse_option_marker(self, match): return optlist def doctest(self, match, context, next_state): + line = self.document.current_line data = '\n'.join(self.state_machine.get_text_block()) # TODO: prepend class value ['pycon'] (Python Console) # parse with `directives.body.CodeBlock` (returns literal-block # with class "code" and syntax highlight markup). - self.parent += nodes.doctest_block(data, data) + n = nodes.doctest_block(data, data) + n.line = line + self.parent += n return [], next_state, [] def line_block(self, match, context, next_state): ``` --- Sent from sourceforge.net because doc...@li... is subscribed to https://sourceforge.net/p/docutils/patches/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/patches/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |