The tag is no longer private

A private tag is never loaded for visitor, making this feature useless.
This commit is contained in:
ArthurHoaro 2016-05-30 18:51:00 +02:00
parent 6d03a9b2b3
commit 8c4e60186d
2 changed files with 20 additions and 5 deletions

View file

@ -10,9 +10,8 @@ require_once 'Parsedown.php';
/*
* If this tag is used on a shaare, the description won't be processed by Parsedown.
* Using a private tag so it won't appear for visitors.
*/
define('NO_MD_TAG', '.nomarkdown');
define('NO_MD_TAG', 'nomarkdown');
/**
* Parse linklist descriptions.
@ -25,11 +24,11 @@ function hook_markdown_render_linklist($data)
{
foreach ($data['links'] as &$value) {
if (!empty($value['tags']) && noMarkdownTag($value['tags'])) {
$value['taglist'] = stripNoMarkdownTag($value['taglist']);
continue;
}
$value['description'] = process_markdown($value['description']);
}
return $data;
}
@ -44,6 +43,7 @@ function hook_markdown_render_feed($data)
{
foreach ($data['links'] as &$value) {
if (!empty($value['tags']) && noMarkdownTag($value['tags'])) {
$value['tags'] = stripNoMarkdownTag($value['tags']);
continue;
}
$value['description'] = process_markdown($value['description']);
@ -86,6 +86,19 @@ function noMarkdownTag($tags)
return strpos($tags, NO_MD_TAG) !== false;
}
/**
* Remove the no-markdown meta tag so it won't be displayed.
*
* @param string $tags Tag list.
*
* @return string tag list without no markdown tag.
*/
function stripNoMarkdownTag($tags)
{
unset($tags[array_search(NO_MD_TAG, $tags)]);
return array_values($tags);
}
/**
* When link list is displayed, include markdown CSS.
*

View file

@ -125,7 +125,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
$data = array(
'links' => array(array(
'description' => $str,
'tags' => NO_MD_TAG
'tags' => NO_MD_TAG,
'taglist' => array(NO_MD_TAG),
))
);
@ -140,7 +141,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
// nth link
0 => array(
'formatedDescription' => $str,
'tags' => NO_MD_TAG
'tags' => NO_MD_TAG,
'taglist' => array(),
),
),
),