-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested shortcode issue #57
Comments
Hi @jenstornell, I also ran your script here on the same PHP versions with the same setup as in #56, with the same result: correct, both shortcodes replaced as they should. BTW I assume that "Logan" in the first result is a typo because I'm pretty sure I don't detect and replace names in the source text. :) |
@thunderer Yes, "Logan" was a typo. As I already write I can tell about the backstory of using your library. I have an idea to write a plugin for Kirby that would be a replacement for their built in "Tags": https://getkirby.com/docs/developer-guide/kirbytext/tags And the reason for the replacement is mainly this issue: ...but it would also be nice to have something more powerful with support for nesting etc. You are sure you run exatcly this code when you tested? <?php
include 'vendor/autoload.php';
use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
$facade = new ShortcodeFacade();
$facade->addHandler('hello', function(ShortcodeInterface $s) {
return sprintf('Hello, %s!' . $s->getContent(), $s->getParameter('name'));
});
$text = '
<p>Start</p>
[hello name="Thomas"]
[hello name="Peter"]
[/hello]
<p>End</p>
';
echo $facade->process($text); |
Thanks for the information, @jenstornell. A couple more questions then:
Also, yes, I'm sure that I ran exactly the code you mentioned, you can see the Gist with all my code to reproduce your issue: https://gist.github.com/thunderer/862b87b0cd26916387510ab81f2c418b . |
Some server info is in the image below. Multibyte support is enabled. I have not overwritten it. It's a very standard XAMPP setup. It seems complicated to install PHP Unit so I have been able to code decently without it so far. I can't test it because of limited skills. I have not tried the code on Linux, but Apache is a Linux server, right? It looks like you are running the code as it should. |
@jenstornell I see that Apache is an HTTP server that is indeed commonly run under Linux, but it's not a Linux server per se. You are using a version compiled for Windows. If you could create an Ubuntu VM in VirtualBox and check it, it would be very helpful to isolate the problem. But PHPUnit output is crucial here if some of the tests are failing under Windows (even though I also ran them there and they passed) then I need to know which. |
I managed to get fresh XAMPP with PHP 7.2 running on Windows 10 on my laptop, ran the tests, all green. apart from running Shortcode tests, could you "debug" the code using |
I just get this:
If I go directly to UpdateYou already have run the tests so I get to the
Output of it (same as before):
|
@jenstornell The first shortcode is correctly extracted from the text, but is there only one, not two? The second one should be Please run the tests by executing |
I tried it at home on my laptop with the same result. Here I also use Windows with XAMPP so the result is expected. I also installed it with Composer. <?php
include 'vendor/autoload.php';
use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use Thunder\Shortcode\Parser\RegularParser;
$facade = new ShortcodeFacade();
$facade->addHandler('hello', function(ShortcodeInterface $s) {
return sprintf('Hello, %s!' . $s->getContent(), $s->getParameter('name'));
});
$text = '
<p>Start</p>
[hello name="Thomas"]
[hello name="Peter"]
[/hello]
<p>End</p>
';
$parser = new RegularParser();
var_dump($parser->parse($text));
echo $facade->process($text); It output the var_dump and also the result of the echo.
I don't know if it help you. If not, maybe I can mail you a zip of my files. Then you can try a copy of my files, in case they are different in some way. I'll get back to you with phpunit tests if I get it to run. |
Phpunit tests. A driver is missing but it seems to have run anyway. So all tests passed, I guess, at 276/276 100%.
Also see my previous comment about the var_dump test. |
If you want to test exactly the same files as me, I created a new repo for you here: https://github.com/jenstornell/shortcode-test It returns the same thing as a comment above, var_dump of the parse and this output:
|
@jenstornell If that's exactly the code you're running then I know what happened - you're using an old version
which matches the |
The problem is solved, but not the way you think. But you are correct, the version I have is 0.6. Updates back to 0.6So I run the update process:
I expected it to be 0.6.5 now, but nope:
Updates to 0.6.5
Here I don't even need to check the version number as it says it in the process above. Anyway, Maybe the issue is the command line tool? I use the built in cmd.exe (Windows Termial / command prompt). |
Interesting, when I ran the mentioned command with |
It's me who shall be thanking you for all the effort to solve this problem. Great thanks! =) As a sidenote, I run |
Fails
Result
Works
Result
The text was updated successfully, but these errors were encountered: