${
this.preEncode(code)
}`
+`` },
map: function(text, func){
return text.replace(this.pre_pattern, func) },
replace: function(text, index, updated){
return this.map(text,
function(match, language, code){
return index-- != 0 ?
match
: ('```'+language
+ (typeof(updated) == 'function' ?
updated(code)
: updated)
+'```') }) },
toHTML: function(text){
return this.map(text, this.handler) },
__pre_parse__: function(text, editor, elem){
return text
.replace(this.pre_pattern, this.pre.bind(this))
.replace(this.quote_pattern, this.quote.bind(this)) },
// XXX is this a good strategy???
__state: undefined,
__keydown__: function(evt, editor, elem){
// code editing...
if(elem.nodeName == 'CODE'
&& elem.getAttribute('contenteditable') == 'true'){
// XXX can keydown and keyup be triggered from different elements???
this.__state = elem.innerText
// XXX move this to keyboard.js...
if(evt.key == 'Escape'){
editor.focus(elem) }
// XXX not sure if the is needed with keyboard.js...
return false } },
// defined