Skip to content

Support Markdown parsing inside collapsible blocks <details><summary>…</summary></details> #5

@NumesSanguis

Description

@NumesSanguis

Thanks again for m2r2 and I hope it's okay to make requests here?

What I want to do

In my .md file I'm making use of collapsible blocks that makes the document much more readable:

<details><summary>Expand (CLICK ME)</summary>
<p>

Large Markdown formatted text:
- Many lists

</p>
</details>

Which turns on GitHub into:

Expand (CLICK ME)

Large Markdown formatted text:

  • Many lists

Issue

When turning the above Markdown into HTML with Sphinx, it just becomes a literal string.
Checking the output of m2r2 README.md, we can see that everything is wrapped into a raw html wrapper:

.. raw:: html

   <details><summary>Expand (CLICK ME)</summary>
   <p>

   Large Markdown formatted text:
   - Many lists

   </p>
   </details>

Related issue

The problem might be fundamentally the same as encountered by this GitHub Pages user:
https://github.community/t/collapsible-markdown-inside-details-summary-summary-details-fails-to-render/10489

The solution for them was to set a different markdown parser: markdown: CommonMarkGhPages

Request / Possible solution

  • Automatically detect that <details><summary> has been used, and only wrap that part into .. raw:: html OR
  • Allow to manually specify that m2r2 should parse the contents inside collapsible HTML code OR
  • Some other approach

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions