Repository: executablebooks/MyST-Parser
Pull request #831 (2023-11-24 06:46:10)

👌 Nested parse attribution in `attr_block`
This is in keeping with the restructured text implementation, e.g.

```restructuredtext
  Hallo

  -- Chris Sewell `link <https://source.com>`__
```

tokenizes to:

```xml
<document source="test.rst">
    <block_quote>
        <paragraph>
            Hallo
        <attribution>
            Chris Sewell 
            <reference name="link" refuri="https://source.com">
                link
```


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/executablebooks/MyST-Parser/pull/831?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`ebf989f`)](https://app.codecov.io/gh/executablebooks/MyST-Parser/commit/ebf989fdae10c68dfbd3dcdfec4b86259b810cd9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) 90.26% compared to head [(`e7b6963`)](https://app.codecov.io/gh/executablebooks/MyST-Parser/pull/831?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) 90.27%.


<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master     #831   +/-   ##
=======================================
  Coverage   90.26%   90.27%           
=======================================
  Files          23       23           
  Lines        2970     2971    +1     
=======================================
+ Hits         2681     2682    +1     
  Misses        289      289           
```

| [Flag](https://app.codecov.io/gh/executablebooks/MyST-Parser/pull/831/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | Coverage Δ | |
|---|---|---|
| [pytests](https://app.codecov.io/gh/executablebooks/MyST-Parser/pull/831/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | `90.27% <100.00%> (+<0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#carryforward-flags-in-the-pull-request-comment) to find out more.


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/executablebooks/MyST-Parser/pull/831?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks).


Patch:
diff --git a/docs/.gitignore b/docs/.gitignore
index 22f62c8..d9e1fab 100644
--- a/docs/.gitignore
+++ b/docs/.gitignore
@@ -1,2 +1,3 @@
 _build/
 _api/
+apidocs/
diff --git a/docs/syntax/optional.md b/docs/syntax/optional.md
index fb21e99..d1e481f 100644
--- a/docs/syntax/optional.md
+++ b/docs/syntax/optional.md
@@ -749,7 +749,7 @@ c = 3
 For **block quotes**, the `attribution` key is supported:
 
 :::{myst-example}
-{attribution="Chris Sewell"}
+{attribution="Chris Sewell, [link](https://example.com)"}
 > Hallo
 :::
 
diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py
index cbf041e..faf35e4 100644
--- a/myst_parser/mdit_to_docutils/base.py
+++ b/myst_parser/mdit_to_docutils/base.py
@@ -582,12 +582,15 @@ class DocutilsRenderer(RendererProtocol):
         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()


Test patch:
diff --git a/tests/test_renderers/fixtures/attributes.md b/tests/test_renderers/fixtures/attributes.md
index e14175a..59b780a 100644
--- a/tests/test_renderers/fixtures/attributes.md
+++ b/tests/test_renderers/fixtures/attributes.md
@@ -16,7 +16,7 @@ c = 3
 
 blockquote
 .
-{attribution="Chris Sewell"}
+{attribution="Chris Sewell [link](https://source.com)"}
 > Hallo
 .
 <document source="<src>/index.md">
@@ -25,6 +25,8 @@ blockquote
             Hallo
         <attribution>
             Chris Sewell
+            <reference refuri="https://source.com">
+                link
 .
 
 list-style