mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-25 04:24:43 -04:00
Updated codemirror to 5.4.0
This commit is contained in:
parent
1d843c8ac2
commit
01685c255f
69 changed files with 2988 additions and 558 deletions
|
@ -68,12 +68,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
, strong = 'strong'
|
||||
, strikethrough = 'strikethrough';
|
||||
|
||||
var hrRE = /^([*\-=_])(?:\s*\1){2,}\s*$/
|
||||
var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
|
||||
, ulRE = /^[*\-+]\s+/
|
||||
, olRE = /^[0-9]+\.\s+/
|
||||
, olRE = /^[0-9]+([.)])\s+/
|
||||
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
||||
, atxHeaderRE = /^#+ ?/
|
||||
, setextHeaderRE = /^(?:\={1,}|-{1,})$/
|
||||
, atxHeaderRE = /^(#+)(?: |$)/
|
||||
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
|
||||
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
|
||||
|
||||
function switchInline(stream, state, f) {
|
||||
|
@ -100,6 +100,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
state.strikethrough = false;
|
||||
// Reset state.quote
|
||||
state.quote = 0;
|
||||
// Reset state.indentedCode
|
||||
state.indentedCode = false;
|
||||
if (!htmlFound && state.f == htmlBlock) {
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
|
@ -116,7 +118,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
|
||||
var sol = stream.sol();
|
||||
|
||||
var prevLineIsList = state.list !== false;
|
||||
var prevLineIsList = state.list !== false,
|
||||
prevLineIsIndentedCode = state.indentedCode;
|
||||
|
||||
state.indentedCode = false;
|
||||
|
||||
if (prevLineIsList) {
|
||||
if (state.indentationDiff >= 0) { // Continued list
|
||||
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
|
||||
|
@ -134,23 +140,27 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
|
||||
var match = null;
|
||||
if (state.indentationDiff >= 4) {
|
||||
state.indentation -= 4;
|
||||
stream.skipToEnd();
|
||||
return code;
|
||||
if (prevLineIsIndentedCode || !state.prevLineHasContent) {
|
||||
state.indentation -= 4;
|
||||
state.indentedCode = true;
|
||||
return code;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eatSpace()) {
|
||||
return null;
|
||||
} else if (match = stream.match(atxHeaderRE)) {
|
||||
state.header = Math.min(6, match[0].indexOf(" ") !== -1 ? match[0].length - 1 : match[0].length);
|
||||
} else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
|
||||
state.header = match[1].length;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
return getType(state);
|
||||
} else if (state.prevLineHasContent && (match = stream.match(setextHeaderRE))) {
|
||||
} else if (state.prevLineHasContent && !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;
|
||||
return getType(state);
|
||||
} else if (stream.eat('>')) {
|
||||
state.indentation++;
|
||||
state.quote = sol ? 1 : state.quote + 1;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "quote";
|
||||
stream.eatSpace();
|
||||
|
@ -158,6 +168,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
} else if (stream.peek() === '[') {
|
||||
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))) {
|
||||
var listType = null;
|
||||
|
@ -262,18 +273,17 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
}
|
||||
|
||||
if (state.linkHref) {
|
||||
styles.push(linkhref);
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
styles.push(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(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.header) { styles.push(header); styles.push(header + "-" + state.header); }
|
||||
|
||||
if (state.quote) {
|
||||
|
@ -626,7 +636,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
|
||||
}
|
||||
state.f = state.inline = inlineNormal;
|
||||
return linkhref;
|
||||
return linkhref + " url";
|
||||
}
|
||||
|
||||
var savedInlineRE = [];
|
||||
|
@ -663,6 +673,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
em: false,
|
||||
strong: false,
|
||||
header: 0,
|
||||
hr: false,
|
||||
taskList: false,
|
||||
list: false,
|
||||
listDepth: 0,
|
||||
|
@ -695,10 +706,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
strong: s.strong,
|
||||
strikethrough: s.strikethrough,
|
||||
header: s.header,
|
||||
hr: s.hr,
|
||||
taskList: s.taskList,
|
||||
list: s.list,
|
||||
listDepth: s.listDepth,
|
||||
quote: s.quote,
|
||||
indentedCode: s.indentedCode,
|
||||
trailingSpace: s.trailingSpace,
|
||||
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
||||
md_inside: s.md_inside
|
||||
|
@ -711,10 +724,11 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|||
state.formatting = false;
|
||||
|
||||
if (stream.sol()) {
|
||||
var forceBlankLine = !!state.header;
|
||||
var forceBlankLine = !!state.header || state.hr;
|
||||
|
||||
// Reset state.header
|
||||
// Reset state.header and state.hr
|
||||
state.header = 0;
|
||||
state.hr = false;
|
||||
|
||||
if (stream.match(/^\s*$/, true) || forceBlankLine) {
|
||||
state.prevLineHasContent = false;
|
||||
|
|
122
public/vendor/codemirror/mode/markdown/test.js
vendored
122
public/vendor/codemirror/mode/markdown/test.js
vendored
|
@ -41,11 +41,11 @@
|
|||
"[variable-2&formatting&formatting-list&formatting-list-ol 1. ][variable-2 foo]");
|
||||
|
||||
FT("formatting_link",
|
||||
"[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string (][string http://example.com/][string&formatting&formatting-link-string )]");
|
||||
"[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string&url (][string&url http://example.com/][string&formatting&formatting-link-string&url )]");
|
||||
|
||||
FT("formatting_linkReference",
|
||||
"[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string [][string bar][string&formatting&formatting-link-string ]]]",
|
||||
"[link&formatting&formatting-link [][link bar][link&formatting&formatting-link ]]:] [string http://example.com/]");
|
||||
"[link&formatting&formatting-link [][link foo][link&formatting&formatting-link ]]][string&formatting&formatting-link-string&url [][string&url bar][string&formatting&formatting-link-string&url ]]]",
|
||||
"[link&formatting&formatting-link [][link bar][link&formatting&formatting-link ]]:] [string&url http://example.com/]");
|
||||
|
||||
FT("formatting_linkWeb",
|
||||
"[link&formatting&formatting-link <][link http://example.com/][link&formatting&formatting-link >]");
|
||||
|
@ -85,13 +85,6 @@
|
|||
" [comment foo]",
|
||||
"bar");
|
||||
|
||||
// Code blocks using 4 spaces with internal indentation
|
||||
MT("codeBlocksUsing4SpacesIndentation",
|
||||
" foo",
|
||||
" [comment bar]",
|
||||
" [comment hello]",
|
||||
" [comment world]");
|
||||
|
||||
// Code blocks should end even after extra indented lines
|
||||
MT("codeBlocksWithTrailingIndentedLine",
|
||||
" [comment foo]",
|
||||
|
@ -104,6 +97,12 @@
|
|||
MT("codeBlocksUsing1Tab",
|
||||
"\t[comment foo]");
|
||||
|
||||
// No code blocks directly after paragraph
|
||||
// http://spec.commonmark.org/0.19/#example-65
|
||||
MT("noCodeBlocksAfterParagraph",
|
||||
"Foo",
|
||||
" Bar");
|
||||
|
||||
// Inline code using backticks
|
||||
MT("inlineCodeUsingBackticks",
|
||||
"foo [comment `bar`]");
|
||||
|
@ -166,10 +165,13 @@
|
|||
MT("atxH6",
|
||||
"[header&header-6 ###### foo]");
|
||||
|
||||
// H6 - 7x '#' should still be H6, per Dingus
|
||||
// http://daringfireball.net/projects/markdown/dingus
|
||||
MT("atxH6NotH7",
|
||||
"[header&header-6 ####### foo]");
|
||||
// http://spec.commonmark.org/0.19/#example-24
|
||||
MT("noAtxH7",
|
||||
"####### foo");
|
||||
|
||||
// http://spec.commonmark.org/0.19/#example-25
|
||||
MT("noAtxH1WithoutSpace",
|
||||
"#5 bolt");
|
||||
|
||||
// Inline styles should be parsed inside headers
|
||||
MT("atxH1inline",
|
||||
|
@ -202,6 +204,25 @@
|
|||
"foo",
|
||||
"[header&header-2 ---]");
|
||||
|
||||
// http://spec.commonmark.org/0.19/#example-45
|
||||
MT("setextH2AllowSpaces",
|
||||
"foo",
|
||||
" [header&header-2 ---- ]");
|
||||
|
||||
// http://spec.commonmark.org/0.19/#example-44
|
||||
MT("noSetextAfterIndentedCodeBlock",
|
||||
" [comment foo]",
|
||||
"[hr ---]");
|
||||
|
||||
// http://spec.commonmark.org/0.19/#example-51
|
||||
MT("noSetextAfterQuote",
|
||||
"[quote"e-1 > foo]",
|
||||
"[hr ---]");
|
||||
|
||||
MT("noSetextAfterList",
|
||||
"[variable-2 - foo]",
|
||||
"[hr ---]");
|
||||
|
||||
// Single-line blockquote with trailing space
|
||||
MT("blockquoteSpace",
|
||||
"[quote"e-1 > foo]");
|
||||
|
@ -251,6 +272,13 @@
|
|||
"",
|
||||
"hello");
|
||||
|
||||
// Header with leading space after continued blockquote (#3287, negative indentation)
|
||||
MT("headerAfterContinuedBlockquote",
|
||||
"[quote"e-1 > foo]",
|
||||
"[quote"e-1 bar]",
|
||||
"",
|
||||
" [header&header-1 # hello]");
|
||||
|
||||
// Check list types
|
||||
|
||||
MT("listAsterisk",
|
||||
|
@ -287,11 +315,21 @@
|
|||
"1. bar",
|
||||
"2. hello");
|
||||
|
||||
// List after hr
|
||||
MT("listAfterHr",
|
||||
"[hr ---]",
|
||||
"[variable-2 - bar]");
|
||||
|
||||
// List after header
|
||||
MT("listAfterHeader",
|
||||
"[header&header-1 # foo]",
|
||||
"[variable-2 - bar]");
|
||||
|
||||
// hr after list
|
||||
MT("hrAfterList",
|
||||
"[variable-2 - foo]",
|
||||
"[hr -----]");
|
||||
|
||||
// Formatting in lists (*)
|
||||
MT("listAsteriskFormatting",
|
||||
"[variable-2 * ][variable-2&em *foo*][variable-2 bar]",
|
||||
|
@ -498,39 +536,39 @@
|
|||
|
||||
// Inline link with title
|
||||
MT("linkTitle",
|
||||
"[link [[foo]]][string (http://example.com/ \"bar\")] hello");
|
||||
"[link [[foo]]][string&url (http://example.com/ \"bar\")] hello");
|
||||
|
||||
// Inline link without title
|
||||
MT("linkNoTitle",
|
||||
"[link [[foo]]][string (http://example.com/)] bar");
|
||||
"[link [[foo]]][string&url (http://example.com/)] bar");
|
||||
|
||||
// Inline link with image
|
||||
MT("linkImage",
|
||||
"[link [[][tag ![[foo]]][string (http://example.com/)][link ]]][string (http://example.com/)] bar");
|
||||
"[link [[][tag ![[foo]]][string&url (http://example.com/)][link ]]][string&url (http://example.com/)] bar");
|
||||
|
||||
// Inline link with Em
|
||||
MT("linkEm",
|
||||
"[link [[][link&em *foo*][link ]]][string (http://example.com/)] bar");
|
||||
"[link [[][link&em *foo*][link ]]][string&url (http://example.com/)] bar");
|
||||
|
||||
// Inline link with Strong
|
||||
MT("linkStrong",
|
||||
"[link [[][link&strong **foo**][link ]]][string (http://example.com/)] bar");
|
||||
"[link [[][link&strong **foo**][link ]]][string&url (http://example.com/)] bar");
|
||||
|
||||
// Inline link with EmStrong
|
||||
MT("linkEmStrong",
|
||||
"[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string (http://example.com/)] bar");
|
||||
"[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string&url (http://example.com/)] bar");
|
||||
|
||||
// Image with title
|
||||
MT("imageTitle",
|
||||
"[tag ![[foo]]][string (http://example.com/ \"bar\")] hello");
|
||||
"[tag ![[foo]]][string&url (http://example.com/ \"bar\")] hello");
|
||||
|
||||
// Image without title
|
||||
MT("imageNoTitle",
|
||||
"[tag ![[foo]]][string (http://example.com/)] bar");
|
||||
"[tag ![[foo]]][string&url (http://example.com/)] bar");
|
||||
|
||||
// Image with asterisks
|
||||
MT("imageAsterisks",
|
||||
"[tag ![[*foo*]]][string (http://example.com/)] bar");
|
||||
"[tag ![[*foo*]]][string&url (http://example.com/)] bar");
|
||||
|
||||
// Not a link. Should be normal text due to square brackets being used
|
||||
// regularly in text, especially in quoted material, and no space is allowed
|
||||
|
@ -540,24 +578,24 @@
|
|||
|
||||
// Reference-style links
|
||||
MT("linkReference",
|
||||
"[link [[foo]]][string [[bar]]] hello");
|
||||
"[link [[foo]]][string&url [[bar]]] hello");
|
||||
|
||||
// Reference-style links with Em
|
||||
MT("linkReferenceEm",
|
||||
"[link [[][link&em *foo*][link ]]][string [[bar]]] hello");
|
||||
"[link [[][link&em *foo*][link ]]][string&url [[bar]]] hello");
|
||||
|
||||
// Reference-style links with Strong
|
||||
MT("linkReferenceStrong",
|
||||
"[link [[][link&strong **foo**][link ]]][string [[bar]]] hello");
|
||||
"[link [[][link&strong **foo**][link ]]][string&url [[bar]]] hello");
|
||||
|
||||
// Reference-style links with EmStrong
|
||||
MT("linkReferenceEmStrong",
|
||||
"[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string [[bar]]] hello");
|
||||
"[link [[][link&strong **][link&em&strong *foo**][link&em *][link ]]][string&url [[bar]]] hello");
|
||||
|
||||
// Reference-style links with optional space separator (per docuentation)
|
||||
// "You can optionally use a space to separate the sets of brackets"
|
||||
MT("linkReferenceSpace",
|
||||
"[link [[foo]]] [string [[bar]]] hello");
|
||||
"[link [[foo]]] [string&url [[bar]]] hello");
|
||||
|
||||
// Should only allow a single space ("...use *a* space...")
|
||||
MT("linkReferenceDoubleSpace",
|
||||
|
@ -565,7 +603,7 @@
|
|||
|
||||
// Reference-style links with implicit link name
|
||||
MT("linkImplicit",
|
||||
"[link [[foo]]][string [[]]] hello");
|
||||
"[link [[foo]]][string&url [[]]] hello");
|
||||
|
||||
// @todo It would be nice if, at some point, the document was actually
|
||||
// checked to see if the referenced link exists
|
||||
|
@ -573,46 +611,46 @@
|
|||
// Link label, for reference-style links (taken from documentation)
|
||||
|
||||
MT("labelNoTitle",
|
||||
"[link [[foo]]:] [string http://example.com/]");
|
||||
"[link [[foo]]:] [string&url http://example.com/]");
|
||||
|
||||
MT("labelIndented",
|
||||
" [link [[foo]]:] [string http://example.com/]");
|
||||
" [link [[foo]]:] [string&url http://example.com/]");
|
||||
|
||||
MT("labelSpaceTitle",
|
||||
"[link [[foo bar]]:] [string http://example.com/ \"hello\"]");
|
||||
"[link [[foo bar]]:] [string&url http://example.com/ \"hello\"]");
|
||||
|
||||
MT("labelDoubleTitle",
|
||||
"[link [[foo bar]]:] [string http://example.com/ \"hello\"] \"world\"");
|
||||
"[link [[foo bar]]:] [string&url http://example.com/ \"hello\"] \"world\"");
|
||||
|
||||
MT("labelTitleDoubleQuotes",
|
||||
"[link [[foo]]:] [string http://example.com/ \"bar\"]");
|
||||
"[link [[foo]]:] [string&url http://example.com/ \"bar\"]");
|
||||
|
||||
MT("labelTitleSingleQuotes",
|
||||
"[link [[foo]]:] [string http://example.com/ 'bar']");
|
||||
"[link [[foo]]:] [string&url http://example.com/ 'bar']");
|
||||
|
||||
MT("labelTitleParenthese",
|
||||
"[link [[foo]]:] [string http://example.com/ (bar)]");
|
||||
"[link [[foo]]:] [string&url http://example.com/ (bar)]");
|
||||
|
||||
MT("labelTitleInvalid",
|
||||
"[link [[foo]]:] [string http://example.com/] bar");
|
||||
"[link [[foo]]:] [string&url http://example.com/] bar");
|
||||
|
||||
MT("labelLinkAngleBrackets",
|
||||
"[link [[foo]]:] [string <http://example.com/> \"bar\"]");
|
||||
"[link [[foo]]:] [string&url <http://example.com/> \"bar\"]");
|
||||
|
||||
MT("labelTitleNextDoubleQuotes",
|
||||
"[link [[foo]]:] [string http://example.com/]",
|
||||
"[link [[foo]]:] [string&url http://example.com/]",
|
||||
"[string \"bar\"] hello");
|
||||
|
||||
MT("labelTitleNextSingleQuotes",
|
||||
"[link [[foo]]:] [string http://example.com/]",
|
||||
"[link [[foo]]:] [string&url http://example.com/]",
|
||||
"[string 'bar'] hello");
|
||||
|
||||
MT("labelTitleNextParenthese",
|
||||
"[link [[foo]]:] [string http://example.com/]",
|
||||
"[link [[foo]]:] [string&url http://example.com/]",
|
||||
"[string (bar)] hello");
|
||||
|
||||
MT("labelTitleNextMixed",
|
||||
"[link [[foo]]:] [string http://example.com/]",
|
||||
"[link [[foo]]:] [string&url http://example.com/]",
|
||||
"(bar\" hello");
|
||||
|
||||
MT("linkWeb",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue