diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 9c5fff50464a..86677305d5f8 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -347,7 +347,7 @@ class Design extends BaseDesign $items = $this->transformLineItems($this->entity->line_items, $type); - $this->processMarkdownOnLineItems($items); + // $this->processMarkdownOnLineItems($items); if (count($items) == 0) { return []; diff --git a/app/Services/PdfMaker/PdfMaker.php b/app/Services/PdfMaker/PdfMaker.php index aa98de169941..aded4c4a54fe 100644 --- a/app/Services/PdfMaker/PdfMaker.php +++ b/app/Services/PdfMaker/PdfMaker.php @@ -12,6 +12,8 @@ namespace App\Services\PdfMaker; +use League\CommonMark\CommonMarkConverter; + class PdfMaker { use PdfMakerUtilities; @@ -36,6 +38,9 @@ class PdfMaker private $options; + /** @var CommonMarkConverter */ + protected $commonmark; + public function __construct(array $data) { $this->data = $data; @@ -43,6 +48,10 @@ class PdfMaker if (array_key_exists('options', $data)) { $this->options = $data['options']; } + + $this->commonmark = new CommonMarkConverter([ + 'allow_unsafe_links' => false, + ]); } public function design(Design $design) diff --git a/app/Services/PdfMaker/PdfMakerUtilities.php b/app/Services/PdfMaker/PdfMakerUtilities.php index 8ce5622896cf..19e60b6a8be2 100644 --- a/app/Services/PdfMaker/PdfMakerUtilities.php +++ b/app/Services/PdfMaker/PdfMakerUtilities.php @@ -91,6 +91,10 @@ trait PdfMakerUtilities foreach ($children as $child) { $contains_html = false; + if ($child['element'] !== 'script') { + $child['content'] = $this->commonmark->convertToHtml($child['content'] ?? ''); + } + if (isset($child['content'])) { if (isset($child['is_empty']) && $child['is_empty'] === true) { continue;