Add handling for details & summary tags (collapsible sections) #1567
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
PR to solve #1422
Handles
<details>
and<summary>
tags to allow for users to have collapsible sections in text.Behavior is close to 1:1 with that of Github's handling.
Minor differences:
\n\n
) to have a proper newline in the resulting text. In this implementation, all newlines are handled (\n
).<details>
is not handled. In this implementation, it is.Screenshots
The following text showing different structures will render as pictured on subsequent image:
Additional Context
I was able to get it to work very close to github-like behavior without the additional imports of
except I couldn't get inner lists and inner markdown to work, noting that markdown does not work inside
<details>
on github, but lists do.Checklist
Are your changes backwards compatible? Please answer below:
Yes. Existing tags (though unlikely to have been used since they were not handled and would appear as plain text) will now render properly.
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
7/10
Tested a variety of markdown inside
<details>
and various ways of structuring the tags: all tags on one line, a few lines, indentations, etc.It works in bios.
Tags remain as plaintext in post titles as expected.
Will QA some more while in draft.
For frontend changes: Tested on mobile? Please answer below:
Yes. Works on mobile as expected.
Did you introduce any new environment variables? If so, call them out explicitly here:
No.
DRAFT
Creating this as draft for now for the following reasons:
<spoiler>
solution. That solution was little additional code and lean, leveraging the stylers already used for<sub>
and<sup>
. The use cases could be also be different. A spoiler for someone who wants to hide the winner of a sports match or a character dying in a show. The<details>
/<summary>
tags for breaking down bigger posts into smaller chunks or chapters, or also to hide answers like @SouthKoreaLN wished.