Skip to content

Commit

Permalink
chore: improve ghMentions
Browse files Browse the repository at this point in the history
  • Loading branch information
tivie committed Jan 6, 2017
1 parent f2671c0 commit a58674e
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 7 deletions.
8 changes: 6 additions & 2 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion performance.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"1.5.5":[{"suiteName":"Basic","cycles":100,"tests":[{"name":"Simple \"Hello World\"","time":0.3017154600000001,"maxTime":5.968856000000001,"minTime":0.14796299999999718},{"name":"readme.md","time":8.157263590000007,"maxTime":17.988235999999993,"minTime":7.204394999999977}]},{"suiteName":"subParsers","cycles":1000,"tests":[{"name":"hashHTMLBlocks","time":0.6816068189999991,"maxTime":1.094506000000024,"minTime":0.6253030000000308},{"name":"anchors","time":0.2342927859999952,"maxTime":0.5794980000000578,"minTime":0.1910560000001169},{"name":"autoLinks","time":0.014762871999999106,"maxTime":0.18050900000002912,"minTime":0.01295799999979863},{"name":"blockGamut","time":7.3070927989999825,"maxTime":17.844490999999834,"minTime":6.509178000000247},{"name":"blockQuotes","time":0.06523252800000227,"maxTime":0.25795599999946717,"minTime":0.058762999999089516},{"name":"codeBlocks","time":0.07315170800001215,"maxTime":1.051713999999265,"minTime":0.06237900000087393},{"name":"codeSpans","time":0.18133396599998558,"maxTime":0.8983270000007906,"minTime":0.1651399999991554},{"name":"detab","time":0.023979393999999956,"maxTime":0.2088370000001305,"minTime":0.022299000000202795},{"name":"encodeAmpsAndAngles","time":0.01590047000001141,"maxTime":0.2796539999999368,"minTime":0.013861999999789987},{"name":"encodeBackslashEscapes","time":0.014044158999993669,"maxTime":0.3592109999990498,"minTime":0.012655999998969492},{"name":"encodeCode","time":0.1713209560000123,"maxTime":0.5418289999997796,"minTime":0.15368899999884889},{"name":"encodeEmailAddress","time":2.3023639950000105,"maxTime":4.221322999999757,"minTime":2.079922999999326},{"name":"escapeSpecialCharsWithinTagAttributes","time":0.06365613699999631,"maxTime":0.4035089999997581,"minTime":0.05424300000049698},{"name":"githubCodeBlocks","time":0.11150525500000368,"maxTime":6.431128999998691,"minTime":0.0569550000000163},{"name":"hashBlock","time":0.031511962000016866,"maxTime":6.548655999999028,"minTime":0.011150000000270666},{"name":"hashElement","time":0.0007349880000037956,"maxTime":0.22661599999992177,"minTime":0},{"name":"hashHTMLSpans","time":0.03193505000001096,"maxTime":6.133695999998963,"minTime":0.00994399999945017},{"name":"hashPreCodeTags","time":0.017636856999988595,"maxTime":0.3019540000004781,"minTime":0.015067999998791493},{"name":"headers","time":0.4557796079999789,"maxTime":7.748634999999922,"minTime":0.3962759999994887},{"name":"images","time":0.03852289700000438,"maxTime":1.0164559999993799,"minTime":0.03284699999858276},{"name":"italicsAndBold","time":0.0357555800000082,"maxTime":0.4667920000010781,"minTime":0.031038999999509542},{"name":"lists","time":5.111364808999966,"maxTime":11.046619000000646,"minTime":4.623325000000477},{"name":"outdent","time":0.05124681700002475,"maxTime":0.4122480000005453,"minTime":0.04429799999707029},{"name":"paragraphs","time":1.3728050700000132,"maxTime":3.7286149999999907,"minTime":1.2099230000021635},{"name":"spanGamut","time":0.7691525840000031,"maxTime":1.306657000000996,"minTime":0.6686979999976757},{"name":"strikethrough","time":0.0004860790000202542,"maxTime":0.2513269999981276,"minTime":0},{"name":"stripBlankLines","time":0.03095717400000649,"maxTime":0.2920090000006894,"minTime":0.027421999999205582},{"name":"stripLinkDefinitions","time":0.06971120600001814,"maxTime":0.42219200000181445,"minTime":0.06117399999857298},{"name":"tables","time":0.000774782000004052,"maxTime":0.21154800000294927,"minTime":0},{"name":"unescapeSpecialChars","time":0.0036451429999833636,"maxTime":0.18713900000147987,"minTime":0.0027119999977003317}]}],"1.5.4":[{"suiteName":"Basic","cycles":100,"tests":[{"name":"Simple \"Hello World\"","time":0.30990324000000025,"maxTime":5.549075,"minTime":0.14916800000000308},{"name":"readme.md","time":8.072704459999997,"maxTime":17.975579000000003,"minTime":7.220064999999977}]}]}
{"1.5.6":[{"suiteName":"Basic","cycles":100,"tests":[{"name":"Simple \"Hello World\"","time":0.48365952999999995,"maxTime":5.497247999999999,"minTime":0.15941500000000275},{"name":"readme.md","time":8.624009609999991,"maxTime":20.72512300000001,"minTime":7.638648999999987}]},{"suiteName":"subParsers","cycles":1000,"tests":[{"name":"hashHTMLBlocks","time":0.6974054759999992,"maxTime":1.1927480000001651,"minTime":0.6367549999999937},{"name":"anchors","time":0.19090051499999935,"maxTime":0.6283180000000357,"minTime":0.1591129999999339},{"name":"autoLinks","time":0.01718004600000063,"maxTime":0.31822600000009515,"minTime":0.01386200000001736},{"name":"blockGamut","time":7.7196042380000085,"maxTime":14.916580000000977,"minTime":6.94945800000005},{"name":"blockQuotes","time":0.06506110199997783,"maxTime":0.23625900000115507,"minTime":0.05966699999953562},{"name":"codeBlocks","time":0.08153567099998872,"maxTime":1.0782339999987016,"minTime":0.06298199999946519},{"name":"codeSpans","time":0.18521222000000126,"maxTime":0.9152030000004743,"minTime":0.1675520000007964},{"name":"detab","time":0.024611045000006927,"maxTime":0.19467299999996612,"minTime":0.022600999998758198},{"name":"encodeAmpsAndAngles","time":0.016200345999990533,"maxTime":0.31943199999841454,"minTime":0.01356099999975413},{"name":"encodeBackslashEscapes","time":0.01431991399999606,"maxTime":0.2639839999992546,"minTime":0.012655999998969492},{"name":"encodeCode","time":0.1769781109999949,"maxTime":0.48939399999835587,"minTime":0.1554969999997411},{"name":"encodeEmailAddress","time":2.848971260999982,"maxTime":482.6867740000016,"minTime":2.1034310000013647},{"name":"escapeSpecialCharsWithinTagAttributes","time":0.06140210999999181,"maxTime":0.4282199999997829,"minTime":0.054543999998713844},{"name":"githubCodeBlocks","time":0.08352940699999999,"maxTime":5.148885999999038,"minTime":0.05574999999953434},{"name":"hashBlock","time":0.035242384999986824,"maxTime":6.322346999999354,"minTime":0.011450999998487532},{"name":"hashElement","time":0.0007398209999955725,"maxTime":0.228423999998995,"minTime":0},{"name":"hashHTMLSpans","time":0.023965240999994423,"maxTime":4.870135000001028,"minTime":0.010548000000198954},{"name":"hashPreCodeTags","time":0.0177119209999928,"maxTime":0.29502299999876413,"minTime":0.015066999998452957},{"name":"headers","time":0.47185469899999044,"maxTime":4.046241999998529,"minTime":0.40471400000024005},{"name":"images","time":0.04015382200000204,"maxTime":0.8353449999995064,"minTime":0.03314899999895715},{"name":"italicsAndBold","time":0.040937056000007944,"maxTime":0.4218909999999596,"minTime":0.03555899999992107},{"name":"lists","time":5.605958104999981,"maxTime":8.2754040000018,"minTime":5.111517999999705},{"name":"outdent","time":0.05058991999998762,"maxTime":0.8519200000009732,"minTime":0.04490099999748054},{"name":"paragraphs","time":1.3683752520000052,"maxTime":2.683230000002368,"minTime":1.221376000001328},{"name":"spanGamut","time":0.6380164189999886,"maxTime":1.4329240000006394,"minTime":0.5689510000011069},{"name":"strikethrough","time":0.00041044099999635366,"maxTime":0.2287259999975504,"minTime":0},{"name":"stripBlankLines","time":0.031698214999982155,"maxTime":0.29773500000010245,"minTime":0.027422999999544118},{"name":"stripLinkDefinitions","time":0.07171796800000084,"maxTime":0.35408800000004703,"minTime":0.06177699999898323},{"name":"tables","time":0.0005409359999939625,"maxTime":0.19889199999670382,"minTime":0},{"name":"unescapeSpecialChars","time":0.0034100999999900523,"maxTime":0.15188100000159466,"minTime":0.0030129999977361877}]}],"1.5.5":[{"suiteName":"Basic","cycles":100,"tests":[{"name":"Simple \"Hello World\"","time":0.3017154600000001,"maxTime":5.968856000000001,"minTime":0.14796299999999718},{"name":"readme.md","time":8.157263590000007,"maxTime":17.988235999999993,"minTime":7.204394999999977}]},{"suiteName":"subParsers","cycles":1000,"tests":[{"name":"hashHTMLBlocks","time":0.6816068189999991,"maxTime":1.094506000000024,"minTime":0.6253030000000308},{"name":"anchors","time":0.2342927859999952,"maxTime":0.5794980000000578,"minTime":0.1910560000001169},{"name":"autoLinks","time":0.014762871999999106,"maxTime":0.18050900000002912,"minTime":0.01295799999979863},{"name":"blockGamut","time":7.3070927989999825,"maxTime":17.844490999999834,"minTime":6.509178000000247},{"name":"blockQuotes","time":0.06523252800000227,"maxTime":0.25795599999946717,"minTime":0.058762999999089516},{"name":"codeBlocks","time":0.07315170800001215,"maxTime":1.051713999999265,"minTime":0.06237900000087393},{"name":"codeSpans","time":0.18133396599998558,"maxTime":0.8983270000007906,"minTime":0.1651399999991554},{"name":"detab","time":0.023979393999999956,"maxTime":0.2088370000001305,"minTime":0.022299000000202795},{"name":"encodeAmpsAndAngles","time":0.01590047000001141,"maxTime":0.2796539999999368,"minTime":0.013861999999789987},{"name":"encodeBackslashEscapes","time":0.014044158999993669,"maxTime":0.3592109999990498,"minTime":0.012655999998969492},{"name":"encodeCode","time":0.1713209560000123,"maxTime":0.5418289999997796,"minTime":0.15368899999884889},{"name":"encodeEmailAddress","time":2.3023639950000105,"maxTime":4.221322999999757,"minTime":2.079922999999326},{"name":"escapeSpecialCharsWithinTagAttributes","time":0.06365613699999631,"maxTime":0.4035089999997581,"minTime":0.05424300000049698},{"name":"githubCodeBlocks","time":0.11150525500000368,"maxTime":6.431128999998691,"minTime":0.0569550000000163},{"name":"hashBlock","time":0.031511962000016866,"maxTime":6.548655999999028,"minTime":0.011150000000270666},{"name":"hashElement","time":0.0007349880000037956,"maxTime":0.22661599999992177,"minTime":0},{"name":"hashHTMLSpans","time":0.03193505000001096,"maxTime":6.133695999998963,"minTime":0.00994399999945017},{"name":"hashPreCodeTags","time":0.017636856999988595,"maxTime":0.3019540000004781,"minTime":0.015067999998791493},{"name":"headers","time":0.4557796079999789,"maxTime":7.748634999999922,"minTime":0.3962759999994887},{"name":"images","time":0.03852289700000438,"maxTime":1.0164559999993799,"minTime":0.03284699999858276},{"name":"italicsAndBold","time":0.0357555800000082,"maxTime":0.4667920000010781,"minTime":0.031038999999509542},{"name":"lists","time":5.111364808999966,"maxTime":11.046619000000646,"minTime":4.623325000000477},{"name":"outdent","time":0.05124681700002475,"maxTime":0.4122480000005453,"minTime":0.04429799999707029},{"name":"paragraphs","time":1.3728050700000132,"maxTime":3.7286149999999907,"minTime":1.2099230000021635},{"name":"spanGamut","time":0.7691525840000031,"maxTime":1.306657000000996,"minTime":0.6686979999976757},{"name":"strikethrough","time":0.0004860790000202542,"maxTime":0.2513269999981276,"minTime":0},{"name":"stripBlankLines","time":0.03095717400000649,"maxTime":0.2920090000006894,"minTime":0.027421999999205582},{"name":"stripLinkDefinitions","time":0.06971120600001814,"maxTime":0.42219200000181445,"minTime":0.06117399999857298},{"name":"tables","time":0.000774782000004052,"maxTime":0.21154800000294927,"minTime":0},{"name":"unescapeSpecialChars","time":0.0036451429999833636,"maxTime":0.18713900000147987,"minTime":0.0027119999977003317}]}],"1.5.4":[{"suiteName":"Basic","cycles":100,"tests":[{"name":"Simple \"Hello World\"","time":0.30990324000000025,"maxTime":5.549075,"minTime":0.14916800000000308},{"name":"readme.md","time":8.072704459999997,"maxTime":17.975579000000003,"minTime":7.220064999999977}]}]}
43 changes: 43 additions & 0 deletions performance.log.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
# Performance Tests for showdown


