aboutsummaryrefslogtreecommitdiffstats
path: root/include/markdown.php
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2018-09-28 15:46:14 +0200
committerMax Kostikov <max@kostikov.co>2018-09-28 15:46:14 +0200
commit4a904fa3a8af1c101ede76657249fb7eb47faf60 (patch)
tree544509813fb68579ef2b556ce879a971d183269a /include/markdown.php
parentf5f6ec3d71acb3e0488386819d5060e59331ec23 (diff)
parentc13d7e29ef9676b0f0e4ae23aa52e203f4ad8895 (diff)
downloadvolse-hubzilla-4a904fa3a8af1c101ede76657249fb7eb47faf60.tar.gz
volse-hubzilla-4a904fa3a8af1c101ede76657249fb7eb47faf60.tar.bz2
volse-hubzilla-4a904fa3a8af1c101ede76657249fb7eb47faf60.zip
Merge branch 'patch-29' into 'dev'
Patch 29 See merge request Kostikov/core!3
Diffstat (limited to 'include/markdown.php')
-rw-r--r--include/markdown.php10
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('&lt;','&gt;','&amp;'),array('&_lt_;','&_gt_;','&_amp_;'),$Text);
+ // This might fix PHP Warning: DOMDocument::loadHTML(): htmlParseEntityRef: no name in Entity
+ $Text = str_replace("&", "&amp;", $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('&lt;','&gt;','&amp;'),$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
+}