Markdown parsing for line items

This commit is contained in:
Benjamin Beganović 2021-05-31 14:08:24 +02:00
parent c9334daa3f
commit d701125bf1
3 changed files with 20 additions and 1 deletions

View File

@ -346,6 +346,8 @@ class Design extends BaseDesign
$items = $this->transformLineItems($this->entity->line_items, $type);
$this->processMarkdownOnLineItems($items);
if (count($items) == 0) {
return [];
}

View File

@ -330,4 +330,18 @@ document.addEventListener('DOMContentLoaded', function() {
return $converter->convertToHtml($markdown);
}
public function processMarkdownOnLineItems(array &$items)
{
// Use setting to determinate if parsing should be done.
// 'parse_markdown_on_pdfs'
foreach ($items as $key => $item) {
foreach ($item as $variable => $value) {
$item[$variable] = DesignHelpers::parseMarkdownToHtml($value ?? '');
}
$items[$key] = $item;
}
}
}

View File

@ -92,7 +92,10 @@ trait PdfMakerUtilities
$contains_html = false;
if (isset($child['content'])) {
$child['content'] = nl2br($child['content']);
// Commented cause it keeps adding <br> at the end, if markdown parsing is turned on.
// Should update with 'parse_markdown_on_pdfs' setting.
// $child['content'] = nl2br($child['content']);
}
// "/\/[a-z]*>/i" -> checks for HTML-like tags: