[^ ]+!m', '$1', $description);
}
/**
* Remove
tag to let markdown handle it.
*
* @param string $description input description text.
*
* @return string $description without
tags.
*/
function reverse_nl2br($description)
{
return preg_replace('!
!im', '', $description);
}
/**
* Remove HTML spaces ' ' auto generated by Shaarli core system.
*
* @param string $description input description text.
*
* @return string $description without HTML links.
*/
function reverse_space2nbsp($description)
{
return preg_replace('/(^| ) /m', '$1 ', $description);
}
/**
* Remove '>' at start of line auto generated by Shaarli core system
* to allow markdown blockquotes.
*
* @param string $description input description text.
*
* @return string $description without HTML links.
*/
function reset_quote_tags($description)
{
return preg_replace('/^( *)> /m', '$1> ', $description);
}
/**
* Render shaare contents through Markdown parser.
* 1. Remove HTML generated by Shaarli core.
* 2. Generate markdown descriptions.
* 3. Wrap description in 'markdown' CSS class.
*
* @param string $description input description text.
*
* @return string HTML processed $description.
*/
function process_markdown($description)
{
$parsedown = new Parsedown();
$processedDescription = $description;
$processedDescription = reverse_text2clickable($processedDescription);
$processedDescription = reverse_nl2br($processedDescription);
$processedDescription = reverse_space2nbsp($processedDescription);
$processedDescription = reset_quote_tags($processedDescription);
$processedDescription = $parsedown
->setMarkupEscaped(false)
->setBreaksEnabled(true)
->text($processedDescription);
$processedDescription = '