Closed idmx1 closed 5 years ago
Making class instance within the for-each loop will increase the memory used. But what happens when you do this?
foreach ($posts as &$postItem) {
$Parsedown = new ParsedownExtraPlugin;
// ... your code goes here
}
Hey, thanks for answering.
Just tried it but its the same result.
Updated my code to give you a full picture of what I am doing.
Actually based on your answer, this works:
foreach ($posts as &$postItem) {
$Parsedown->linkAttributes = function($Text, $Attributes, &$Element, $Internal) {
if (!$Internal) {
return [
'rel' => 'ugc',
'target' => '_blank'
];
}
return [];
};
// Code goes in here
}
This seems to be caused by inlineImage()
method that inherits to inlineLink()
method. In my extension, I need to alternately attach and unmount the linkAttributes
property on the image and link. I will mark this issue as a bug.
For quick fix, try to put this line next out of the if ( ... ) {}
statement.
I am using Parsedown to parse a text with links from MySQL.
As recommended in another answer on StackOverflow: https://stackoverflow.com/a/47148927/10415318 I am using the Parsedown Extra Plugin https://github.com/taufik-nurrohman/parsedown-extra-plugin
When doing the query and the foreach all I get is the first result to have a rel=ugc attribute, the other ones don't have it. The links render ok, just not the rel attribute.
Here is the PHP code I have: