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

Checkbox parser removes mentions and internal links #3

Closed
tomaszstrojny opened this issue Mar 12, 2021 · 14 comments
Closed

Checkbox parser removes mentions and internal links #3

tomaszstrojny opened this issue Mar 12, 2021 · 14 comments

Comments

@tomaszstrojny
Copy link

After installing the plugin, all the comments and descriptions are cleared from the internal links and @mentions.

I've tracked down it's because of the ParsedownCheckbox, emojis work fine.

My current code for the MarkdownPlusHelper->markdown() looks like this, and it works:

    public function markdown($text, $isPublicLink = false)
    {
        $emoji = new Client(new Ruleset());
        $parser = new Markdown($this->container, $isPublicLink);
        $parsecheckbox = new ParsedownCheckbox();
        if ($this->configModel->get('unicode_shortcode', '2') == 1) {
            $text = $emoji->shortnameToUnicode($text);
        } else {
            $text = $emoji->toImage($text);
        }

        // $parser->setMarkupEscaped(MARKDOWN_ESCAPE_HTML);
        $text = $parser->text($text);
        // $text = $parsecheckbox->text($text);

        return $text;
    }

While I try to add the parsecheckbox in any other place, it's escaping the links. It generally makes sense, but I would like to have both of them and don't know how to touch it. Do you have any suggestions?

@creecros
Copy link
Owner

anyway you could include a screenshot or gif showing me the issue? it's been a long time since I really used kanboard so not sure I even know what you're talking about. point me in the right direction.

@tomaszstrojny
Copy link
Author

Sure! Thanks for the response :)

For the code I've pasted above I am getting such a content:
image

When I comment the $text = $parser->text($text); and uncomment the // $text = $parsecheckbox->text($text); I'm getting something like this:
image

As you can see, the checkbox is rendered correctly, but the links under @admin and #1 disappeared.

@creecros
Copy link
Owner

creecros commented Mar 12, 2021

OK, I understand now.

and what's the non preview of that link code look like?

is it markdown or html? or does it just link with #1 oh and the @

@creecros
Copy link
Owner

nm I see it autofills... I'll take a look, probably some js stuff goin on with that, I wasn't even aware of it.

@tomaszstrojny
Copy link
Author

From what I observe, it's in PHP.

The methods meant to build the internal link and users (defined in the Core/Kanboard) are not run when we use the checkbox parser. I'm tracing the execution with xdebug and it just doesn't run it. It's like the Core/Markdown parser runs or the ParsedownCheckbox - I cannot get both of them working on the same content.

@tomaszstrojny
Copy link
Author

OK, I understand now.

and what's the non preview of that link code look like?

is it markdown or html? or does it just link with #1 oh and the @

Generally in Kanboard internal links are created by the core parser, which looks for @ and #, give suggestions and then parse them as links. @mentions to users and #123 to tasks.

For the not parsed version HTML looks like that:

<article class="markdown">
    <p>test @admin <img class="emojione" alt="" title=":arrow_up_down:" src="https://cdn.jsdelivr.net/emojione/assets/4.5/png/32/2195.png"> #1 </p>
    <input type="checkbox" disabled=""> ates        
</article>

on the other hand we have this:

<article class="markdown">
    <p>test <a href="/?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link" title="admin" aria-label="admin">@admin</a> <img class="emojione" alt="" title=":arrow_up_down:" src="https://cdn.jsdelivr.net/emojione/assets/4.5/png/32/2195.png"> <a href="/?controller=TaskViewController&amp;action=show&amp;task_id=1">#1</a>
    </p>
    <p>[ ] ates</p>        
</article>

@creecros
Copy link
Owner

see, you know more than I do! I'll definitely take a look and see what I can come up with, might just take me a while to get the chance though. if I'm lucky, you solve it before me 😄

@creecros
Copy link
Owner

i figured out whats going on. had to come up with a workaround, but long story short, the core markdown extends Parsedown, i had to back it out and extend ParsedownCheckbox, which extends Parsedown extra, and then add to the construct to get it to run them all.

image

creecros added a commit that referenced this issue Mar 15, 2021
@creecros
Copy link
Owner

@tomaszstrojny givee it a test drive, hopefully i didn't screw anything up fixing it

@creecros
Copy link
Owner

creecros commented Mar 15, 2021

well, now i'm getting an error, and I'm out of time for the day. to be continued:
2021/03/15 15:21:41 [error] 16#16: *202 FastCGI sent in stderr: "PHP message: PHP Notice: Trying to access array offset on value of type null in /var/www/app/plugins/MarkdownPlus/vendor/erusev/parsedown-extra/ParsedownExtra.php on line 241PHP message: PHP Notice: Trying to access array offset on value of type null in /var/www/app/plugins/MarkdownPlus/vendor/erusev/parsedown-extra/ParsedownExtra.php on line 241" while reading response header from upstream, client: 172.17.0.3, server: localhost, request: "GET /project/4/task/110 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "projects.divdist.com"

@creecros
Copy link
Owner

@tomaszstrojny ok, so no errors, and all appears to correctly be parsing...let me know if you see anymore issues.

@creecros
Copy link
Owner

reopen if you find any issues, closing for now.

@tomaszstrojny
Copy link
Author

Changes in the vendor directory is always a lot of fun :)

Anyway, everything works nice now, thanks!

@creecros
Copy link
Owner

I know, I hated to do it, but really had no choice.

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

No branches or pull requests

2 participants