getgrav / grav-plugin-shortcode-owl-carousel

Grav Shortcode Owl Carousel Plugin
https://getgrav.org
MIT License
11 stars 12 forks source link

Evading Gantry 5 content markdown autoescaping #4

Closed smxmn closed 3 years ago

smxmn commented 7 years ago

Gantry 5 themes, particularly Helium, force autoescaping on content markdown. While the shortcode evaluation works in current state, the image list in page markdowns renders as an escaped paragraph.

Line 3 of the plugin partial template 'owl-carousel.html.twig' can be modified like this: {{ owl_items|regex_replace('(^\n?<p>|<\/p>$)','') }} to {{ owl_items|regex_replace('(^\n?<p>|<\/p>$)','')|raw }}

The generated layout of the carousel is a bit messy, but it works.

jakob-beetz commented 5 years ago

Hi guys, thank you for the great work! despite the suggested fix by @smxmn , multiple items on separate lines produce empty items, which I guess is related (also a Gantry5 theme)

[owl-carousel items=1 margin=0 loop=true autoplay=true autoplayHoverPause=true nav=false]
!['http://one.org'](one.png?resize=1024,300)
!['http://two.org'](two.png?resize=1024,300)
!['http://three.org'](three.png?resize=1024,300)
[/owl-carousel]

produces an extra blank item between each item

[owl-carousel items=1 margin=0 loop=true autoplay=true autoplayHoverPause=true nav=false]
!['http://one.org'](one.png?resize=1024,300)!['http://two.org'](two.png?resize=1024,300)!['http://three.org'](three.png?resize=1024,300)
[/owl-carousel]

(no linebreaks in items between in shortcode) produces the expected three items without blanks

any suggestions?

Thanks for the contribution!

lesar commented 4 years ago

I notice this is mark as bug from 2017 but I'm try to make carousel work on last grav and gantry 5 theme.
Have you any work around? Can give me any help?

best regards, Leonardo

P.s. My theme is Hydrogen. I have install this plugin, put in a markdown page

[owl-carousel items=1 margin=10 loop=true autoplay=true autoplayHoverPause=true nav=true]
[/owl-carousel]

Then install helium and go on his folder and copy particle for carousel on my hydrogen themplate.
Then add carousel particle on layout and configure it. The carousel is working in particle (to me is better if work in page markdown) If I cut out from the markdown page the [owl-carousel items=1... the carousel is no more working: nothing show.

I have try only now the trick at /user/plugins/shortcode-owl-carousel/templates/partialsowl-carousel.html.twig and it work to me using multiple item too.

beamaria commented 4 years ago

I can confirm the problem is with the code at /user/plugins/shortcode-owl-carousel/templates/partialsowl-carousel.html.twig: changing the line to {{ owl_items|regex_replace('(^\n?<p>|<\/p>$)','')|raw }} will enable the vision of a gallery in a blog post. The plugin which is installed though Admin Manager should be corrected ASAP, because it still has the wrong code!! I don't know if this is a problem only for Helium theme or for other themes as well.