## [version 1.5.6](https://github.com/showdownjs/showdown/tree/)

### Test Suite: Basic (100 cycles)
| test | avgTime | max | min |
|:-----|--------:|----:|----:|
|Simple "Hello World"|0.484|5.497|0.159|
|readme.md|8.624|20.725|7.639|

### Test Suite: subParsers (1000 cycles)
| test | avgTime | max | min |
|:-----|--------:|----:|----:|
|hashHTMLBlocks|0.697|1.193|0.637|
|anchors|0.191|0.628|0.159|
|autoLinks|0.017|0.318|0.014|
|blockGamut|7.720|14.917|6.949|
|blockQuotes|0.065|0.236|0.060|
|codeBlocks|0.082|1.078|0.063|
|codeSpans|0.185|0.915|0.168|
|detab|0.025|0.195|0.023|
|encodeAmpsAndAngles|0.016|0.319|0.014|
|encodeBackslashEscapes|0.014|0.264|0.013|
|encodeCode|0.177|0.489|0.155|
|encodeEmailAddress|2.849|482.687|2.103|
|escapeSpecialCharsWithinTagAttributes|0.061|0.428|0.055|
|githubCodeBlocks|0.084|5.149|0.056|
|hashBlock|0.035|6.322|0.011|
|hashElement|0.001|0.228|0.000|
|hashHTMLSpans|0.024|4.870|0.011|
|hashPreCodeTags|0.018|0.295|0.015|
|headers|0.472|4.046|0.405|
|images|0.040|0.835|0.033|
|italicsAndBold|0.041|0.422|0.036|
|lists|5.606|8.275|5.112|
|outdent|0.051|0.852|0.045|
|paragraphs|1.368|2.683|1.221|
|spanGamut|0.638|1.433|0.569|
|strikethrough|0.000|0.229|0.000|
|stripBlankLines|0.032|0.298|0.027|
|stripLinkDefinitions|0.072|0.354|0.062|
|tables|0.001|0.199|0.000|
|unescapeSpecialChars|0.003|0.152|0.003|


