-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(makeMarkdown.ghMentions): add support for ghMentions in makeMark…
…down Related to #910
- Loading branch information
Showing
21 changed files
with
93 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
showdown.subParser('makeMarkdown.links', function (node, globals) { | ||
showdown.subParser('makeMarkdown.links', function (node, options, globals) { | ||
'use strict'; | ||
|
||
var txt = ''; | ||
if (node.hasChildNodes() && node.hasAttribute('href')) { | ||
var children = node.childNodes, | ||
childrenLength = children.length; | ||
txt = '['; | ||
for (var i = 0; i < childrenLength; ++i) { | ||
txt += showdown.subParser('makeMarkdown.node')(children[i], globals); | ||
} | ||
txt += ']('; | ||
txt += '<' + node.getAttribute('href') + '>'; | ||
if (node.hasAttribute('title')) { | ||
txt += ' "' + node.getAttribute('title') + '"'; | ||
|
||
// special case for mentions | ||
// to simplify (and not make stuff really complicated) mentions will only work in this circumstance: | ||
// <a class="user-mention" href="https://github.com/user">@user</a> | ||
// that is, if there's a "user-mention" class and option ghMentions is true | ||
// otherwise is ignored | ||
var classes = node.getAttribute('class'); | ||
if (options.ghMentions && /(?:^| )user-mention\b/.test(classes)) { | ||
for (var ii = 0; ii < childrenLength; ++ii) { | ||
txt += showdown.subParser('makeMarkdown.node')(children[ii], options, globals); | ||
} | ||
|
||
} else { | ||
txt = '['; | ||
for (var i = 0; i < childrenLength; ++i) { | ||
txt += showdown.subParser('makeMarkdown.node')(children[i], options, globals); | ||
} | ||
txt += ']('; | ||
txt += '<' + node.getAttribute('href') + '>'; | ||
if (node.hasAttribute('title')) { | ||
txt += ' "' + node.getAttribute('title') + '"'; | ||
} | ||
txt += ')'; | ||
} | ||
txt += ')'; | ||
|
||
|
||
} | ||
return txt; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/functional/makemarkdown/cases/features/ghMentions/github.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<p><a class="bazinga user-mention foo bar baz" href="https://github.com/tivie">@tivie</a></p> | ||
<p><a class="not-user-mention" href="https://www.google.com">@something</a></p> |
3 changes: 3 additions & 0 deletions
3
test/functional/makemarkdown/cases/features/ghMentions/github.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@tivie | ||
|
||
[@something](<https://www.google.com>) |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.