I have started development of a
code folding plugin
for Prism syntax highlighting. The
comment
by Lea Verou
showed me that the details
and summary
tags combined with the
Keep markup plugin are a
more comfortable solution.
The idea from above is just possible with the new details
and summary
tags and the
Keep markup plugin.
The details
and summary
tags are pretty new. We can hide everything in the
details
tag except the content of the summary
.
Here a small example.
Here a paragraph that can be hided.
<details>
<summary>Here is the summary</summary>
<p>Here a paragraph that can be hided.</p>
</details>
The Keep markup plugin will make it possible to use HTML tags inside of the code
element. In our
case details
and summary
.
We just have to add <details><summary>
infront of the starting line, a
</summary>
in front of the next line and </details>
in front of our
ending line. We can add the attribute open="true"
to the details
for initial
open details. Here a small example with the HTML code from above.
<details>
<summary>Here is the summary</summary>
<p>Here a paragraph that can be hided.</p>
</details>
<pre><code class="language-html"><details open="true"><summary><details>
</summary> <summary>Here is the summary</summary>
<p>Here a paragraph that can be hided.</p>
</details></details></code></pre>