33function dolMd2Html($content, $parser =
'parsedown', $replaceimagepath =
null)
36 $content = preg_replace(
'/<a href="([^"]+)">([^<]+)<\/a>/',
'[\2](\1)', $content);
38 $content = preg_replace(
'/<a href="([^"]+)" target="([^"]+)">([^<]+)<\/a>/',
'[\3](\1)', $content);
41 $content = preg_replace(
'/<!--.*-->/Ums',
'', $content);
43 if (is_array($replaceimagepath)) {
44 foreach ($replaceimagepath as $key => $val) {
45 $keytoreplace =
']('.$key;
46 $valafter =
']('.$val;
47 $content = preg_replace(
'/'.preg_quote($keytoreplace,
'/').
'/m', $valafter, $content);
50 if ($parser ==
'parsedown') {
51 include_once DOL_DOCUMENT_ROOT.
'/includes/parsedown/Parsedown.php';
52 $parsedown =
new Parsedown();
53 $parsedown->setSafeMode(
true);
56 $content = preg_replace(
'/<span style="([^"]+)">/',
'<!-- SPAN_STYLE_\1 -->', $content);
57 $content = preg_replace(
'/<\/span>/',
'<!-- SPAN_END -->', $content);
59 $content = $parsedown->text($content);
61 $content = preg_replace(
'/<!-- SPAN_STYLE_([^-]+) -->/',
'<span style="\1">', $content);
62 $content = preg_replace(
'/<!-- SPAN_END -->/',
'</span>', $content);
64 $content = nl2br($content);