commit
0cff85920e
5 changed files with 31 additions and 13 deletions
|
|
@ -33,6 +33,12 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
var XHTML_NS = "http://www.w3.org/1999/xhtml";
|
var XHTML_NS = "http://www.w3.org/1999/xhtml";
|
||||||
|
|
||||||
|
exports.getDocumentHead = function(doc) {
|
||||||
|
if (!doc)
|
||||||
|
doc = document;
|
||||||
|
return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
|
||||||
|
}
|
||||||
|
|
||||||
exports.createElement = function(tag, ns) {
|
exports.createElement = function(tag, ns) {
|
||||||
return document.createElementNS ?
|
return document.createElementNS ?
|
||||||
document.createElementNS(ns || XHTML_NS, tag) :
|
document.createElementNS(ns || XHTML_NS, tag) :
|
||||||
|
|
@ -134,8 +140,7 @@ exports.importCssString = function importCssString(cssText, id, doc) {
|
||||||
if (id)
|
if (id)
|
||||||
style.id = id;
|
style.id = id;
|
||||||
|
|
||||||
var head = doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
|
exports.getDocumentHead(doc).appendChild(style);
|
||||||
head.appendChild(style);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -147,8 +152,7 @@ exports.importCssStylsheet = function(uri, doc) {
|
||||||
link.rel = 'stylesheet';
|
link.rel = 'stylesheet';
|
||||||
link.href = uri;
|
link.href = uri;
|
||||||
|
|
||||||
var head = doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
|
exports.getDocumentHead(doc).appendChild(link);
|
||||||
head.appendChild(link);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
var dom = require("./dom");
|
||||||
|
|
||||||
exports.get = function (url, callback) {
|
exports.get = function (url, callback) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
@ -22,18 +23,19 @@ exports.get = function (url, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.loadScript = function(path, callback) {
|
exports.loadScript = function(path, callback) {
|
||||||
var head = document.head || document.getElementsByTagName('head')[0];
|
var head = dom.getDocumentHead();
|
||||||
var s = document.createElement('script');
|
var s = document.createElement('script');
|
||||||
|
|
||||||
s.src = path;
|
s.src = path;
|
||||||
head.appendChild(s);
|
head.appendChild(s);
|
||||||
|
|
||||||
if (s.onload !== undefined)
|
s.onload = s.onreadystatechange = function(_, isAbort) {
|
||||||
s.onload = callback;
|
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
|
||||||
else
|
s = s.onload = s.onreadystatechange = null;
|
||||||
s.onreadystatechange = function () {
|
if (!isAbort)
|
||||||
this.readyState == 'loaded' && callback();
|
callback();
|
||||||
};
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,13 @@ test: header ends with '#'
|
||||||
test: 6+ #s is not a valid header
|
test: 6+ #s is not a valid header
|
||||||
####### foo
|
####### foo
|
||||||
test: # followed be only space is not a valid header
|
test: # followed be only space is not a valid header
|
||||||
|
#
|
||||||
test: only space between #s is not a valid header
|
test: only space between #s is not a valid header
|
||||||
# #
|
# #
|
||||||
|
|
||||||
# test links [Cloud9 IDE](http://www.c9.io/) #
|
# test links [Cloud9 IDE](http://www.c9.io/) #
|
||||||
* [demo](http://ajaxorg.github.com/ace/)
|
* [demo](http://ajaxorg.github.com/ace/)
|
||||||
|
* usually *work* fine (_em_)
|
||||||
in lists
|
in lists
|
||||||
|
|
||||||
in plain text <b>http://ace.ajaxorg.com<b>
|
in plain text <b>http://ace.ajaxorg.com<b>
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@
|
||||||
],[
|
],[
|
||||||
"start",
|
"start",
|
||||||
["text","test: # followed be only space is not a valid header"]
|
["text","test: # followed be only space is not a valid header"]
|
||||||
|
],[
|
||||||
|
"start",
|
||||||
|
["text","# "]
|
||||||
],[
|
],[
|
||||||
"start",
|
"start",
|
||||||
["text","test: only space between #s is not a valid header"]
|
["text","test: only space between #s is not a valid header"]
|
||||||
|
|
@ -62,6 +65,13 @@
|
||||||
["markup.underline","http://ajaxorg.github.com/ace/"],
|
["markup.underline","http://ajaxorg.github.com/ace/"],
|
||||||
["text",")"],
|
["text",")"],
|
||||||
["markup.list"," "]
|
["markup.list"," "]
|
||||||
|
],[
|
||||||
|
"listblock",
|
||||||
|
["markup.list","* usually "],
|
||||||
|
["string","*work*"],
|
||||||
|
["markup.list"," fine ("],
|
||||||
|
["string","_em_"],
|
||||||
|
["markup.list",")"]
|
||||||
],[
|
],[
|
||||||
"listblock",
|
"listblock",
|
||||||
["markup.list","in lists"]
|
["markup.list","in lists"]
|
||||||
|
|
|
||||||
|
|
@ -150,12 +150,12 @@ var MarkdownHighlightRules = function() {
|
||||||
token : "empty_line",
|
token : "empty_line",
|
||||||
regex : "^$",
|
regex : "^$",
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
|
||||||
include : "basic", noEscape: true
|
|
||||||
}, { // list
|
}, { // list
|
||||||
token : "markup.list",
|
token : "markup.list",
|
||||||
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
|
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
|
||||||
next : "listblock-start"
|
next : "listblock-start"
|
||||||
|
}, {
|
||||||
|
include : "basic", noEscape: true
|
||||||
}, {
|
}, {
|
||||||
defaultToken : "markup.list"
|
defaultToken : "markup.list"
|
||||||
} ],
|
} ],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue