summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/mode/markdown
diff options
context:
space:
mode:
authorWu Cheng-Han2016-07-30 12:25:24 +0800
committerWu Cheng-Han2016-07-30 12:25:24 +0800
commit1490eafdd26a576dcc3832d1811802c0162dfe84 (patch)
treeabf105de4a0ec1659672643b7583330a421e79bb /public/vendor/codemirror/mode/markdown
parentb6ca8649af10d969d86f0e8ff31723321d43087a (diff)
Update CodeMirror to version 5.17.1
Diffstat (limited to 'public/vendor/codemirror/mode/markdown')
-rw-r--r--public/vendor/codemirror/mode/markdown/markdown.js30
-rw-r--r--public/vendor/codemirror/mode/markdown/test.js29
2 files changed, 50 insertions, 9 deletions
diff --git a/public/vendor/codemirror/mode/markdown/markdown.js b/public/vendor/codemirror/mode/markdown/markdown.js
index 37329c23..9dd44574 100644
--- a/public/vendor/codemirror/mode/markdown/markdown.js
+++ b/public/vendor/codemirror/mode/markdown/markdown.js
@@ -63,7 +63,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
list2: "variable-3",
list3: "keyword",
hr: "hr",
- image: "tag",
+ image: "image",
+ imageAltText: "image-alt-text",
+ imageMarker: "image-marker",
formatting: "formatting",
linkInline: "link",
linkEmail: "link",
@@ -313,6 +315,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
if (state.linkText) { styles.push(tokenTypes.linkText); }
if (state.code) { styles.push(tokenTypes.code); }
+ if (state.image) { styles.push(tokenTypes.image); }
+ if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
+ if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
}
if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
@@ -432,12 +437,29 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
- stream.match(/\[[^\]]*\]/);
+ state.imageMarker = true;
+ state.image = true;
+ if (modeCfg.highlightFormatting) state.formatting = "image";
+ return getType(state);
+ }
+
+ if (ch === '[' && state.imageMarker) {
+ state.imageMarker = false;
+ state.imageAltText = true
+ if (modeCfg.highlightFormatting) state.formatting = "image";
+ return getType(state);
+ }
+
+ if (ch === ']' && state.imageAltText) {
+ if (modeCfg.highlightFormatting) state.formatting = "image";
+ var type = getType(state);
+ state.imageAltText = false;
+ state.image = false;
state.inline = state.f = linkHref;
- return tokenTypes.image;
+ return type;
}
- if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false)) {
+ if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && !state.image) {
state.linkText = true;
if (modeCfg.highlightFormatting) state.formatting = "link";
return getType(state);
diff --git a/public/vendor/codemirror/mode/markdown/test.js b/public/vendor/codemirror/mode/markdown/test.js
index e76eae90..2f43a170 100644
--- a/public/vendor/codemirror/mode/markdown/test.js
+++ b/public/vendor/codemirror/mode/markdown/test.js
@@ -22,6 +22,8 @@
"list3" : "override-list3",
"hr" : "override-hr",
"image" : "override-image",
+ "imageAltText": "override-image-alt-text",
+ "imageMarker": "override-image-marker",
"linkInline" : "override-link-inline",
"linkEmail" : "override-link-email",
"linkText" : "override-link-text",
@@ -89,6 +91,9 @@
FT("formatting_escape",
"[formatting-escape \\*]");
+ FT("formatting_image",
+ "[formatting&formatting-image&image&image-marker !][formatting&formatting-image&image&image-alt-text&link [[][image&image-alt-text&link alt text][formatting&formatting-image&image&image-alt-text&link ]]][formatting&formatting-link-string&string&url (][url&string http://link.to/image.jpg][formatting&formatting-link-string&string&url )]");
+
MT("plainText",
"foo");
@@ -589,6 +594,20 @@
MT("hrDashLong",
"[hr ---------------------------------------]");
+ //Images
+ MT("Images",
+ "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)]")
+
+ //Images with highlight alt text
+ MT("imageEm",
+ "[image&image-marker !][image&image-alt-text&link [[][image-alt-text&em&image&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
+
+ MT("imageStrong",
+ "[image&image-marker !][image&image-alt-text&link [[][image-alt-text&strong&image&link **alt text**][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
+
+ MT("imageEmStrong",
+ "[image&image-marker !][image&image-alt-text&link [[][image-alt-text&image&strong&link **][image&image-alt-text&em&strong&link *alt text**][image&image-alt-text&em&link *][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
+
// Inline link with title
MT("linkTitle",
"[link [[foo]]][string&url (http://example.com/ \"bar\")] hello");
@@ -599,7 +618,7 @@
// Inline link with image
MT("linkImage",
- "[link [[][tag ![[foo]]][string&url (http://example.com/)][link ]]][string&url (http://example.com/)] bar");
+ "[link [[][link&image&image-marker !][link&image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)][link ]]][string&url (http://example.com/)] bar");
// Inline link with Em
MT("linkEm",
@@ -615,15 +634,15 @@
// Image with title
MT("imageTitle",
- "[tag ![[foo]]][string&url (http://example.com/ \"bar\")] hello");
+ "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/ \"bar\")] hello");
// Image without title
MT("imageNoTitle",
- "[tag ![[foo]]][string&url (http://example.com/)] bar");
+ "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/)] bar");
// Image with asterisks
MT("imageAsterisks",
- "[tag ![[*foo*]]][string&url (http://example.com/)] bar");
+ "[image&image-marker !][image&image-alt-text&link [[ ][image&image-alt-text&em&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)] 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
@@ -878,7 +897,7 @@
"[override-hr * * *]");
TokenTypeOverrideTest("overrideImage",
- "[override-image ![[foo]]][override-link-href&url (http://example.com/)]")
+ "[override-image&override-image-marker !][override-image&override-image-alt-text&link [[alt text]]][override-link-href&url (http://link.to/image.jpg)]");
TokenTypeOverrideTest("overrideLinkText",
"[override-link-text [[foo]]][override-link-href&url (http://example.com)]");