X-Ryl669 / grav-plugin-markdown-collapsible

MIT License
3 stars 4 forks source link

Plugin seems to have no effect #3

Closed frans-fuerst closed 7 months ago

frans-fuerst commented 2 years ago

I'm on Grav v1.7.34 and have the current markdown-collapsible plugin installed and enabled - the following Markdown code (taken from the example) gets rendered as without the plugin:

!> My section

### Whatever markdown you need

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris feugiat quam erat, ut iaculis diam posuere nec.
Vestibulum eu condimentum urna. Vestibulum feugiat odio ut sodales porta. Donec sit amet ante mi. Donec lobortis
orci dolor. Donec tristique volutpat ultricies. Nullam tempus, enim sit amet fringilla facilisis, ipsum ex
tincidunt ipsum, vel placerat sem sem vitae risus. Aenean posuere sed purus nec pretium.
!@

image

grav.log shows nothing and the console only shows a file being loaded by the plugin:

[Wed Jun 22 09:28:15 2022] 172.17.0.1:56604 [200]: /user/plugins/markdown-collapsible/assets/collapsible.css
[Wed Jun 22 09:28:15 2022] 172.17.0.1:56666 [200]: /user/plugins/markdown-collapsible/js/collapsible.js

Any idea? Does that plugin depend on a certain theme? Are there conflicting plugins?

X-Ryl669 commented 2 years ago

Few ideas, it's hard to say without checking your configuration:

  1. Try with named sections, like this:
    
    !>[interface] Whatever

Some text

!@


2. Make sure markdown processing it enabled in your grav installation "Configuration / Content => Process: Markdown". I'm not using twig here. In my "Configuration / Content" I only have *URL taxonomy* and *Ignore hidden* set to yes. In "Configuration / Markdown" I only have *Markdown Extra* set to yes.

If none of the above work, please report, I'll tell where to add debug to check why it's not matching your markdown.
frans-fuerst commented 2 years ago

Adding a section name works for me, thanks! Should the unnamed section work, too?

And - admittedly unrelated - should a section be collapsible, too? I can only expand them - clicking the title again only scrolls down a bit (which I personally find a bit annoying) but the section doesn't collapse again..

frans-fuerst commented 2 years ago

Without having tried it in the live system, maybe the regex used in the php file is wrong. Moving ? out of the braces makes the whole section name optional:

/^!>(\[(\w[\w-]*)\])?\s*(.*)$/
X-Ryl669 commented 2 years ago

Should the unnamed section work, too ?

Yes, it should (and it does on my website .?.?). Click on Properties chaining to see the effect.

And - admittedly unrelated - should a section be collapsible, too? I can only expand them - clicking the title again only scrolls down a bit (which I personally find a bit annoying) but the section doesn't collapse again..

That's because of the limited choice of implementation. The markdown emits only HTML's and CSS and no javascript, so I'm limited to what could be done without JS. The unnamed section is using a checkbox (so it has both states: checked and unchecked) while the named section use a radiobox (which, when clicked, can't be unclicked, you can only click another item). So it works on system without JS, and doesn't disturb SEO algorithms.

The only JS script I've added is to scroll back the page to the section name when folding a section, so if you have JS enabled, at least, it doesn't jump to another part of the page when clicking. You can try to disable it if you find it disturbing, or if you find a better, less painful workaround, I'll be grateful for it.

frans-fuerst commented 2 years ago

On https://blog.cyril.by/en/documentation/emqtt5-doc/emqtt5 "Properties Chaining" and "Properties Viewing" indeed works. I only tried it with the bunch of sections starting at "MessageReceived" - those don't work for me (Firefox, btw.)

X-Ryl669 commented 2 years ago

Moving ? out of the braces makes the whole section name optional:

There are 2 regex in the code, one for section names and one without (see 2 lines below in the else if). I've split in 2 regex because the text doesn't end up in the same capture's index. I should try your suggestion to see if I can simplify the code.

X-Ryl669 commented 2 years ago

I only tried it with the bunch of sections starting at "MessageReceived" - those don't work for me (Firefox, btw.)

That's because I'm stupid. MessageReceived doesn't have the same section name as the Contructor or the other connectTo methods, so it opens but doesn't collapse when clicking the other items. Other method will collapse so only one is opened at a time. I'll fix it, sorry for the bad example.

frans-fuerst commented 2 years ago

Nice to see a living plugin with a caring maintainer, thanks :)

X-Ryl669 commented 2 years ago

So, did you find out what wasn't working with the unnamed section mark code ?

X-Ryl669 commented 7 months ago

Issue is stale. Feel free to reopen if not.