5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"), require("../markdown/markdown"), require("../../addon/mode/overlay"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror", "../markdown/markdown", "../../addon/mode/overlay"], mod);
11
})(function(CodeMirror) {
14
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
16
CodeMirror.defineMode("gfm", function(config, modeConfig) {
18
function blankLine(state) {
23
startState: function() {
30
copyState: function(s) {
33
codeBlock: s.codeBlock,
37
token: function(stream, state) {
38
state.combineTokens = null;
41
if (state.codeBlock) {
42
if (stream.match(/^```+/)) {
43
state.codeBlock = false;
52
if (stream.sol() && stream.match(/^```+/)) {
54
state.codeBlock = true;
58
if (stream.peek() === '`') {
60
var before = stream.pos;
62
var difference = 1 + stream.pos - before;
64
codeDepth = difference;
67
if (difference === codeDepth) {
72
} else if (state.code) {
77
if (stream.eatSpace()) {
78
state.ateSpace = true;
81
if (stream.sol() || state.ateSpace) {
82
state.ateSpace = false;
83
if (modeConfig.gitHubSpice !== false) {
84
if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/)) {
88
state.combineTokens = true;
90
} else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
94
state.combineTokens = true;
99
if (stream.match(urlRE) &&
100
stream.string.slice(stream.start - 2, stream.start) != "](" &&
101
(stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
106
state.combineTokens = true;
115
var markdownConfig = {
120
for (var attr in modeConfig) {
121
markdownConfig[attr] = modeConfig[attr];
123
markdownConfig.name = "markdown";
124
return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
128
CodeMirror.defineMIME("text/x-gfm", "gfm");