X-Ryl669 / grav-plugin-markdown-collapsible

MIT License
3 stars 4 forks source link

Uncollapses, but doesn't collapse again #4

Closed Pumpapa closed 1 year ago

Pumpapa commented 1 year ago

I had the other issue, about the plugin not working at all, so now I have multiple uniquely named collapsibles.

When a page is loaded, all are collapsed, and uncollapsing works fine, but then clicking the arrow to collapse again doesn't work; it just scrolls to the end of the collapsible.

X-Ryl669 commented 1 year ago

That's probably because you have uniquely named section. Make them the same name and they'll collapse (except for the last clicked one), like an accordion.

If you need unique section that works more or less like a <detail> html element, then the syntax is:


!> Property chaining
#### Using properties with the client

Some example

!@

This is because the implementation doesn't rely on JS (only on pure HTML/CSS code). The unnamed section is made with a checkbox that can be checked or unchecked. If checked, the section is visible.

The named section are made with a radio box (where only one option can be active at a time, can not be unchecked). If you've created named section with all a different name, you'll get as many different radio box as you have section. You can't uncheck a radio box, without JS.

Pumpapa commented 1 year ago

Each section should be independently collapsible; they are not grouped. I have to be able to uncollapse it, read it and then collapse it again. I added the group name only because otherwise the plugin doesn't work, as discussed in the other issue

X-Ryl669 commented 1 year ago

Well I don't know why it doesn't work for you, it works on my site for unnamed collapsible (the extract above is extracted from my website).

Maybe you can add some debug on the most important part and report here 1. In markdown-collapsible.php at line 39, add `vardump($text);` 2. Enable debug in grav admin's 'Configuration' page, 'System' tab, 'Debugger' section, enable 'Debugger' 3. Make sure you are processing markdown (again in 'System' tab, 'Markdown' section, enable 'Markdown extra') 4. Disable caching ('Caching' section, disable 'Caching') 5. Refresh the page with unnamed collapsible 6. It should display the title for the section (and not its name) in an ugly PHP var-dump here
Pumpapa commented 1 year ago

This regexp seems off: /^!>(\[(\w[\w-]*)\]?)\s*(.*)$/ Shouldn't the ? go after the entire (parenthesized) group and not just the \] I tried /^!>(\[(\w[\w-]*)\])?\s*(.*)$/ and that seems to work

X-Ryl669 commented 1 year ago

Ok, I've tested the regexp and it also works on my website (doesn't break, at least!). So if it works for you, let's use it.

Pumpapa commented 1 year ago

OK. Thanks. Then I can simply update when that arrives.