Export: convert tables from HTML to Markdown

When exporting pages to Markdown, tables were still HTML. This is because `league/html-to-markdown` does not convert tables to Markdown by default, "because it is not part of the original Markdown syntax" (source: https://packagist.org/packages/league/html-to-markdown)
This commit is contained in:
William Edwards 2024-10-11 17:14:21 +02:00
parent 4dc75bad05
commit 8bc4c130cc

View File

@ -13,6 +13,7 @@ use League\HTMLToMarkdown\Converter\LinkConverter;
use League\HTMLToMarkdown\Converter\ListBlockConverter;
use League\HTMLToMarkdown\Converter\ListItemConverter;
use League\HTMLToMarkdown\Converter\PreformattedConverter;
use League\HTMLToMarkdown\Converter\TableConverter;
use League\HTMLToMarkdown\Converter\TextConverter;
use League\HTMLToMarkdown\Environment;
use League\HTMLToMarkdown\HtmlConverter;
@ -32,6 +33,8 @@ class HtmlToMarkdown
public function convert(): string
{
$converter = new HtmlConverter($this->getConverterEnvironment());
$converter->getEnvironment()->addConverter(new TableConverter());
$html = $this->prepareHtml($this->html);
return $converter->convert($html);