mirror of
https://github.com/discourse/discourse.git
synced 2025-09-11 21:04:42 +08:00
FEATURE: Autolinking to category using hashtags.
This commit is contained in:
parent
b8471177dc
commit
c1dbf5c1c4
20 changed files with 365 additions and 14 deletions
|
@ -289,6 +289,46 @@ test("Mentions", function() {
|
|||
"it allows mentions within HTML tags");
|
||||
});
|
||||
|
||||
test("Category hashtags", () => {
|
||||
var alwaysTrue = { categoryHashtagLookup: (function() { return ["category", "http://test.discourse.org/category-hashtag"]; }) };
|
||||
|
||||
cookedOptions("Check out #category-hashtag", alwaysTrue,
|
||||
"<p>Check out <a class=\"hashtag\" href=\"http://test.discourse.org/category-hashtag\">#category-hashtag</a></p>",
|
||||
"it translates category hashtag into links");
|
||||
|
||||
cooked("Check out #category-hashtag",
|
||||
"<p>Check out <span class=\"hashtag\">#category-hashtag</span></p>",
|
||||
"it does not translate category hashtag into links if it is not a valid category hashtag");
|
||||
|
||||
cookedOptions("[#category-hashtag](http://www.test.com)", alwaysTrue,
|
||||
"<p><a href=\"http://www.test.com\">#category-hashtag</a></p>",
|
||||
"it does not translate category hashtag within links");
|
||||
|
||||
cooked("```\n# #category-hashtag\n```",
|
||||
"<p><pre><code class=\"lang-auto\"># #category-hashtag</code></pre></p>",
|
||||
"it does not translate category hashtags to links in code blocks");
|
||||
|
||||
cooked("># #category-hashtag\n",
|
||||
"<blockquote><h1><span class=\"hashtag\">#category-hashtag</span></h1></blockquote>",
|
||||
"it handles category hashtags in simple quotes");
|
||||
|
||||
cooked("# #category-hashtag",
|
||||
"<h1><span class=\"hashtag\">#category-hashtag</span></h1>",
|
||||
"it works within ATX-style headers");
|
||||
|
||||
cooked("don't `#category-hashtag`",
|
||||
"<p>don't <code>#category-hashtag</code></p>",
|
||||
"it does not mention in an inline code block");
|
||||
|
||||
cooked("test #hashtag1/#hashtag2",
|
||||
"<p>test <span class=\"hashtag\">#hashtag1</span>/#hashtag2</p>",
|
||||
"it does not convert category hashtag not bounded by spaces");
|
||||
|
||||
cooked("<small>#category-hashtag</small>",
|
||||
"<p><small><span class=\"hashtag\">#category-hashtag</span></small></p>",
|
||||
"it works between HTML tags");
|
||||
});
|
||||
|
||||
|
||||
test("Heading", function() {
|
||||
cooked("**Bold**\n----------", "<h2><strong>Bold</strong></h2>", "It will bold the heading");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue