mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-31 15:18:38 -04:00
Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor
This commit is contained in:
parent
ce65e58096
commit
eaa8ccaccb
381 changed files with 6726 additions and 2636 deletions
4
public/vendor/codemirror/mode/markdown/index.html
vendored
Executable file → Normal file
4
public/vendor/codemirror/mode/markdown/index.html
vendored
Executable file → Normal file
|
@ -350,8 +350,10 @@ Output:
|
|||
});
|
||||
</script>
|
||||
|
||||
<p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
|
||||
<p>You might want to use the <a href="../gfm/index.html">Github-Flavored Markdown mode</a> instead, which adds support for fenced code blocks and a few other things.</p>
|
||||
|
||||
<p>Optionally depends on the XML mode for properly highlighted inline XML blocks.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#markdown_*">normal</a>, <a href="../../test/index.html#verbose,markdown_*">verbose</a>.</p>
|
||||
|
|
192
public/vendor/codemirror/mode/markdown/markdown.js
vendored
Executable file → Normal file
192
public/vendor/codemirror/mode/markdown/markdown.js
vendored
Executable file → Normal file
|
@ -39,8 +39,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
if (modeCfg.underscoresBreakWords === undefined)
|
||||
modeCfg.underscoresBreakWords = true;
|
||||
|
||||
// Turn on fenced code blocks? ("```" to start/end)
|
||||
if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
|
||||
// Use `fencedCodeBlocks` to configure fenced code blocks. false to
|
||||
// disable, string to specify a precise regexp that the fence should
|
||||
// match, and true to allow three or more backticks or tildes (as
|
||||
// per CommonMark).
|
||||
|
||||
// Turn on task lists? ("- [ ] " and "- [x] ")
|
||||
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
|
||||
|
@ -49,32 +51,46 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
if (modeCfg.strikethrough === undefined)
|
||||
modeCfg.strikethrough = false;
|
||||
|
||||
// Allow token types to be overridden by user-provided token types.
|
||||
if (modeCfg.tokenTypeOverrides === undefined)
|
||||
modeCfg.tokenTypeOverrides = {};
|
||||
|
||||
var codeDepth = 0;
|
||||
|
||||
var header = 'header'
|
||||
, code = 'comment'
|
||||
, quote = 'quote'
|
||||
, list1 = 'variable-2'
|
||||
, list2 = 'variable-3'
|
||||
, list3 = 'keyword'
|
||||
, hr = 'hr'
|
||||
, image = 'tag'
|
||||
, formatting = 'formatting'
|
||||
, linkinline = 'link'
|
||||
, linkemail = 'link'
|
||||
, linktext = 'link'
|
||||
, linkhref = 'string'
|
||||
, em = 'em'
|
||||
, strong = 'strong'
|
||||
, strikethrough = 'strikethrough';
|
||||
var tokenTypes = {
|
||||
header: "header",
|
||||
code: "comment",
|
||||
quote: "quote",
|
||||
list1: "variable-2",
|
||||
list2: "variable-3",
|
||||
list3: "keyword",
|
||||
hr: "hr",
|
||||
image: "tag",
|
||||
formatting: "formatting",
|
||||
linkInline: "link",
|
||||
linkEmail: "link",
|
||||
linkText: "link",
|
||||
linkHref: "string",
|
||||
em: "em",
|
||||
strong: "strong",
|
||||
strikethrough: "strikethrough"
|
||||
};
|
||||
|
||||
for (var tokenType in tokenTypes) {
|
||||
if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) {
|
||||
tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
|
||||
}
|
||||
}
|
||||
|
||||
var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
|
||||
, ulRE = /^[*\-+]\s+/
|
||||
, olRE = /^[0-9]+([.)])\s+/
|
||||
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
||||
, atxHeaderRE = /^(#+)(?: |$)/
|
||||
, atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
|
||||
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
|
||||
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
|
||||
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/
|
||||
, fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) +
|
||||
")[ \\t]*([\\w+#]*)");
|
||||
|
||||
function switchInline(stream, state, f) {
|
||||
state.f = state.inline = f;
|
||||
|
@ -86,6 +102,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return f(stream, state);
|
||||
}
|
||||
|
||||
function lineIsEmpty(line) {
|
||||
return !line || !/\S/.test(line.string)
|
||||
}
|
||||
|
||||
// Blocks
|
||||
|
||||
|
@ -110,7 +129,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
// Mark this line as blank
|
||||
state.thisLineHasContent = false;
|
||||
state.prevLine = state.thisLine
|
||||
state.thisLine = null
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -141,10 +161,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
var match = null;
|
||||
if (state.indentationDiff >= 4) {
|
||||
stream.skipToEnd();
|
||||
if (prevLineIsIndentedCode || !state.prevLineHasContent) {
|
||||
if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) {
|
||||
state.indentation -= 4;
|
||||
state.indentedCode = true;
|
||||
return code;
|
||||
return tokenTypes.code;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -155,7 +175,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
return getType(state);
|
||||
} else if (state.prevLineHasContent && !state.quote && !prevLineIsList && !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
|
||||
} else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList &&
|
||||
!prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
|
||||
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
|
@ -169,8 +190,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return switchInline(stream, state, footnoteLink);
|
||||
} else if (stream.match(hrRE, true)) {
|
||||
state.hr = true;
|
||||
return hr;
|
||||
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
||||
return tokenTypes.hr;
|
||||
} else if ((lineIsEmpty(state.prevLine) || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
||||
var listType = null;
|
||||
if (stream.match(ulRE, true)) {
|
||||
listType = 'ul';
|
||||
|
@ -178,7 +199,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
stream.match(olRE, true);
|
||||
listType = 'ol';
|
||||
}
|
||||
state.indentation += 4;
|
||||
state.indentation = stream.column() + stream.current().length;
|
||||
state.list = true;
|
||||
state.listDepth++;
|
||||
if (modeCfg.taskLists && stream.match(taskListRE, false)) {
|
||||
|
@ -187,9 +208,10 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
state.f = state.inline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
|
||||
return getType(state);
|
||||
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) {
|
||||
} else if (modeCfg.fencedCodeBlocks && (match = stream.match(fencedCodeRE, true))) {
|
||||
state.fencedChars = match[1]
|
||||
// try switching mode
|
||||
state.localMode = getMode(RegExp.$1);
|
||||
state.localMode = getMode(match[2]);
|
||||
if (state.localMode) state.localState = state.localMode.startState();
|
||||
state.f = state.block = local;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
|
@ -202,7 +224,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
|
||||
function htmlBlock(stream, state) {
|
||||
var style = htmlMode.token(stream, state.htmlState);
|
||||
if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) ||
|
||||
if ((htmlFound && state.htmlState.tagStart === null &&
|
||||
(!state.htmlState.context && state.htmlState.tokenize.isInText)) ||
|
||||
(state.md_inside && stream.current().indexOf(">") > -1)) {
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
|
@ -212,7 +235,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
|
||||
function local(stream, state) {
|
||||
if (stream.sol() && stream.match("```", false)) {
|
||||
if (stream.sol() && state.fencedChars && stream.match(state.fencedChars, false)) {
|
||||
state.localMode = state.localState = null;
|
||||
state.f = state.block = leavingLocal;
|
||||
return null;
|
||||
|
@ -220,14 +243,15 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return state.localMode.token(stream, state.localState);
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
return code;
|
||||
return tokenTypes.code;
|
||||
}
|
||||
}
|
||||
|
||||
function leavingLocal(stream, state) {
|
||||
stream.match("```");
|
||||
stream.match(state.fencedChars);
|
||||
state.block = blockNormal;
|
||||
state.f = inlineNormal;
|
||||
state.fencedChars = null;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
state.code = true;
|
||||
var returnType = getType(state);
|
||||
|
@ -240,22 +264,22 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
var styles = [];
|
||||
|
||||
if (state.formatting) {
|
||||
styles.push(formatting);
|
||||
styles.push(tokenTypes.formatting);
|
||||
|
||||
if (typeof state.formatting === "string") state.formatting = [state.formatting];
|
||||
|
||||
for (var i = 0; i < state.formatting.length; i++) {
|
||||
styles.push(formatting + "-" + state.formatting[i]);
|
||||
styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
|
||||
|
||||
if (state.formatting[i] === "header") {
|
||||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
|
||||
styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
|
||||
}
|
||||
|
||||
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
|
||||
// Add `error` instead if the maximum blockquote nesting depth is passed
|
||||
if (state.formatting[i] === "quote") {
|
||||
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote);
|
||||
styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
|
||||
} else {
|
||||
styles.push("error");
|
||||
}
|
||||
|
@ -273,38 +297,36 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
|
||||
if (state.linkHref) {
|
||||
styles.push(linkhref, "url");
|
||||
styles.push(tokenTypes.linkHref, "url");
|
||||
} else { // Only apply inline styles to non-url text
|
||||
if (state.strong) { styles.push(strong); }
|
||||
if (state.em) { styles.push(em); }
|
||||
if (state.strikethrough) { styles.push(strikethrough); }
|
||||
|
||||
if (state.linkText) { styles.push(linktext); }
|
||||
|
||||
if (state.code) { styles.push(code); }
|
||||
if (state.strong) { styles.push(tokenTypes.strong); }
|
||||
if (state.em) { styles.push(tokenTypes.em); }
|
||||
if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
|
||||
if (state.linkText) { styles.push(tokenTypes.linkText); }
|
||||
if (state.code) { styles.push(tokenTypes.code); }
|
||||
}
|
||||
|
||||
if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
|
||||
if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
|
||||
|
||||
if (state.quote) {
|
||||
styles.push(quote);
|
||||
styles.push(tokenTypes.quote);
|
||||
|
||||
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
|
||||
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||
styles.push(quote + "-" + state.quote);
|
||||
styles.push(tokenTypes.quote + "-" + state.quote);
|
||||
} else {
|
||||
styles.push(quote + "-" + modeCfg.maxBlockquoteDepth);
|
||||
styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.list !== false) {
|
||||
var listMod = (state.listDepth - 1) % 3;
|
||||
if (!listMod) {
|
||||
styles.push(list1);
|
||||
styles.push(tokenTypes.list1);
|
||||
} else if (listMod === 1) {
|
||||
styles.push(list2);
|
||||
styles.push(tokenTypes.list2);
|
||||
} else {
|
||||
styles.push(list3);
|
||||
styles.push(tokenTypes.list3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,7 +382,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
stream.next();
|
||||
if (modeCfg.highlightFormatting) {
|
||||
var type = getType(state);
|
||||
return type ? type + " formatting-escape" : "formatting-escape";
|
||||
var formattingEscape = tokenTypes.formatting + "-escape";
|
||||
return type ? type + " " + formattingEscape : formattingEscape;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,7 +397,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||
var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
|
||||
if (stream.match(new RegExp(regex), true)) {
|
||||
return linkhref;
|
||||
return tokenTypes.linkHref;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,7 +428,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
|
||||
stream.match(/\[[^\]]*\]/);
|
||||
state.inline = state.f = linkHref;
|
||||
return image;
|
||||
return tokenTypes.image;
|
||||
}
|
||||
|
||||
if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) {
|
||||
|
@ -431,7 +454,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkinline;
|
||||
return type + tokenTypes.linkInline;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
|
||||
|
@ -443,15 +466,14 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkemail;
|
||||
return type + tokenTypes.linkEmail;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^\w/, false)) {
|
||||
if (stream.string.indexOf(">") != -1) {
|
||||
var atts = stream.string.substring(1,stream.string.indexOf(">"));
|
||||
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
|
||||
state.md_inside = true;
|
||||
}
|
||||
if (ch === '<' && stream.match(/^(!--|\w)/, false)) {
|
||||
var end = stream.string.indexOf(">", stream.pos);
|
||||
if (end != -1) {
|
||||
var atts = stream.string.substring(stream.start, end);
|
||||
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true;
|
||||
}
|
||||
stream.backUp(1);
|
||||
state.htmlState = CodeMirror.startState(htmlMode);
|
||||
|
@ -553,12 +575,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkinline;
|
||||
return type + tokenTypes.linkInline;
|
||||
}
|
||||
|
||||
stream.match(/^[^>]+/, true);
|
||||
|
||||
return linkinline;
|
||||
return tokenTypes.linkInline;
|
||||
}
|
||||
|
||||
function linkHref(stream, state) {
|
||||
|
@ -598,7 +620,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
|
||||
function footnoteLink(stream, state) {
|
||||
if (stream.match(/^[^\]]*\]:/, false)) {
|
||||
if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
|
||||
state.f = footnoteLinkInside;
|
||||
stream.next(); // Consume [
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
|
@ -617,9 +639,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return returnType;
|
||||
}
|
||||
|
||||
stream.match(/^[^\]]+/, true);
|
||||
stream.match(/^([^\]\\]|\\.)+/, true);
|
||||
|
||||
return linktext;
|
||||
return tokenTypes.linkText;
|
||||
}
|
||||
|
||||
function footnoteUrl(stream, state) {
|
||||
|
@ -636,7 +658,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
|
||||
}
|
||||
state.f = state.inline = inlineNormal;
|
||||
return linkhref + " url";
|
||||
return tokenTypes.linkHref + " url";
|
||||
}
|
||||
|
||||
var savedInlineRE = [];
|
||||
|
@ -656,8 +678,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return {
|
||||
f: blockNormal,
|
||||
|
||||
prevLineHasContent: false,
|
||||
thisLineHasContent: false,
|
||||
prevLine: null,
|
||||
thisLine: null,
|
||||
|
||||
block: blockNormal,
|
||||
htmlState: null,
|
||||
|
@ -680,7 +702,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
quote: 0,
|
||||
trailingSpace: 0,
|
||||
trailingSpaceNewLine: false,
|
||||
strikethrough: false
|
||||
strikethrough: false,
|
||||
fencedChars: null
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -688,8 +711,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
return {
|
||||
f: s.f,
|
||||
|
||||
prevLineHasContent: s.prevLineHasContent,
|
||||
thisLineHasContent: s.thisLineHasContent,
|
||||
prevLine: s.prevLine,
|
||||
thisLine: s.thisLine,
|
||||
|
||||
block: s.block,
|
||||
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
|
||||
|
@ -702,6 +725,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
text: s.text,
|
||||
formatting: false,
|
||||
linkTitle: s.linkTitle,
|
||||
code: s.code,
|
||||
em: s.em,
|
||||
strong: s.strong,
|
||||
strikethrough: s.strikethrough,
|
||||
|
@ -714,7 +738,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
indentedCode: s.indentedCode,
|
||||
trailingSpace: s.trailingSpace,
|
||||
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
||||
md_inside: s.md_inside
|
||||
md_inside: s.md_inside,
|
||||
fencedChars: s.fencedChars
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -723,28 +748,25 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
// Reset state.formatting
|
||||
state.formatting = false;
|
||||
|
||||
if (stream.sol()) {
|
||||
var forceBlankLine = !!state.header || state.hr;
|
||||
if (stream != state.thisLine) {
|
||||
var forceBlankLine = state.header || state.hr;
|
||||
|
||||
// Reset state.header and state.hr
|
||||
state.header = 0;
|
||||
state.hr = false;
|
||||
|
||||
if (stream.match(/^\s*$/, true) || forceBlankLine) {
|
||||
state.prevLineHasContent = false;
|
||||
blankLine(state);
|
||||
return forceBlankLine ? this.token(stream, state) : null;
|
||||
} else {
|
||||
state.prevLineHasContent = state.thisLineHasContent;
|
||||
state.thisLineHasContent = true;
|
||||
if (!forceBlankLine) return null
|
||||
state.prevLine = null
|
||||
}
|
||||
|
||||
state.prevLine = state.thisLine
|
||||
state.thisLine = stream
|
||||
|
||||
// Reset state.taskList
|
||||
state.taskList = false;
|
||||
|
||||
// Reset state.code
|
||||
state.code = false;
|
||||
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
|
|
176
public/vendor/codemirror/mode/markdown/test.js
vendored
Executable file → Normal file
176
public/vendor/codemirror/mode/markdown/test.js
vendored
Executable file → Normal file
|
@ -6,6 +6,39 @@
|
|||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
var modeHighlightFormatting = CodeMirror.getMode({tabSize: 4}, {name: "markdown", highlightFormatting: true});
|
||||
function FT(name) { test.mode(name, modeHighlightFormatting, Array.prototype.slice.call(arguments, 1)); }
|
||||
var modeAtxNoSpace = CodeMirror.getMode({tabSize: 4}, {name: "markdown", allowAtxHeaderWithoutSpace: true});
|
||||
function AtxNoSpaceTest(name) { test.mode(name, modeAtxNoSpace, Array.prototype.slice.call(arguments, 1)); }
|
||||
var modeFenced = CodeMirror.getMode({tabSize: 4}, {name: "markdown", fencedCodeBlocks: true});
|
||||
function FencedTest(name) { test.mode(name, modeFenced, Array.prototype.slice.call(arguments, 1)); }
|
||||
var modeOverrideClasses = CodeMirror.getMode({tabsize: 4}, {
|
||||
name: "markdown",
|
||||
strikethrough: true,
|
||||
tokenTypeOverrides: {
|
||||
"header" : "override-header",
|
||||
"code" : "override-code",
|
||||
"quote" : "override-quote",
|
||||
"list1" : "override-list1",
|
||||
"list2" : "override-list2",
|
||||
"list3" : "override-list3",
|
||||
"hr" : "override-hr",
|
||||
"image" : "override-image",
|
||||
"linkInline" : "override-link-inline",
|
||||
"linkEmail" : "override-link-email",
|
||||
"linkText" : "override-link-text",
|
||||
"linkHref" : "override-link-href",
|
||||
"em" : "override-em",
|
||||
"strong" : "override-strong",
|
||||
"strikethrough" : "override-strikethrough"
|
||||
}});
|
||||
function TokenTypeOverrideTest(name) { test.mode(name, modeOverrideClasses, Array.prototype.slice.call(arguments, 1)); }
|
||||
var modeFormattingOverride = CodeMirror.getMode({tabsize: 4}, {
|
||||
name: "markdown",
|
||||
highlightFormatting: true,
|
||||
tokenTypeOverrides: {
|
||||
"formatting" : "override-formatting"
|
||||
}});
|
||||
function FormatTokenTypeOverrideTest(name) { test.mode(name, modeFormattingOverride, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
|
||||
FT("formatting_emAsterisk",
|
||||
"[em&formatting&formatting-em *][em foo][em&formatting&formatting-em *]");
|
||||
|
@ -110,7 +143,7 @@
|
|||
// Block code using single backtick (shouldn't work)
|
||||
MT("blockCodeSingleBacktick",
|
||||
"[comment `]",
|
||||
"foo",
|
||||
"[comment foo]",
|
||||
"[comment `]");
|
||||
|
||||
// Unclosed backticks
|
||||
|
@ -173,6 +206,16 @@
|
|||
MT("noAtxH1WithoutSpace",
|
||||
"#5 bolt");
|
||||
|
||||
// CommonMark requires a space after # but most parsers don't
|
||||
AtxNoSpaceTest("atxNoSpaceAllowed_H1NoSpace",
|
||||
"[header&header-1 #foo]");
|
||||
|
||||
AtxNoSpaceTest("atxNoSpaceAllowed_H4NoSpace",
|
||||
"[header&header-4 ####foo]");
|
||||
|
||||
AtxNoSpaceTest("atxNoSpaceAllowed_H1Space",
|
||||
"[header&header-1 # foo]");
|
||||
|
||||
// Inline styles should be parsed inside headers
|
||||
MT("atxH1inline",
|
||||
"[header&header-1 # foo ][header&header-1&em *bar*]");
|
||||
|
@ -498,14 +541,14 @@
|
|||
"",
|
||||
" [variable-3 * bar]",
|
||||
"",
|
||||
" [variable-2 hello]"
|
||||
" [variable-3 hello]"
|
||||
);
|
||||
MT("listNested",
|
||||
"[variable-2 * foo]",
|
||||
"",
|
||||
" [variable-3 * bar]",
|
||||
"",
|
||||
" [variable-3 * foo]"
|
||||
" [keyword * foo]"
|
||||
);
|
||||
|
||||
// Code followed by text
|
||||
|
@ -653,6 +696,15 @@
|
|||
"[link [[foo]]:] [string&url http://example.com/]",
|
||||
"(bar\" hello");
|
||||
|
||||
MT("labelEscape",
|
||||
"[link [[foo \\]] ]]:] [string&url http://example.com/]");
|
||||
|
||||
MT("labelEscapeColon",
|
||||
"[link [[foo \\]]: bar]]:] [string&url http://example.com/]");
|
||||
|
||||
MT("labelEscapeEnd",
|
||||
"[[foo\\]]: http://example.com/");
|
||||
|
||||
MT("linkWeb",
|
||||
"[link <http://example.com/>] foo");
|
||||
|
||||
|
@ -760,16 +812,128 @@
|
|||
"\\",
|
||||
"[em *foo*]");
|
||||
|
||||
// Class override tests
|
||||
TokenTypeOverrideTest("overrideHeader1",
|
||||
"[override-header&override-header-1 # Foo]");
|
||||
|
||||
TokenTypeOverrideTest("overrideHeader2",
|
||||
"[override-header&override-header-2 ## Foo]");
|
||||
|
||||
TokenTypeOverrideTest("overrideHeader3",
|
||||
"[override-header&override-header-3 ### Foo]");
|
||||
|
||||
TokenTypeOverrideTest("overrideHeader4",
|
||||
"[override-header&override-header-4 #### Foo]");
|
||||
|
||||
TokenTypeOverrideTest("overrideHeader5",
|
||||
"[override-header&override-header-5 ##### Foo]");
|
||||
|
||||
TokenTypeOverrideTest("overrideHeader6",
|
||||
"[override-header&override-header-6 ###### Foo]");
|
||||
|
||||
TokenTypeOverrideTest("overrideCode",
|
||||
"[override-code `foo`]");
|
||||
|
||||
TokenTypeOverrideTest("overrideCodeBlock",
|
||||
"[override-code ```]",
|
||||
"[override-code foo]",
|
||||
"[override-code ```]");
|
||||
|
||||
TokenTypeOverrideTest("overrideQuote",
|
||||
"[override-quote&override-quote-1 > foo]",
|
||||
"[override-quote&override-quote-1 > bar]");
|
||||
|
||||
TokenTypeOverrideTest("overrideQuoteNested",
|
||||
"[override-quote&override-quote-1 > foo]",
|
||||
"[override-quote&override-quote-1 >][override-quote&override-quote-2 > bar]",
|
||||
"[override-quote&override-quote-1 >][override-quote&override-quote-2 >][override-quote&override-quote-3 > baz]");
|
||||
|
||||
TokenTypeOverrideTest("overrideLists",
|
||||
"[override-list1 - foo]",
|
||||
"",
|
||||
" [override-list2 + bar]",
|
||||
"",
|
||||
" [override-list3 * baz]",
|
||||
"",
|
||||
" [override-list1 1. qux]",
|
||||
"",
|
||||
" [override-list2 - quux]");
|
||||
|
||||
TokenTypeOverrideTest("overrideHr",
|
||||
"[override-hr * * *]");
|
||||
|
||||
TokenTypeOverrideTest("overrideImage",
|
||||
"[override-image ![[foo]]][override-link-href&url (http://example.com/)]")
|
||||
|
||||
TokenTypeOverrideTest("overrideLinkText",
|
||||
"[override-link-text [[foo]]][override-link-href&url (http://example.com)]");
|
||||
|
||||
TokenTypeOverrideTest("overrideLinkEmailAndInline",
|
||||
"[override-link-email <][override-link-inline foo@example.com>]");
|
||||
|
||||
TokenTypeOverrideTest("overrideEm",
|
||||
"[override-em *foo*]");
|
||||
|
||||
TokenTypeOverrideTest("overrideStrong",
|
||||
"[override-strong **foo**]");
|
||||
|
||||
TokenTypeOverrideTest("overrideStrikethrough",
|
||||
"[override-strikethrough ~~foo~~]");
|
||||
|
||||
FormatTokenTypeOverrideTest("overrideFormatting",
|
||||
"[override-formatting-escape \\*]");
|
||||
|
||||
// Tests to make sure GFM-specific things aren't getting through
|
||||
|
||||
MT("taskList",
|
||||
"[variable-2 * [ ]] bar]");
|
||||
|
||||
MT("fencedCodeBlocks",
|
||||
"[comment ```]",
|
||||
MT("noFencedCodeBlocks",
|
||||
"~~~",
|
||||
"foo",
|
||||
"[comment ```]");
|
||||
"~~~");
|
||||
|
||||
FencedTest("fencedCodeBlocks",
|
||||
"[comment ```]",
|
||||
"[comment foo]",
|
||||
"[comment ```]",
|
||||
"bar");
|
||||
|
||||
FencedTest("fencedCodeBlocksMultipleChars",
|
||||
"[comment `````]",
|
||||
"[comment foo]",
|
||||
"[comment ```]",
|
||||
"[comment foo]",
|
||||
"[comment `````]",
|
||||
"bar");
|
||||
|
||||
FencedTest("fencedCodeBlocksTildes",
|
||||
"[comment ~~~]",
|
||||
"[comment foo]",
|
||||
"[comment ~~~]",
|
||||
"bar");
|
||||
|
||||
FencedTest("fencedCodeBlocksTildesMultipleChars",
|
||||
"[comment ~~~~~]",
|
||||
"[comment ~~~]",
|
||||
"[comment foo]",
|
||||
"[comment ~~~~~]",
|
||||
"bar");
|
||||
|
||||
FencedTest("fencedCodeBlocksMultipleChars",
|
||||
"[comment `````]",
|
||||
"[comment foo]",
|
||||
"[comment ```]",
|
||||
"[comment foo]",
|
||||
"[comment `````]",
|
||||
"bar");
|
||||
|
||||
FencedTest("fencedCodeBlocksMixed",
|
||||
"[comment ~~~]",
|
||||
"[comment ```]",
|
||||
"[comment foo]",
|
||||
"[comment ~~~]",
|
||||
"bar");
|
||||
|
||||
// Tests that require XML mode
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue