diff options
Diffstat (limited to 'include/markdown.php')
-rw-r--r-- | include/markdown.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/markdown.php b/include/markdown.php index f4944e2cc..6af055366 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -251,10 +251,16 @@ function bb_to_markdown($Text, $options = []) { // Markdownify does not preserve previously escaped html entities such as <> and &. //$Text = str_replace(array('<','>','&'),array('&_lt_;','&_gt_;','&_amp_;'),$Text); + // This might fix PHP Warning: DOMDocument::loadHTML(): htmlParseEntityRef: no name in Entity + $Text = str_replace("&", "&", $Text); + // Now convert HTML to Markdown $Text = html2markdown($Text); + //html2markdown adds backslashes infront of hashes after a new line. remove them + $Text = str_replace("\n\#", "\n#", $Text); + // It also adds backslashes to our attempt at getting around the html entity preservation for some weird reason. //$Text = str_replace(array('&\\_lt\\_;','&\\_gt\\_;','&\\_amp\\_;'),array('<','>','&'),$Text); @@ -292,7 +298,7 @@ function bb_to_markdown($Text, $options = []) { */ function html2markdown($html,$options = []) { $markdown = ''; - + $environment = Environment::createDefaultEnvironment($options); $environment->addConverter(new TableConverter()); $converter = new HtmlConverter($environment); @@ -374,4 +380,4 @@ class TableConverter implements ConverterInterface { return array('table', 'tr', 'thead', 'td', 'tbody'); } -}
\ No newline at end of file +} |