From 4986e86e6884bbe8ff79e2914a38b9ed6573092c Mon Sep 17 00:00:00 2001 From: Kevin Deldycke Date: Wed, 10 Sep 2025 15:53:53 +0200 Subject: [PATCH] Aligns directive's block_text content to rST's --- myst_parser/mdit_to_docutils/base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py index 3778dd31..47523b98 100644 --- a/myst_parser/mdit_to_docutils/base.py +++ b/myst_parser/mdit_to_docutils/base.py @@ -1773,8 +1773,13 @@ def run_directive( lineno=position, # the line offset of the first line of the content content_offset=parsed.body_offset, - # a string containing the entire directive - block_text="\n".join(parsed.body), + # A string containing the entire directive, including options and full, + # unparsed content. + # XXX Ideally, and to mirros rST's behavior, it should also contain the + # complete directive header (i.e the "```{name} {arguments}" line), and + # the directive closing line (i.e. the "```" line), but that is not + # currently possible unless we refactor the parser. + block_text=content, state=state, state_machine=state_machine, )