From cd2ce0f1c4e10f7e1822bf9b8ff24d4385e8bb8d Mon Sep 17 00:00:00 2001 From: nsantacruz Date: Wed, 18 May 2022 21:05:34 +0300 Subject: [PATCH] dont wrap text in a tags with clickableWords --- sefaria.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sefaria.js b/sefaria.js index 402fd6b0..dbb85beb 100644 --- a/sefaria.js +++ b/sefaria.js @@ -1426,14 +1426,22 @@ Sefaria.util = { // self-closing case return `<${node.name} ${attributes}>`; } + const shouldWrapChildren = node.name !== "a"; // dont wrap contents in a tags. + const nodeContents = node.children.map( + (c, i) => _wrap(c, i, shouldWrapChildren) + ).join(''); return ( - `<${node.name} ${attributes}>${node.children.map((c, i) => _wrap(c, i)).join('')}` + `<${node.name} ${attributes}>${nodeContents}` ); }; - const _wrap = (node, index) => { + const _wrap = (node, index, shouldWrapChildren) => { switch (node.type) { case ElementType.Text: - return _wrapTextNode(node, index); + if (shouldWrapChildren) { + return _wrapTextNode(node, index); + } else { + return node.data; + } case ElementType.Tag: return _wrapElement(node, index); }