mirror of
https://github.com/getgrav/grav.git
synced 2026-02-26 08:31:42 +01:00
added optional options to noprocess (#2954)
* added optional options to noprocess * fix minor bug with skip and better naming * Added tests Signed-off-by: Andy Miller <rhuk@mac.com> * Added some tests Signed-off-by: Andy Miller <rhuk@mac.com> Co-authored-by: Ricardo <ricardo@urbansquid.london> Co-authored-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
@@ -104,12 +104,16 @@ class Excerpts
|
||||
// Valid attributes supported.
|
||||
$valid_attributes = Grav::instance()['config']->get('system.pages.markdown.valid_link_attributes');
|
||||
|
||||
$skip = [];
|
||||
// Unless told to not process, go through actions.
|
||||
if (array_key_exists('noprocess', $actions)) {
|
||||
$skip = is_bool($actions['noprocess']) ? $actions : explode(',', $actions['noprocess']);
|
||||
unset($actions['noprocess']);
|
||||
} else {
|
||||
// Loop through actions for the image and call them.
|
||||
foreach ($actions as $attrib => $value) {
|
||||
}
|
||||
|
||||
// Loop through actions for the image and call them.
|
||||
foreach ($actions as $attrib => $value) {
|
||||
if (!in_array($attrib, $skip)) {
|
||||
$key = $attrib;
|
||||
|
||||
if (in_array($attrib, $valid_attributes, true)) {
|
||||
|
||||
@@ -87,4 +87,34 @@ class ExcerptsTest extends \Codeception\TestCase\Test
|
||||
Excerpts::processImageHtml('<img src="sample-image.jpg?classes=foo" alt="Sample Image" />', $this->page)
|
||||
);
|
||||
}
|
||||
|
||||
public function testNoProcess()
|
||||
{
|
||||
$this->assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?hl=de" id="org.jitsi.meet" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank">regular process</a>')
|
||||
);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank&noprocess">noprocess</a>')
|
||||
);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?id=org.jitsi.meet&hl=de&target=_blank&noprocess=id">noprocess=id</a>')
|
||||
);
|
||||
}
|
||||
|
||||
public function testTarget()
|
||||
{
|
||||
$this->assertStringStartsWith(
|
||||
'<a href="https://play.google.com/store/apps/details" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://play.google.com/store/apps/details?target=_blank">only target</a>')
|
||||
);
|
||||
$this->assertStringStartsWith(
|
||||
'<a href="https://meet.weikamp.biz/Support" rel="nofollow" target="_blank"',
|
||||
Excerpts::processLinkHtml('<a href="https://meet.weikamp.biz/Support?rel=nofollow&target=_blank">target and rel</a>')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user