From eaa8ccaccb1091820d0a8d1223996a6dd057347d Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 17 Jan 2016 14:28:04 -0600 Subject: Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor --- public/vendor/codemirror/mode/gfm/gfm.js | 45 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) mode change 100755 => 100644 public/vendor/codemirror/mode/gfm/gfm.js (limited to 'public/vendor/codemirror/mode/gfm/gfm.js') diff --git a/public/vendor/codemirror/mode/gfm/gfm.js b/public/vendor/codemirror/mode/gfm/gfm.js old mode 100755 new mode 100644 index 80a8e2c8..6e74ad4f --- a/public/vendor/codemirror/mode/gfm/gfm.js +++ b/public/vendor/codemirror/mode/gfm/gfm.js @@ -11,6 +11,8 @@ })(function(CodeMirror) { "use strict"; +var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i + CodeMirror.defineMode("gfm", function(config, modeConfig) { var codeDepth = 0; function blankLine(state) { @@ -37,7 +39,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) { // Hack to prevent formatting override inside code blocks (block and inline) if (state.codeBlock) { - if (stream.match(/^```/)) { + if (stream.match(/^```+/)) { state.codeBlock = false; return null; } @@ -47,7 +49,7 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) { if (stream.sol()) { state.code = false; } - if (stream.sol() && stream.match(/^```/)) { + if (stream.sol() && stream.match(/^```+/)) { stream.skipToEnd(); state.codeBlock = true; return null; @@ -78,25 +80,29 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) { } if (stream.sol() || state.ateSpace) { state.ateSpace = false; - if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) { - // User/Project@SHA - // User@SHA - // SHA - state.combineTokens = true; - return "link"; - } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) { - // User/Project#Num - // User#Num - // #Num - state.combineTokens = true; - return "link"; + if (modeConfig.gitHubSpice !== false) { + if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) { + // User/Project@SHA + // User@SHA + // SHA + state.combineTokens = true; + return "link"; + } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) { + // User/Project#Num + // User#Num + // #Num + state.combineTokens = true; + return "link"; + } } } - if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i) && - stream.string.slice(stream.start - 2, stream.start) != "](") { + if (stream.match(urlRE) && + stream.string.slice(stream.start - 2, stream.start) != "](" && + (stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) { // URLs // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls // And then (issue #1160) simplified to make it not crash the Chrome Regexp engine + // And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL state.combineTokens = true; return "link"; } @@ -109,15 +115,16 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) { var markdownConfig = { underscoresBreakWords: false, taskLists: true, - fencedCodeBlocks: true, + fencedCodeBlocks: '```', strikethrough: true }; for (var attr in modeConfig) { markdownConfig[attr] = modeConfig[attr]; } markdownConfig.name = "markdown"; - CodeMirror.defineMIME("gfmBase", markdownConfig); - return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay); + return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay); + }, "markdown"); + CodeMirror.defineMIME("text/x-gfm", "gfm"); }); -- cgit v1.2.3