Skip to content
Browse files

Move HTML tags out of xml_util

  • Loading branch information...
1 parent d23ffd8 commit 70cda1375b294151a309c11e0cc44427f715248d @danyaPostfactum danyaPostfactum committed Jul 2, 2012
Showing with 26 additions and 33 deletions.
  1. +22 −3 lib/ace/mode/html_highlight_rules.js
  2. +4 −30 lib/ace/mode/xml_util.js
View
25 lib/ace/mode/html_highlight_rules.js
@@ -44,6 +44,25 @@ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScrip
var xmlUtil = require("./xml_util");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+var tagMap = {
+ a : 'anchor',
+ button : 'form',
+ form : 'form',
+ img : 'image',
+ input : 'form',
+ label : 'form',
+ script : 'script',
+ select : 'form',
+ textarea : 'form',
+ style : 'style',
+ table : 'table',
+ tbody : 'table',
+ td : 'table',
+ tfoot : 'table',
+ th : 'table',
+ tr : 'table'
+};
+
var HtmlHighlightRules = function() {
// regexp must not have capturing parentheses
@@ -113,9 +132,9 @@ var HtmlHighlightRules = function() {
} ]
};
- xmlUtil.tag(this.$rules, "tag", "start");
- xmlUtil.tag(this.$rules, "style", "css-start");
- xmlUtil.tag(this.$rules, "script", "js-start");
+ xmlUtil.tag(this.$rules, "tag", "start", tagMap);
+ xmlUtil.tag(this.$rules, "style", "css-start", tagMap);
+ xmlUtil.tag(this.$rules, "script", "js-start", tagMap);
this.embedRules(JavaScriptHighlightRules, "js-", [{
token: "comment",
View
34 lib/ace/mode/xml_util.js
@@ -38,16 +38,6 @@
define(function(require, exports, module) {
"use strict";
-var lang = require("../lib/lang");
-
-var formTags = lang.arrayToMap(
- ("button|form|input|label|select|textarea").split("|")
-);
-
-var tableTags = lang.arrayToMap(
- ("table|tbody|td|tfoot|th|tr").split("|")
-);
-
function string(state) {
return [{
token : "string",
@@ -81,33 +71,17 @@ function multiLineString(quote, state) {
}];
}
-exports.tag = function(states, name, nextState) {
+exports.tag = function(states, name, nextState, tagMap) {
states[name] = [{
token : "text",
regex : "\\s+"
}, {
//token : "meta.tag",
token : function(value) {
- if ( value==='a' ) {
- return "meta.tag.anchor";
- }
- else if ( value==='img' ) {
- return "meta.tag.image";
- }
- else if ( value==='script' ) {
- return "meta.tag.script";
- }
- else if ( value==='style' ) {
- return "meta.tag.style";
- }
- else if (formTags.hasOwnProperty(value.toLowerCase())) {
- return "meta.tag.form";
- }
- else if (tableTags.hasOwnProperty(value.toLowerCase())) {
- return "meta.tag.table";
- }
- else {
+ if (tagMap && tagMap[value]) {
+ return "meta.tag" + '.' + tagMap[value];
+ } else {
return "meta.tag";
}
},

0 comments on commit 70cda13

Please sign in to comment.
Something went wrong with that request. Please try again.