1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for parsing markdown in pdf tables

This commit is contained in:
David Bomba 2022-02-07 12:31:14 +11:00
parent 5897a4e749
commit 35c80583c4
4 changed files with 15 additions and 12 deletions

View File

@ -382,22 +382,23 @@ document.addEventListener('DOMContentLoaded', function() {
return $converter->convertToHtml($markdown);
}
public function processMarkdownOnLineItems(array &$items): void
{
foreach ($items as $key => $item) {
foreach ($item as $variable => $value) {
$item[$variable] = DesignHelpers::parseMarkdownToHtml($value ?? '');
}
// public function processMarkdownOnLineItems(array &$items): void
// {
// foreach ($items as $key => $item) {
// foreach ($item as $variable => $value) {
// $item[$variable] = DesignHelpers::parseMarkdownToHtml($value ?? '');
// }
$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);
// $item[$variable] = nl2br($value, true);
$item[$variable] = str_replace( "\n", '<br>', $value);
}
$items[$key] = $item;

View File

@ -51,6 +51,7 @@ class PdfMaker
$this->commonmark = new CommonMarkConverter([
'allow_unsafe_links' => false,
// 'html_input' => 'allow',
]);
}

View File

@ -92,7 +92,9 @@ trait PdfMakerUtilities
$contains_html = false;
if ($child['element'] !== 'script') {
if (array_key_exists('process_markdown', $this->data) && $this->data['process_markdown']) {
if (array_key_exists('process_markdown', $this->data) && array_key_exists('content', $child) && $this->data['process_markdown']) {
$child['content'] = str_replace("<br>", "\r", $child['content']);
$child['content'] = $this->commonmark->convertToHtml($child['content'] ?? '');
}
}

View File

@ -44,7 +44,6 @@
"eway/eway-rapid-php": "^1.3",
"fakerphp/faker": "^1.14",
"fideloper/proxy": "^4.2",
"firebase/php-jwt": "^5",
"fruitcake/laravel-cors": "^2.0",
"gocardless/gocardless-pro": "^4.12",
"google/apiclient": "^2.7",