summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/mode/markdown/markdown.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/vendor/codemirror/mode/markdown/markdown.js')
-rw-r--r--public/vendor/codemirror/mode/markdown/markdown.js30
1 files changed, 26 insertions, 4 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);