Closed giansi closed 8 years ago
I'm actually working with the developer of the upstream shortcode library we are using. I have found a couple of problems that he's working on fixing. I will look at this issue of yours at the same time.
Cheers,.
Awesome. Thank you! Maybe the Shortcode library could be added to Grav composer instead of the shortcodes plugin
I don't want to tie shortcodes into Grav core. As a plugin it allows for much more rapid development and updates. I just released a new version of the core with dev-master of the shortcode library that contains several fixes.
Can you please test your code with it? I'm having trouble recreating your issue. This is mine:
[ui-tabs position="top-left" active="0" theme="lite"]
[ui-tab title="First Tab"]
In tempor sed sapien eu porttitor. Aliquam cursus facilisis ante. Etiam neque nunc, blandit vel lacus et, faucibus accumsan lacus. Proin posuere varius purus quis faucibus. Quisque et enim vitae orci [placerat tincidunt](#) id ac eros. Fusce et gravida libero.
Phasellus cursus odio ex, in **mattis lorem tincidunt** vel. Donec nibh odio, dapibus non ligula a, semper ornare massa. Nulla consectetur eu nunc sed ultrices. Integer at turpis dolor.
[/ui-tab]
[ui-tab title="Second Tab"]
In tempor sed sapien **eu porttitor**. Aliquam cursus facilisis ante. Etiam neque nunc, blandit vel lacus et, faucibus accumsan lacus. Proin posuere varius purus quis faucibus. [Quisque et enim](#) vitae orci placerat tincidunt id ac eros. Fusce et gravida libero.
Phasellus cursus odio ex, in mattis lorem tincidunt vel. [Donec nibh odio](#), dapibus non ligula a, semper ornare massa. Nulla consectetur eu nunc sed ultrices. Integer at turpis dolor.
[/ui-tab]
[/ui-tabs]
Works fine.
It still does not work. To reproduce the issue, please add this code to shortcode-ui.php: private function addTabsHandler() { [...] $this->handlers->add('ui-tab', function(ShortcodeInterface $shortcode) { echo htmlentities($shortcode->getContent());exit;
and you will get this result:
</p> <p>In tempor sed sapien eu porttitor. Aliquam cursus facilisis ante. Etiam neque nunc, blandit vel lacus et, faucibus accumsan lacus. Proin posuere varius purus quis faucibus. Quisque et enim vitae orci <a href="#">placerat tincidunt</a> id ac eros. Fusce et gravida libero.</p> <p>Phasellus cursus odio ex, in <strong>mattis lorem tincidunt</strong> vel. Donec nibh odio, dapibus non ligula a, semper ornare massa. Nulla consectetur eu nunc sed ultrices. Integer at turpis dolor.</p> <p>
which has a
at the beginning and aat the end which should not be present. This happens because the shortcode is parsed using the markdown rendered content, which converts the [ui-tab title="First Tab"] as
[ui-tab title="First Tab"]
I really can't make any sense of your comment because you are not using appropriate code blocks.
Could you please do one of the following:
1) Point me to your code on github 2) Post your shortcode and your plugin code in proper code blocks.
Thanks!
Andy
Seems like you have this sorted
Hi @rhukster, no this is not sorted yet. I just realized that some important bits are missing from opening issue, so I would try to fix this problem.
I just rendered again your ui-tabs and the issue still lies there. The problem is with the ui-tab rendered code, in fact the produced html code is this one
<div class="tab" id="2f1b79ae7e0"></p>
<p>In tempor sed sapien eu porttitor. Aliquam cursus facilisis ante. Etiam neque nunc, blandit vel lacus et, faucibus accumsan lacus. Proin posuere varius purus quis faucibus. Quisque et enim vitae orci <a href="#">placerat tincidunt</a> id ac eros. Fusce et gravida libero. </p>
<p>Phasellus cursus odio ex, in <strong>mattis lorem tincidunt</strong> vel. Donec nibh odio, dapibus non ligula a, semper ornare massa. Nulla consectetur eu nunc sed ultrices. Integer at turpis dolor.</p>
<p></div>
As you can see, after the opening div there is a </p>
(missing bit) and just before the closing div there is a <p>
(missing bit). Those bad tokens comes from the shortcode definitions, in fact the first arrives from <p>[ui-tab title="First Tab"]</p>
and the last from the <p>[/ui-tab]</p>
.
Here's a screenshot of the rendered ut-tab (selected code). Hope I could explain myself this time. :-)
Are you running the latest 'github' version? I originally was going to put a fix in the grav core, but then thought better of it and put it in to the shortcode core plugin. Basically it registers the [
tag as a root level 'block' item so doesn't wrap it in <p>
tags.
@rhukster, could you kindly point me where I can look for this fix?
When a shortcode is rendered, it returns a bad closing token, when calling shortcode getContent method. Here's an example for tabs shortcode:
In tempor sed sapien eu porttitor. Aliquam cursus facilisis ante. Etiam neque nunc, blandit vel lacus et, faucibus accumsan lacus. Proin posuere varius purus quis faucibus. Quisque et enim vitae orci placerat tincidunt id ac eros. Fusce et gravida libero.
Phasellus cursus odio ex, in mattis lorem tincidunt vel. Donec nibh odio, dapibus non ligula a, semper ornare massa. Nulla consectetur eu nunc sed ultrices. Integer at turpis dolor.
It adds a
at the beginning because it is used the rendered page, which source is the following:[ui-tab title="First Tab"]
In tempor sed sapien eu porttitor. Aliquam cursus facilisis ante. Etiam neque nunc, blandit vel lacus et, faucibus accumsan lacus. Proin posuere varius purus quis faucibus. Quisque et enim vitae orci placerat tincidunt id ac eros. Fusce et gravida libero.
Phasellus cursus odio ex, in mattis lorem tincidunt vel. Donec nibh odio, dapibus non ligula a, semper ornare massa. Nulla consectetur eu nunc sed ultrices. Integer at turpis dolor.
[/ui-tab] [ui-tab title="Second Tab"]
In tempor sed sapien eu porttitor. Aliquam cursus facilisis ante. Etiam neque nunc, blandit vel lacus et, faucibus accumsan lacus. Proin posuere varius purus quis faucibus. Quisque et enim vitae orci placerat tincidunt id ac eros. Fusce et gravida libero.
Phasellus cursus odio ex, in mattis lorem tincidunt vel. Donec nibh odio, dapibus non ligula a, semper ornare massa. Nulla consectetur eu nunc sed ultrices. Integer at turpis dolor.
[/ui-tab]
A solution to fix could be replacing the bad closing token. In addition I'd like to know if Is there is any chance to have the original markdown before it is rendered.