Fixed URL and emails in editor

This commit is contained in:
benweet 2014-06-09 12:59:19 +01:00
parent 4d97ba5f84
commit 2305bb6207
2 changed files with 15 additions and 12 deletions

View File

@ -1,8 +1,10 @@
// Credit to https://editorially.com/ // Credit to https://editorially.com/
Prism.languages.md = (function () { Prism.languages.md = (function () {
var urlPattern = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>\[\]'"]+|\([^\s()<>\[\]'"]*\))+(?:\([^\s()<>\[\]'"]*\)|[^\s`!()\[\]{}:'".,<>?«»“”‘’]))/gi; var charInsideUrl = "[-A-Z0-9+&@#/%?=~_|[\\]()!:,.;]",
var emailPattern = /[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b/gi; charEndingUrl = "[-A-Z0-9+&@#/%=~_|[\\])]";
var urlPattern = new RegExp("(=\"|<)?\\b(https?|ftp)(://" + charInsideUrl + "*" + charEndingUrl + ")(?=$|\\W)", "gi");
var emailPattern = /(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)/gi;
var latex = Prism.languages.latex; var latex = Prism.languages.latex;
@ -241,9 +243,6 @@ Prism.languages.md = (function () {
} }
} }
}; };
md.email = {
pattern: emailPattern
};
md.code = { md.code = {
pattern: /(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/g, pattern: /(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/g,
lookbehind: true, lookbehind: true,
@ -297,8 +296,11 @@ Prism.languages.md = (function () {
conflict: //g, conflict: //g,
comment: Prism.languages.markup.comment, comment: Prism.languages.markup.comment,
tag: Prism.languages.markup.tag, tag: Prism.languages.markup.tag,
entity: Prism.languages.markup.entity entity: Prism.languages.markup.entity,
url: urlPattern,
email: emailPattern
}; };
for (var c = 6; c >= 1; c--) { for (var c = 6; c >= 1; c--) {
md["h" + c].inside.rest = rest; md["h" + c].inside.rest = rest;
} }

View File

@ -1223,11 +1223,6 @@ a {
.h6 { font-size: 0.9em; } .h6 { font-size: 0.9em; }
.url,
.email {
color: @tertiary-color-light;
}
.md, .hr { .md, .hr {
color: @tertiary-color-light; color: @tertiary-color-light;
font-style: normal; font-style: normal;
@ -1248,10 +1243,16 @@ a {
text-decoration: line-through text-decoration: line-through
} }
.url,
.email,
.md-underlined-text { .md-underlined-text {
text-decoration: underline; text-decoration: underline;
} }
.linkdef .url {
color: @tertiary-color-light;
}
.img, .img,
.imgref { .imgref {
padding: 0.2em 0.4em; padding: 0.2em 0.4em;