You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just made an extension that makes an invisible wrapper around any block. Contents are parsed as usual. It wraps any other text in a div so you have more possibilities with CSS and JS.
For example, in our CMS I want our writers to be able to add a setlist when writing a concert review:
...setlist
Intro
Song 1
Song 2
...
I know this could have been done using
```setlist
Intro
Song 1
Song 2
```
but the following could not. I wanted our writers to be able to add an image gallery.
I could not have a list of images inside en fenced code block since the images would not be parsed. And having images in a list is not enough, since a list could be used someplace else as well.
So I needed an invisible wrapper with a class. Now I can have CSS and JS targeting the .gallery ul.
Using a wrapper with a class I can save some time finding extra codes and extensions. That way I keep ParsedownExtra smaller and put more control into CSS and JS.
Maybe this is interesting in some way for ParsedownExtra. Most code was copied from the blockQuote and blockQuoteContinues methods.
publicfunction__construct()
{
// add a new block type: tripe period plus class name$this->BlockTypes['.'] = array('Wrap');
}
protectedfunctionblockWrap($Line)
{
// check for the triple period (or more) plus class nameif (preg_match('/^\.{3,}[ ]?(.*)/', $Line['text'], $matches)) {
$Block = array(
'element' => array(
'name' => 'div',
'handler' => 'lines',
'attributes' => ['class' => $matches[1]],
),
);
return$Block;
}
}
protectedfunctionblockWrapContinue($Line, array$Block)
{
if ($Line['text'][0] === '.' and preg_match('/^\.{3,}[ ]?(.*)/', $Line['text'], $matches)) {
if (isset($Block['interrupted'])) {
$Block['element']['text'] []= '';
unset($Block['interrupted']);
}
$Block['element']['text'] []= $matches[1];
return$Block;
}
if ( ! isset($Block['interrupted'])) {
$Block['element']['text'] []= $Line['text'];
return$Block;
}
}
The text was updated successfully, but these errors were encountered:
Just realized that this is not a fenced block. The block ends when there is a blank line. Hm, still having a problem with the wrapper, then. I'd prefer a wrapper being fenced but with the contents being parsed.
I just made an extension that makes an invisible wrapper around any block. Contents are parsed as usual. It wraps any other text in a
div
so you have more possibilities with CSS and JS.For example, in our CMS I want our writers to be able to add a setlist when writing a concert review:
I know this could have been done using
but the following could not. I wanted our writers to be able to add an image gallery.
I could not have a list of images inside en fenced code block since the images would not be parsed. And having images in a list is not enough, since a list could be used someplace else as well.
So I needed an invisible wrapper with a class. Now I can have CSS and JS targeting the
.gallery ul
.Using a wrapper with a class I can save some time finding extra codes and extensions. That way I keep ParsedownExtra smaller and put more control into CSS and JS.
Maybe this is interesting in some way for ParsedownExtra. Most code was copied from the blockQuote and blockQuoteContinues methods.
The text was updated successfully, but these errors were encountered: