nl2br on line items

This commit is contained in:
Benjamin Beganović 2021-08-09 16:49:12 +02:00
parent 49bb80b328
commit 5a4e009960
3 changed files with 14 additions and 3 deletions

View File

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

View File

@ -331,7 +331,7 @@ document.addEventListener('DOMContentLoaded', function() {
return $converter->convertToHtml($markdown); return $converter->convertToHtml($markdown);
} }
public function processMarkdownOnLineItems(array &$items) public function processMarkdownOnLineItems(array &$items): void
{ {
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
foreach ($item as $variable => $value) { foreach ($item as $variable => $value) {
@ -341,4 +341,15 @@ document.addEventListener('DOMContentLoaded', function() {
$items[$key] = $item; $items[$key] = $item;
} }
} }
public function processNewLines(array &$items): void
{
foreach ($items as $key => $item) {
foreach ($item as $variable => $value) {
$item[$variable] = nl2br($value);
}
$items[$key] = $item;
}
}
} }

View File

@ -94,8 +94,6 @@ trait PdfMakerUtilities
if ($child['element'] !== 'script') { if ($child['element'] !== 'script') {
if (array_key_exists('process_markdown', $this->data) && $this->data['process_markdown']) { if (array_key_exists('process_markdown', $this->data) && $this->data['process_markdown']) {
$child['content'] = $this->commonmark->convertToHtml($child['content'] ?? ''); $child['content'] = $this->commonmark->convertToHtml($child['content'] ?? '');
} else {
$child['content'] = array_key_exists('content', $child) ? nl2br($child['content']) : '';
} }
} }