|
From: Günter M. <mi...@us...> - 2024-11-11 17:40:11
|
- **status**: open --> open-accepted
- **Comment**:
Applied in [r9979]. Thank you for the patch.
---
**[patches:#211] Doctest nodes have incorrect `line` field **
**Status:** open-accepted
**Group:** None
**Created:** Thu Sep 12, 2024 09:39 AM UTC by Hood Chatham
**Last Updated:** Thu Sep 12, 2024 09:47 AM 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. |