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

Fix markdown modifier with custom parser #3373

Merged
merged 2 commits into from
Mar 19, 2021
Merged

Conversation

lorisleiva
Copy link
Contributor

Hi there 👋

Just a quick little bug I've noticed.

When creating a custom parser as per the documentation:

Markdown::extend('special', function ($parser) {
    return $parser
        ->withStatamicDefaults()
        ->addExtensions(...);
});

And then using this custom parser via the markdown modifier:

{{ text | markdown:special }}

It always uses the default markdown parser no matter what option we provide.

A quick check at the source code and I found that this check:

in_array($parser, [true, 'true', ''])

always returns true since it does not use strict comparison and "any_non_empty_string" == true.

This tiny PR fixes this by making the in_array strict.

@duncanmcclean
Copy link
Member

duncanmcclean commented Mar 15, 2021

Hey! Just wondering, do you know if this PR fixes any open issues? (it's fine if not) 😅

@lorisleiva
Copy link
Contributor Author

Hi! Surprisingly I couldn't find any on this repo. I must be the only one using the markdown modifier with a custom parser. 🤷‍♂️😅

@duncanmcclean
Copy link
Member

Hi! Surprisingly I couldn't find any on this repo. I must be the only one using the markdown modifier with a custom parser. 🤷‍♂️😅

Haha, that's fine. Just wanted to check.

@jasonvarga
Copy link
Member

Nice catch, thanks!

@jasonvarga jasonvarga merged commit a4347c7 into statamic:3.0 Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants