32function dolMd2Html($content, $parser =
'parsedown', $replaceimagepath =
null)
35 $content = preg_replace(
'/<a href="([^"]+)">([^<]+)<\/a>/',
'[\2](\1)', $content);
37 $content = preg_replace(
'/<a href="([^"]+)" target="([^"]+)">([^<]+)<\/a>/',
'[\3](\1)', $content);
40 $content = preg_replace(
'/<!--.*-->/Ums',
'', $content);
42 if (is_array($replaceimagepath)) {
43 foreach ($replaceimagepath as $key => $val) {
44 $keytoreplace =
']('.$key;
45 $valafter =
']('.$val;
46 $content = preg_replace(
'/'.preg_quote($keytoreplace,
'/').
'/m', $valafter, $content);
49 if ($parser ==
'parsedown') {
50 include_once DOL_DOCUMENT_ROOT.
'/includes/parsedown/Parsedown.php';
51 $parsedown =
new Parsedown();
52 $parsedown->setSafeMode(
true);
55 $content = preg_replace(
'/<span style="([^"]+)">/',
'<!-- SPAN_STYLE_\1 -->', $content);
56 $content = preg_replace(
'/<\/span>/',
'<!-- SPAN_END -->', $content);
58 $content = $parsedown->text($content);
60 $content = preg_replace(
'/<!-- SPAN_STYLE_([^-]+) -->/',
'<span style="\1">', $content);
61 $content = preg_replace(
'/<!-- SPAN_END -->/',
'</span>', $content);
63 $content = nl2br($content);