use plist instead of libxml
This commit is contained in:
parent
3ce8d4a8a9
commit
83ff661f4d
3 changed files with 17 additions and 56 deletions
|
|
@ -37,7 +37,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var buildAce = require("Makefile.dryice.js").buildAce;
|
||||
var buildAce = require("./Makefile.dryice").buildAce;
|
||||
|
||||
|
||||
var ACE_HOME = __dirname;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"asyncjs": "0.0.x",
|
||||
"jsdom": "0.2.x",
|
||||
"amd-loader": "~0.0.4",
|
||||
"libxml": "0.0.x",
|
||||
"plist": "",
|
||||
"dryice": "0.4.2",
|
||||
"panino" : "~1.0.15"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,58 +1,14 @@
|
|||
var xml = require("libxml");
|
||||
var fs = require("fs");
|
||||
|
||||
function plistToJson(el) {
|
||||
if (el.tagName != "plist")
|
||||
throw new Error("not a plist!");
|
||||
|
||||
return $plistParse(el.selectSingleNode("dict"));
|
||||
var parseString = require("plist").parseString;
|
||||
function parseTheme(themeXml, callback) {
|
||||
parseString(themeXml, function(_, theme) {
|
||||
console.log(theme)
|
||||
callback(theme[0])
|
||||
});
|
||||
}
|
||||
|
||||
function $plistParse(el) {
|
||||
if (el.tagName == "dict") {
|
||||
var dict = {};
|
||||
var key;
|
||||
var childNodes = el.childNodes;
|
||||
for (var i=0, l=childNodes.length; i<l; i++) {
|
||||
var child = childNodes[i];
|
||||
if (child.nodeType !== 1)
|
||||
continue;
|
||||
|
||||
if (child.tagName == "key") {
|
||||
key = child.nodeValue;
|
||||
} else {
|
||||
if (!key)
|
||||
throw new Error("missing key");
|
||||
dict[key] = $plistParse(child);
|
||||
key = null;
|
||||
}
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
else if (el.tagName == "array") {
|
||||
var arr = [];
|
||||
var childNodes = el.childNodes;
|
||||
for (var i=0, l=childNodes.length; i<l; i++) {
|
||||
var child = childNodes[i];
|
||||
if (child.nodeType !== 1)
|
||||
continue;
|
||||
|
||||
arr.push($plistParse(child));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
else if (el.tagName == "string") {
|
||||
return el.nodeValue;
|
||||
} else {
|
||||
throw new Error("unsupported node type " + el.tagName);
|
||||
}
|
||||
}
|
||||
|
||||
function parseTheme(themeXml) {
|
||||
try {
|
||||
return plistToJson(xml.parseFromString(themeXml).documentElement);
|
||||
} catch(e) { return; }
|
||||
}
|
||||
|
||||
var supportedScopes = {
|
||||
"keyword": "keyword",
|
||||
|
|
@ -253,10 +209,15 @@ var themes = {
|
|||
"vibrant_ink": "Vibrant Ink"
|
||||
};
|
||||
|
||||
for (var name in themes) {
|
||||
function convertTheme(name) {
|
||||
console.log("Converting " + name);
|
||||
var tmTheme = fs.readFileSync(__dirname + "/tmthemes/" + themes[name] + ".tmTheme", "utf8");
|
||||
parseTheme(tmTheme, function(theme) {
|
||||
var styles = extractStyles(theme);
|
||||
theme = createTheme(name, styles, cssTemplate, jsTemplate)
|
||||
fs.writeFileSync(__dirname + "/../lib/ace/theme/" + name + ".js", theme);
|
||||
})
|
||||
}
|
||||
|
||||
var styles = extractStyles(parseTheme(tmTheme));
|
||||
fs.writeFileSync(__dirname + "/../lib/ace/theme/" + name + ".js", createTheme(name, styles, cssTemplate, jsTemplate));
|
||||
}
|
||||
for (var name in themes)
|
||||
convertTheme(name);
|
||||
Loading…
Add table
Add a link
Reference in a new issue