* Shaare's descriptions are parsed with Markdown.
*/
+use Shaarli\Config\ConfigManager;
+
/*
* If this tag is used on a shaare, the description won't be processed by Parsedown.
*/
$value = stripNoMarkdownTag($value);
continue;
}
+ $value['description_src'] = $value['description'];
$value['description'] = process_markdown(
$value['description'],
$conf->get('security.markdown_escape', true),
$value = stripNoMarkdownTag($value);
continue;
}
+ $value['description'] = reverse_feed_permalink($value['description']);
$value['description'] = process_markdown(
$value['description'],
$conf->get('security.markdown_escape', true),
|| $data['_PAGE_'] == Router::$PAGE_DAILY
|| $data['_PAGE_'] == Router::$PAGE_EDITLINK
) {
-
$data['css_files'][] = PluginManager::$PLUGINS_PATH . '/markdown/markdown.css';
}
// Detect and toggle block of code
if (!$codeBlockOn) {
$codeBlockOn = preg_match('/^```/', $descriptionLine) > 0;
- }
- elseif (preg_match('/^```/', $descriptionLine) > 0) {
+ } elseif (preg_match('/^```/', $descriptionLine) > 0) {
$codeBlockOn = false;
}
$descriptionLine
);
+ // Make hashtag links markdown ready, otherwise the links will be ignored with escape set to true
+ if (!$codeBlockOn && !$codeLineOn) {
+ $descriptionLine = preg_replace(
+ '#<a href="([^ ]*)"'. $hashtagTitle .'>([^<]+)</a>#m',
+ '[$2]($1)',
+ $descriptionLine
+ );
+ }
+
$descriptionOut .= $descriptionLine;
if ($lineCount++ < count($descriptionLines) - 1) {
$descriptionOut .= PHP_EOL;
return preg_replace('/(^| ) /m', '$1 ', $description);
}
+function reverse_feed_permalink($description)
+{
+ return preg_replace('@— <a href="([^"]+)" title="[^"]+">(\w+)</a>$@im', '— [$2]($1)', $description);
+}
+
/**
* Replace not whitelisted protocols with http:// in given description.
*
foreach ($escapeTags as $tag) {
$description = preg_replace_callback(
'#<\s*'. $tag .'[^>]*>(.*</\s*'. $tag .'[^>]*>)?#is',
- function ($match) { return escape($match[0]); },
- $description);
+ function ($match) {
+ return escape($match[0]);
+ },
+ $description
+ );
}
$description = preg_replace(
'#(<[^>]+\s)on[a-z]*="?[^ "]*"?#is',
'$1',
- $description);
+ $description
+ );
return $description;
}
->text($processedDescription);
$processedDescription = sanitize_html($processedDescription);
- if(!empty($processedDescription)){
+ if (!empty($processedDescription)) {
$processedDescription = '<div class="markdown">'. $processedDescription . '</div>';
}