Skip to content

Commit e2c844d

Browse files
committed
Improved parsing <links> in the markdown parser.
1 parent 880ed9d commit e2c844d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- added support for `HEAD` method
1414
- fixed file routing
1515
- added support for handling specific file extensions in the form `ROUTE('FILE *.php', ...)`
16+
- improved parsing `<links>` in the markdown parser
1617

1718
========================
1819
0.0.13

markdown.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,19 @@ function markdown_keywords(value) {
107107
}
108108

109109
function markdown_links2(value) {
110+
110111
value = value.substring(4, value.length - 4);
111-
return '<a href="' + (value.isEmail() ? 'mailto:' : REG_LINKEXTERNAL.test(value) ? '' : 'http://') + value + '" target="_blank">' + value + '</a>';
112+
113+
let url = value;
114+
115+
if (value.isEmail())
116+
url = 'mailto:' + value;
117+
else if (value.isPhone())
118+
url = 'tel:' + value;
119+
else if (!REG_LINKEXTERNAL.test(value))
120+
url = 'http://' + url;
121+
122+
return '<a href="' + url + '" target="_blank">' + value + '</a>';
112123
}
113124

114125
function markdown_format(value, index, text) {

0 commit comments

Comments
 (0)