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
1 changed files with 7 additions and 8 deletions

View File

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