parsedown extension for bulma tables

This commit is contained in:
tp_dhu 2025-03-24 11:15:13 +00:00
parent 8c8de5ec34
commit 53bce00c65
4 changed files with 36 additions and 7 deletions

View File

@ -28,6 +28,7 @@ GET /ticket/@id/attachments=AttachmentController->index
POST /ticket/@id/attachments/upload=AttachmentController->upload POST /ticket/@id/attachments/upload=AttachmentController->upload
GET /attachment/@id/download=AttachmentController->download GET /attachment/@id/download=AttachmentController->download
GET /attachment/@id/delete=AttachmentController->delete GET /attachment/@id/delete=AttachmentController->delete
GET /attachment/@id/view=AttachmentController->view
; knowledgebase ; knowledgebase
GET /kb=KBController->index GET /kb=KBController->index

View File

@ -8,7 +8,7 @@ class ParsedownHelper extends \Prefab {
$return = \Parsedown::instance()->text($args[0]); $return = \Parsedown::instance()->text($args[0]);
return ' return '<!-- tableextension -->
<div class="content"> <div class="content">
<parsedown_rendered>'.$return.'</parsedown_rendered> <parsedown_rendered>'.$return.'</parsedown_rendered>
</div> </div>
@ -28,7 +28,7 @@ class ParsedownHelper extends \Prefab {
} }
function build($content){ function build($content){
return Parsedown::instance()->text($content); return \ParsedownTableExtension::instance()->text($content);
} }
} }

View File

@ -0,0 +1,28 @@
<?php
class ParsedownTableExtension extends Parsedown
{
protected function blockTable($Line, ?array $Block = null)
{
$Block = parent::blockTable($Line, $Block);
if(!isset($Block)){
return null;
}
// add classes to the table element
$Block['element']['attributes'] = [
'class' => 'table is-bordered',
];
// wrap the table in a bulma div
$Block['element'] = [
'name' => 'div',
'attributes' => [
'class' => 'table-container'
],
'handler' => 'element',
'text' => $Block['element'],
];
return $Block;
}
}

View File

@ -3,18 +3,18 @@
require '../lib/autoload.php'; require '../lib/autoload.php';
$f3 = \Base::instance(); $f3 = \Base::instance();
$f3->config('../app/config/.env.cfg');
$f3->set('DEBUG', 3); // development debug
$f3->set('CACHE', FALSE);
/** /**
* Not required yet * Not required yet
*/ */
$htmlpurifier = \HTMLPurifier::instance(); $htmlpurifier = \HTMLPurifier::instance();
// $htmlpurifier->purify($input); // $htmlpurifier->purify($input);
$md = \Parsedown::instance(); $md = \ParsedownTableExtension::instance();
$md->setSafeMode(true); $md->setSafeMode(true);
$f3->config('../app/config/.env.cfg');
$f3->set('DEBUG', 3); // development debug
$f3->set('CACHE', FALSE);
$f3->set('EXT', [new ParsedownHelper, new BulmaFormHelper]); $f3->set('EXT', [new ParsedownHelper, new BulmaFormHelper]);
$f3->set('DB', new \DB\SQL( $f3->set('DB', new \DB\SQL(