server side processing too

This commit is contained in:
John McLear 2021-01-14 16:23:27 +00:00
parent 1cbaf2d272
commit 1cad0a6707

View file

@ -393,6 +393,7 @@ const makeContentCollector = function (
const tname = (dom.nodeTagName(node) || '').toLowerCase(); const tname = (dom.nodeTagName(node) || '').toLowerCase();
const styl = dom.nodeAttr(node, 'style'); const styl = dom.nodeAttr(node, 'style');
const cls = dom.nodeAttr(node, 'class'); const cls = dom.nodeAttr(node, 'class');
console.warn(tname);
if (tname === 'img') { if (tname === 'img') {
// no hook sare called in this branch, just a demo.. // no hook sare called in this branch, just a demo..
hooks.callAll('collectContentImage', { hooks.callAll('collectContentImage', {
@ -403,13 +404,16 @@ const makeContentCollector = function (
cls, cls,
node, node,
}); });
// Client side processing
if (node.src) state.lineAttributes.img = node.src; if (node.src) state.lineAttributes.img = node.src;
this.breakLine = true; // Server side processing
if (node.attribs && node.attribs.src) state.lineAttributes.img = node.attribs.src;
} else if (tname === 'br') { } else if (tname === 'br') {
// Delete line Attributes that can pollute line breaks, they should only // Delete line Attributes that can pollute line breaks, they should only
// be present in the line itself, not in any attributes of a line.. // be present in the line itself, not in any attributes of a line..
// uncommenting the below will make duplicate images.. :) // uncommenting the below will make duplicate images.. :)
if (state.lineAttributes) delete state.lineAttributes; if (state.lineAttributes) delete state.lineAttributes;
console.warn("state", state);
this.breakLine = true; this.breakLine = true;
const tvalue = dom.nodeAttr(node, 'value'); const tvalue = dom.nodeAttr(node, 'value');
const induceLineBreak = hooks.callAll('collectContentLineBreak', { const induceLineBreak = hooks.callAll('collectContentLineBreak', {
@ -605,6 +609,7 @@ const makeContentCollector = function (
if (oldAuthorOrNull) { if (oldAuthorOrNull) {
_exitAuthor(state, oldAuthorOrNull); _exitAuthor(state, oldAuthorOrNull);
} }
console.warn("state", state.lineAttributes);
} }
} }
_reachBlockPoint(node, 1, state); _reachBlockPoint(node, 1, state);