Skip to content
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

Line 393: $Content is array when it should be string #29

Open
hexakon opened this issue Feb 8, 2022 · 4 comments
Open

Line 393: $Content is array when it should be string #29

hexakon opened this issue Feb 8, 2022 · 4 comments
Labels

Comments

@hexakon
Copy link

hexakon commented Feb 8, 2022

<?php
    require 'Parsedown.php';
    require 'ParsedownExtra.php';
    require 'ParsedownExtraPlugin.php';
    
    $Parsedown = new ParsedownExtraPlugin;

    echo $Parsedown->text($text);
?>

The above code prints the expected output when the class Parsedown or ParsedownExtra is used. When using ParsedownExtraPlugin, I get the following error and stack trace in the output log (with parts of the filepath omitted)

Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, array given in [C:\Users\...\docs\ParsedownExtraPlugin.php:393]()
Stack trace:
#0 [C:\Users\...\docs\ParsedownExtraPlugin.php]()(393): explode('\n', Array)
#1 [C:\Users\...\docs\ParsedownExtraPlugin.php]()(272): ParsedownExtraPlugin->doSetContent(Array, NULL, false, 'arguments')
#2 [C:\Users\...\docs\Parsedown.php]()(206): ParsedownExtraPlugin->blockQuoteComplete(Array)
#3 [C:\Users\...\docs\Parsedown.php]()(39): Parsedown->lines(Array)
#4 [C:\Users\...\docs\ParsedownExtra.php]()(46): Parsedown->text('In the beginnin...')
#5 [C:\Users\...\docs\read.php]()(57): ParsedownExtra->text('\n\r\nIn the begin...')
#6 {main}
  thrown in [C:\Users\...\docs\ParsedownExtraPlugin.php]() on line 393
@taufik-nurrohman
Copy link
Owner

Can you provide the minimum text input, so that I can test it myself?

@hexakon
Copy link
Author

hexakon commented Feb 9, 2022

here's the text I used:

In the beginning, the universe was created.

This line comes after a line break.

Can I inject html tags? <b>Lets see!</b>

> Here's a markdown quote and some *italics* and <u>underline</u> and ~~strike one~~
>
> additional quotes
>
> last row

1. one

2. two

* test

----

# test1

hi

![stoat](test/stoat.jpg)
 a humble stoate.

tested on php 8.1.2. It also doesn't work on 7.4.27, but I don't have the output log for it.

@taufik-nurrohman
Copy link
Owner

taufik-nurrohman commented Feb 9, 2022

Sorry, cannot reproduce the issue. Have you checked this pull request?

<?php

require 'vendor/autoload.php';

$Parsedown = new ParsedownExtraPlugin;

$text = <<<S
In the beginning, the universe was created.

This line comes after a line break.

Can I inject html tags? <b>Lets see!</b>

> Here's a markdown quote and some *italics* and <u>underline</u> and ~~strike one~~
>
> additional quotes
>
> last row

1. one

2. two

* test

----

# test1

hi

![stoat](test/stoat.jpg)
 a humble stoate.
S;

echo '<p><mark>' . PHP_VERSION . '</mark></p>';

echo $Parsedown->text($text);

?>

Screenshot 2022-02-09 at 22-56-49 Screenshot

@hexakon
Copy link
Author

hexakon commented Feb 9, 2022

I've downdated ParsedownExtra to 0.8.0 and now receive this error log instead:

Fatal error: Uncaught Exception: Method textElements does not exists. in [C:\Users\...\docs\ParsedownExtraPlugin.php:86]()
Stack trace:
#0 [C:\Users\Coda\...\docs\ParsedownExtra.php]()(46): ParsedownExtraPlugin->__call('textElements', Array)
#1 [C:\Users\Coda\...\docs\read.php]()(62): ParsedownExtra->text('\nIn the beginni...')
#2 {main}
  thrown in [C:\Users\...\docs\ParsedownExtraPlugin.php]() on line 86

If it helps, I'm not using composer.

EDIT: I know this is unrelated to the plugin, but I just noticed that ParsedownExtra 0.8.0 doesn't work for me either (0.8.1 works fine). I get the following error log when I use the ParsedownExtra class (not ParsedownExtraPlugin), maybe it can be of some help:

Fatal error: Uncaught Error: Call to undefined method ParsedownExtra::textElements() in [C:\Users\...\docs\ParsedownExtra_0.8.0.php:46]()
Stack trace:
#0 [C:\Users\...\docs\read.php]()(62): ParsedownExtra->text('\nIn the beginni...')
#1 {main}
  thrown in [C:\Users\...\docs\ParsedownExtra_0.8.0.php]() on line 46

the undefined method in question, textElements(), was replaced in 0.8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants