FIX: text node emitters should always take strings as parameters even if they

return JsonML.
This commit is contained in:
Robin Ward 2013-12-16 15:21:46 -05:00
parent 341adc93a4
commit 2326d4ceb7

View file

@ -30,8 +30,9 @@ function initializeDialects() {
@method processTextNodes
@param {Array} node the JsonML tree
@param {Object} event the parse node event data
@param {Function} emitter the function to call on the text node
**/
function processTextNodes(node, event) {
function processTextNodes(node, event, emitter) {
if (node.length < 2) { return; }
if (node[0] === '__RAW') {
@ -47,12 +48,7 @@ function processTextNodes(node, event) {
textContent = Discourse.Markdown.sanitize(textContent);
}
var result = textContent;
for (var k=0; k<emitters.length; k++) {
result = emitters[k](result, event);
}
var result = emitter(textContent, event);
if (result) {
if (result instanceof Array) {
for (var i=0; i<result.length; i++) {
@ -85,7 +81,10 @@ function parseTree(tree, path, insideCounts) {
if (tree instanceof Array) {
var event = {node: tree, path: path, dialect: dialect, insideCounts: insideCounts || {}};
Discourse.Dialect.trigger('parseNode', event);
processTextNodes(tree, event);
for (var j=0; j<emitters.length; j++) {
processTextNodes(tree, event, emitters[j]);
}
path = path || [];
insideCounts = insideCounts || {};