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:
--- 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):
Actually, I think we should set
n.line = line + 1
?Applied in [r9979]. Thank you for the patch.
Related
Commit: [r9979]