Skip to content

Commit

Permalink
👌 Nested parse attribution in attr_block
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Nov 24, 2023
1 parent f313a09 commit b4c4885
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 9 additions & 6 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,15 @@ def render_blockquote(self, token: SyntaxTreeNode) -> None:
self.add_line_and_source_path(quote, token)
with self.current_node_context(quote, append=True):
self.render_children(token)
if "attribution" in token.attrs:
attribution = nodes.attribution(
token.attrs["attribution"], "", nodes.Text(token.attrs["attribution"])
)
self.add_line_and_source_path(attribution, token)
quote.append(attribution)
if "attribution" in token.attrs:
attribution = nodes.attribution(token.attrs["attribution"], "")
self.add_line_and_source_path(attribution, token)
with self.current_node_context(attribution, append=True):
self.nested_render_text(
str(token.attrs["attribution"]),
token_line(token, 0),
inline=True,
)

def render_hr(self, token: SyntaxTreeNode) -> None:
node = nodes.transition()
Expand Down
4 changes: 3 additions & 1 deletion tests/test_renderers/fixtures/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ c = 3

blockquote
.
{attribution="Chris Sewell"}
{attribution="Chris Sewell [link](https://source.com)"}
> Hallo
.
<document source="<src>/index.md">
Expand All @@ -25,6 +25,8 @@ blockquote
Hallo
<attribution>
Chris Sewell
<reference refuri="https://source.com">
link
.

list-style
Expand Down

0 comments on commit b4c4885

Please sign in to comment.