## [version 1.5.5](https://github.com/showdownjs/showdown/tree/)

### Test Suite: Basic (100 cycles)
Expand Down
7 changes: 6 additions & 1 deletion src/subParsers/anchors.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ showdown.subParser('anchors', function (text, options, globals) {

// Lastly handle GithubMentions if option is enabled
if (options.ghMentions) {
text = text.replace(/(^|\s)(@([a-z\d\-]+))(?=[.!?;,[\]()]|\s|$)/gmi, '$1<a href="https://www.github.com/$3">$2</a>');
text = text.replace(/(^|\s)(\\)?(@([a-z\d\-]+))(?=[.!?;,[\]()]|\s|$)/gmi, function (wm, st, escape, mentions, username) {
if (escape === '\\') {
return st + mentions;
}
return st + '<a href="https://www.github.com/' + username + '">' + mentions + '</a>';
});
}

text = globals.converter._dispatch('anchors.after', text, options, globals);
Expand Down
Empty file removed src/subParsers/ghMentions.js
Empty file.
1 change: 1 addition & 0 deletions test/features/ghMentions.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<p>hello <a href="https://www.github.com/tivie">@tivie</a> how are you?</p>
<p>this email foo@gmail.com is not parsed</p>
<p>this @mentions is not parsed also</p>
2 changes: 2 additions & 0 deletions test/features/ghMentions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
hello @tivie how are you?

this email foo@gmail.com is not parsed

this \@mentions is not parsed also

0 comments on commit a58674e

Please sign in to comment.