Possible to modify Details extension to accept Markdown header syntax? #1717
-
|
Hey folks, Is it possible to modify the behavior of the Details extension so the first line (collapsible section header) can be inserted using Markdown header syntax? For example, can I configure the parser to convert this: To this:
Ideally for h2s to h5s. I'm not an expert in Python (basic understanding), so please try to ELI5 what code I can copy and paste into the details.py file. I have tried messing around with it a bit by coping code from the section of the Markdown BlockProcessor that processer headers, to no avail :( Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
I think what you are requesting is for something where an ID can be added to a Details element: #1194. With that said, I have not yet decided upon or added such functionality, but if you follow the link, I offer some suggestions, such as wrapping the details with a If you must specifically have a header embedded within the summary, you will have to use raw HTML to accomplish the task. While, if I recall correctly, details may allow for inline Markdown, it will not recognize block-level syntax such as headers. |
Beta Was this translation helpful? Give feedback.
-
|
I think I might have a good argument for adding this feature (or some variation of it). With various common search tools, the on-site search displays the header of the section which contains the search term. In some situations, it would be desirable for the For example, consider this FAQs section: Currently, searching for the term "foo" would return a result: But if the summary contains a heading element (perhaps an Obviously, that is more meaningful. Yes, an ID can be set on the detail in some other way (via I should note that heading elements (h1-6) are valid content in summary elements. The spec specifically mentions "heading content." Yes, one can manually use raw tags, but in my testing, for search to show the heading, it needs to also have an ID set. And with raw HTML, we lose Markdown's ability to automatically generate an ID (with the appropriate extension). Therefore, it would be nice to be able to have Markdown create the heading elements for us. Currently, Markdown considers The above should generate the following HTML (assuming a compatible extension was enabled to auto-generate IDs: <details>
<summary><h2 id="what-does-foo-mean">What does "foo" mean?</h2></summary>
<p>"Foo" is placeholder text often used in code examples.</p>
</details>Thoughts? As an aside, using |
Beta Was this translation helpful? Give feedback.
I think what you are requesting is for something where an ID can be added to a Details element: #1194.
With that said, I have not yet decided upon or added such functionality, but if you follow the link, I offer some suggestions, such as wrapping the details with a
<div id="some-id" markdown>.If you must specifically have a header embedded within the summary, you will have to use raw HTML to accomplish the task. While, if I recall correctly, details may allow for inline Markdown, it will not recognize block-level syntax such as headers.