summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/mode/htmlmixed
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-04-20 18:11:40 +0800
committerCheng-Han, Wu2016-04-20 18:11:40 +0800
commit8bf516263c6582771e7576e8484ca8cfaa8cb9cb (patch)
treeaba81172f554a50466a762db99f25e3650d7ff45 /public/vendor/codemirror/mode/htmlmixed
parentedc3a31dfdb03e910d7355144280e281eeb582d5 (diff)
Update CodeMirror to 5.13.5
Diffstat (limited to 'public/vendor/codemirror/mode/htmlmixed')
-rw-r--r--public/vendor/codemirror/mode/htmlmixed/htmlmixed.js42
1 files changed, 22 insertions, 20 deletions
diff --git a/public/vendor/codemirror/mode/htmlmixed/htmlmixed.js b/public/vendor/codemirror/mode/htmlmixed/htmlmixed.js
index 21e74f16..6574fbd5 100644
--- a/public/vendor/codemirror/mode/htmlmixed/htmlmixed.js
+++ b/public/vendor/codemirror/mode/htmlmixed/htmlmixed.js
@@ -44,13 +44,9 @@
return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*");
}
- function getAttrValue(stream, attr) {
- var pos = stream.pos, match;
- while (pos >= 0 && stream.string.charAt(pos) !== "<") pos--;
- if (pos < 0) return pos;
- if (match = stream.string.slice(pos, stream.pos).match(getAttrRegexp(attr)))
- return match[2];
- return "";
+ function getAttrValue(text, attr) {
+ var match = text.match(getAttrRegexp(attr))
+ return match ? match[2] : ""
}
function getTagRegexp(tagName, anchored) {
@@ -66,10 +62,10 @@
}
}
- function findMatchingMode(tagInfo, stream) {
+ function findMatchingMode(tagInfo, tagText) {
for (var i = 0; i < tagInfo.length; i++) {
var spec = tagInfo[i];
- if (!spec[0] || spec[1].test(getAttrValue(stream, spec[0]))) return spec[2];
+ if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2];
}
}
@@ -89,15 +85,17 @@
tags.script.unshift(["type", configScript[i].matches, configScript[i].mode])
function html(stream, state) {
- var tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase();
- var tagInfo = tagName && tags.hasOwnProperty(tagName) && tags[tagName];
-
- var style = htmlMode.token(stream, state.htmlState), modeSpec;
-
- if (tagInfo && /\btag\b/.test(style) && stream.current() === ">" &&
- (modeSpec = findMatchingMode(tagInfo, stream))) {
- var mode = CodeMirror.getMode(config, modeSpec);
- var endTagA = getTagRegexp(tagName, true), endTag = getTagRegexp(tagName, false);
+ var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName
+ if (tag && !/[<>\s\/]/.test(stream.current()) &&
+ (tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) &&
+ tags.hasOwnProperty(tagName)) {
+ state.inTag = tagName + " "
+ } else if (state.inTag && tag && />$/.test(stream.current())) {
+ var inTag = /^([\S]+) (.*)/.exec(state.inTag)
+ state.inTag = null
+ var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])
+ var mode = CodeMirror.getMode(config, modeSpec)
+ var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false);
state.token = function (stream, state) {
if (stream.match(endTagA, false)) {
state.token = html;
@@ -108,6 +106,9 @@
};
state.localMode = mode;
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, ""));
+ } else if (state.inTag) {
+ state.inTag += stream.current()
+ if (stream.eol()) state.inTag += " "
}
return style;
};
@@ -115,7 +116,7 @@
return {
startState: function () {
var state = htmlMode.startState();
- return {token: html, localMode: null, localState: null, htmlState: state};
+ return {token: html, inTag: null, localMode: null, localState: null, htmlState: state};
},
copyState: function (state) {
@@ -123,7 +124,8 @@
if (state.localState) {
local = CodeMirror.copyState(state.localMode, state.localState);
}
- return {token: state.token, localMode: state.localMode, localState: local,
+ return {token: state.token, inTag: state.inTag,
+ localMode: state.localMode, localState: local,
htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
},