Closed anasram closed 4 years ago
Try creating a plugin like the following:
class FigureExtParsedownPicoPlugin extends AbstractPicoPlugin
{
public function onParsedownRegistered(Parsedown &$parsedown)
{
$config = $this->getPico()->getConfig();
$parsedown = new FigureExtParsedown();
$parsedown->setBreaksEnabled((bool) $config['content_config']['breaks']);
$parsedown->setMarkupEscaped((bool) $config['content_config']['escape']);
$parsedown->setUrlsLinked((bool) $config['content_config']['auto_urls']);
}
}
Okay? then? 😕
Actually, I don't speak PHP 😳
Maybe I had to write this issue in a different way:
Plugin Proposal
Any one here interested to build a Pico plugin based on FigureExtParsedown Class gist?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:
Not sure whether someone is going to create a "real" plugin for it and particularly implement the additional features you were asking for, however, the code I provided should do at least the basic job of wrapping images in <figure>
.
Simply create a plugins/FigureExtParsedownPicoPlugin/
folder, copy the FigureExtParsedown.php
from the gist to this folder and create a FigureExtParsedownPicoPlugin.php
with the following contents:
class FigureExtParsedownPicoPlugin extends AbstractPicoPlugin
{
public function __construct(Pico $pico)
{
parent::__construct($pico);
require_once(__DIR__ . '/FigureExtParsedown.php');
}
public function onParsedownRegistered(Parsedown &$parsedown)
{
$config = $this->getPico()->getConfig();
$parsedown = new FigureExtParsedown();
$parsedown->setBreaksEnabled((bool) $config['content_config']['breaks']);
$parsedown->setMarkupEscaped((bool) $config['content_config']['escape']);
$parsedown->setUrlsLinked((bool) $config['content_config']['auto_urls']);
}
}
Here's it so far: FigureExtParsedownPicoPlugin.zip.
Didn't work; still wrapping images in <p>
.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:
Whoops, there's the API version missing...
class FigureExtParsedownPicoPlugin extends AbstractPicoPlugin
{
const API_VERSION = 2;
public function __construct(Pico $pico)
{
parent::__construct($pico);
require_once(__DIR__ . '/FigureExtParsedown.php');
}
public function onParsedownRegistered(Parsedown &$parsedown)
{
$config = $this->getPico()->getConfig();
$parsedown = new FigureExtParsedown();
$parsedown->setBreaksEnabled((bool) $config['content_config']['breaks']);
$parsedown->setMarkupEscaped((bool) $config['content_config']['escape']);
$parsedown->setUrlsLinked((bool) $config['content_config']['auto_urls']);
}
}
Great, Thank you so much!
It works properly now.
After considering a figcaption
bug, here's the final work: FigureExtParsedownPicoPlugin.zip.
I think it will be nice if you could publish it officially, with the following TODO list:
height
and width
attributes and values.<picture>
too in some cases.Thanx!
Recently I found a Parsedown extension wraps single-image lines in
<figure>
element instead of<p>
: FigureExtParsedown.class.php.Any one here interested to build a Pico plugin based on it?
Notice that this gist still lacks several features:
height
andwidth
attributes and values.<picture>
too in some cases.