mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 05:17:31 -05:00 
			
		
		
		
	Merge pull request #6376 from beganovich/v5-610
(v5) Process markdown on global level instead of line items
This commit is contained in:
		
						commit
						ec518b23e7
					
				@ -347,7 +347,7 @@ class Design extends BaseDesign
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $items = $this->transformLineItems($this->entity->line_items, $type);
 | 
					        $items = $this->transformLineItems($this->entity->line_items, $type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->processMarkdownOnLineItems($items);
 | 
					        // $this->processMarkdownOnLineItems($items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (count($items) == 0) {
 | 
					        if (count($items) == 0) {
 | 
				
			||||||
            return [];
 | 
					            return [];
 | 
				
			||||||
 | 
				
			|||||||
@ -12,6 +12,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\Services\PdfMaker;
 | 
					namespace App\Services\PdfMaker;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use League\CommonMark\CommonMarkConverter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PdfMaker
 | 
					class PdfMaker
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use PdfMakerUtilities;
 | 
					    use PdfMakerUtilities;
 | 
				
			||||||
@ -36,6 +38,9 @@ class PdfMaker
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private $options;
 | 
					    private $options;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** @var CommonMarkConverter */
 | 
				
			||||||
 | 
					    protected $commonmark;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct(array $data)
 | 
					    public function __construct(array $data)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->data = $data;
 | 
					        $this->data = $data;
 | 
				
			||||||
@ -43,6 +48,10 @@ class PdfMaker
 | 
				
			|||||||
        if (array_key_exists('options', $data)) {
 | 
					        if (array_key_exists('options', $data)) {
 | 
				
			||||||
            $this->options = $data['options'];
 | 
					            $this->options = $data['options'];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->commonmark = new CommonMarkConverter([
 | 
				
			||||||
 | 
					            'allow_unsafe_links' => false,
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function design(Design $design)
 | 
					    public function design(Design $design)
 | 
				
			||||||
 | 
				
			|||||||
@ -91,6 +91,10 @@ trait PdfMakerUtilities
 | 
				
			|||||||
        foreach ($children as $child) {
 | 
					        foreach ($children as $child) {
 | 
				
			||||||
            $contains_html = false;
 | 
					            $contains_html = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ($child['element'] !== 'script') {
 | 
				
			||||||
 | 
					                $child['content'] = $this->commonmark->convertToHtml($child['content'] ?? '');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (isset($child['content'])) {
 | 
					            if (isset($child['content'])) {
 | 
				
			||||||
                if (isset($child['is_empty']) && $child['is_empty'] === true) {
 | 
					                if (isset($child['is_empty']) && $child['is_empty'] === true) {
 | 
				
			||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user