mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-10 19:41:26 +01:00
Fix dolMd2Html
This commit is contained in:
@@ -31,6 +31,14 @@
|
|||||||
*/
|
*/
|
||||||
function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null)
|
function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null)
|
||||||
{
|
{
|
||||||
|
// Replace a HTML string with a Markdown syntax
|
||||||
|
$content = preg_replace('/<a href="([^"]+)">([^<]+)<\/a>/', '[\2](\1)', $content);
|
||||||
|
//$content = preg_replace('/<a href="([^"]+)" target="([^"]+)">([^<]+)<\/a>/', '[\3](\1){:target="\2"}', $content);
|
||||||
|
$content = preg_replace('/<a href="([^"]+)" target="([^"]+)">([^<]+)<\/a>/', '[\3](\1)', $content);
|
||||||
|
|
||||||
|
// Replace HTML coments
|
||||||
|
$content = preg_replace('/<!--.*-->/ms', '', $content); // We remove HTML comment that are not MD comment because they will be escaped and output when setSafeMode is set to true.
|
||||||
|
|
||||||
if (is_array($replaceimagepath)) {
|
if (is_array($replaceimagepath)) {
|
||||||
foreach ($replaceimagepath as $key => $val) {
|
foreach ($replaceimagepath as $key => $val) {
|
||||||
$keytoreplace = ']('.$key;
|
$keytoreplace = ']('.$key;
|
||||||
|
|||||||
@@ -683,11 +683,6 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||||||
if ((float) DOL_VERSION >= 6.0) {
|
if ((float) DOL_VERSION >= 6.0) {
|
||||||
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
|
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
|
||||||
|
|
||||||
// Replace a HTML string with a Markdown syntax
|
|
||||||
$content = preg_replace('/<a href="([^"]+)">([^<]+)<\/a>/', '[\2](\1)', $content);
|
|
||||||
//$content = preg_replace('/<a href="([^"]+)" target="([^"]+)">([^<]+)<\/a>/', '[\3](\1){:target="\2"}', $content);
|
|
||||||
$content = preg_replace('/<a href="([^"]+)" target="([^"]+)">([^<]+)<\/a>/', '[\3](\1)', $content);
|
|
||||||
|
|
||||||
$content = dolMd2Html(
|
$content = dolMd2Html(
|
||||||
$content,
|
$content,
|
||||||
'parsedown',
|
'parsedown',
|
||||||
@@ -788,6 +783,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
|||||||
|
|
||||||
if ((float) DOL_VERSION >= 6.0) {
|
if ((float) DOL_VERSION >= 6.0) {
|
||||||
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
|
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
|
||||||
|
|
||||||
$content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1)));
|
$content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1)));
|
||||||
} else {
|
} else {
|
||||||
$content = nl2br($content);
|
$content = nl2br($content);
|
||||||
|
|||||||
Reference in New Issue
Block a user