erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.69k stars 1.12k forks source link

Recommended way of getting Smartypants (or equivalent) with Parsedown? #766

Open dajare opened 4 years ago

dajare commented 4 years ago

I would like to use the Smartypants "extension" set for typography with Parsedown, but cannot source the correct package. There is PHP SmartyPants, but I'm not sure how well it would play with Parsedown (or whether it would "play" at all!).

I have looked at Parsedown Extra, but haven't see this issue referenced there, either.

There is probably something obvious I am missing, but if there was some guidance on this question, that would be a huge help. Thanks!

aidantwoods commented 4 years ago

Having a quick look at the PHP library, it indicates:

If you are using PHP SmartyPants with another text filter function that generates HTML such as Markdown, you should filter the text after the HTML-generating filter. This is an example with PHP Markdown:

use Michelf\Markdown, Michelf\SmartyPants;
$my_html = Markdown::defaultTransform($my_text);
$my_html = SmartyPants::defaultTransform($my_html);

It would seem that the extension can cope with HTML being passed as input, have you tried passing the output from Parsedown into PHP SmartyPants?

dajare commented 4 years ago

Thanks, Aidan - will look into that and update this thread. Grateful for your swift reply!