mirror of
https://github.com/discourse/discourse.git
synced 2024-11-21 16:38:15 -06:00
FIX: allows to use open attribute with details (#29116)
Supporting `open` allows to show a `details` block open by default. Usage: ``` [details open] my visible content [/details] ```
This commit is contained in:
parent
85774cc214
commit
fd15562939
@ -2,9 +2,13 @@ const rule = {
|
||||
tag: "details",
|
||||
before(state, tagInfo) {
|
||||
const attrs = tagInfo.attrs;
|
||||
state.push("bbcode_open", "details", 1);
|
||||
const details = state.push("bbcode_open", "details", 1);
|
||||
state.push("bbcode_open", "summary", 1);
|
||||
|
||||
if (attrs.open === "") {
|
||||
details.attrs = [["open", ""]];
|
||||
}
|
||||
|
||||
let token = state.push("text", "", 0);
|
||||
token.content = attrs["_default"] || "";
|
||||
|
||||
|
@ -20,6 +20,21 @@ RSpec.describe PrettyText do
|
||||
HTML
|
||||
end
|
||||
|
||||
it "supports open attribute" do
|
||||
cooked_html = PrettyText.cook <<~MARKDOWN
|
||||
[details open]
|
||||
bar
|
||||
[/details]
|
||||
MARKDOWN
|
||||
|
||||
expect(cooked_html).to match_html <<~HTML
|
||||
<details open="">
|
||||
<summary></summary>
|
||||
<p>bar</p>
|
||||
</details>
|
||||
HTML
|
||||
end
|
||||
|
||||
it "deletes elided content" do
|
||||
cooked_html = PrettyText.cook <<~MARKDOWN
|
||||
Hello World
|
||||
|
Loading…
Reference in New Issue
Block a user