aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-05-30 18:51:00 +0200
committerArthurHoaro <arthur@hoa.ro>2016-05-30 18:51:00 +0200
commit8c4e60186d393a7c42b6bc09e81ba3051092076e (patch)
tree6e2b7d6f40fd0e417f70a9845e00898fbfc5d4a3
parent6d03a9b2b38dd27c6df3127fcd2e24c686cab9df (diff)
downloadShaarli-8c4e60186d393a7c42b6bc09e81ba3051092076e.tar.gz
Shaarli-8c4e60186d393a7c42b6bc09e81ba3051092076e.tar.zst
Shaarli-8c4e60186d393a7c42b6bc09e81ba3051092076e.zip
The tag is no longer private
A private tag is never loaded for visitor, making this feature useless.
-rw-r--r--plugins/markdown/markdown.php19
-rw-r--r--tests/plugins/PluginMarkdownTest.php6
2 files changed, 20 insertions, 5 deletions
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php
index 57fcce32..5f56ecc2 100644
--- a/plugins/markdown/markdown.php
+++ b/plugins/markdown/markdown.php
@@ -10,9 +10,8 @@ require_once 'Parsedown.php';
10 10
11/* 11/*
12 * If this tag is used on a shaare, the description won't be processed by Parsedown. 12 * If this tag is used on a shaare, the description won't be processed by Parsedown.
13 * Using a private tag so it won't appear for visitors.
14 */ 13 */
15define('NO_MD_TAG', '.nomarkdown'); 14define('NO_MD_TAG', 'nomarkdown');
16 15
17/** 16/**
18 * Parse linklist descriptions. 17 * Parse linklist descriptions.
@@ -25,11 +24,11 @@ function hook_markdown_render_linklist($data)
25{ 24{
26 foreach ($data['links'] as &$value) { 25 foreach ($data['links'] as &$value) {
27 if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { 26 if (!empty($value['tags']) && noMarkdownTag($value['tags'])) {
27 $value['taglist'] = stripNoMarkdownTag($value['taglist']);
28 continue; 28 continue;
29 } 29 }
30 $value['description'] = process_markdown($value['description']); 30 $value['description'] = process_markdown($value['description']);
31 } 31 }
32
33 return $data; 32 return $data;
34} 33}
35 34
@@ -44,6 +43,7 @@ function hook_markdown_render_feed($data)
44{ 43{
45 foreach ($data['links'] as &$value) { 44 foreach ($data['links'] as &$value) {
46 if (!empty($value['tags']) && noMarkdownTag($value['tags'])) { 45 if (!empty($value['tags']) && noMarkdownTag($value['tags'])) {
46 $value['tags'] = stripNoMarkdownTag($value['tags']);
47 continue; 47 continue;
48 } 48 }
49 $value['description'] = process_markdown($value['description']); 49 $value['description'] = process_markdown($value['description']);
@@ -87,6 +87,19 @@ function noMarkdownTag($tags)
87} 87}
88 88
89/** 89/**
90 * Remove the no-markdown meta tag so it won't be displayed.
91 *
92 * @param string $tags Tag list.
93 *
94 * @return string tag list without no markdown tag.
95 */
96function stripNoMarkdownTag($tags)
97{
98 unset($tags[array_search(NO_MD_TAG, $tags)]);
99 return array_values($tags);
100}
101
102/**
90 * When link list is displayed, include markdown CSS. 103 * When link list is displayed, include markdown CSS.
91 * 104 *
92 * @param array $data includes data. 105 * @param array $data includes data.
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
index fa7e1d52..3593a556 100644
--- a/tests/plugins/PluginMarkdownTest.php
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -125,7 +125,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
125 $data = array( 125 $data = array(
126 'links' => array(array( 126 'links' => array(array(
127 'description' => $str, 127 'description' => $str,
128 'tags' => NO_MD_TAG 128 'tags' => NO_MD_TAG,
129 'taglist' => array(NO_MD_TAG),
129 )) 130 ))
130 ); 131 );
131 132
@@ -140,7 +141,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
140 // nth link 141 // nth link
141 0 => array( 142 0 => array(
142 'formatedDescription' => $str, 143 'formatedDescription' => $str,
143 'tags' => NO_MD_TAG 144 'tags' => NO_MD_TAG,
145 'taglist' => array(),
144 ), 146 ),
145 ), 147 ),
146 ), 148 ),