Skip to content

Commit

Permalink
dont wrap text in a tags with clickableWords
Browse files Browse the repository at this point in the history
  • Loading branch information
nsantacruz committed May 18, 2022
1 parent be4ad0b commit cd2ce0f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sefaria.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}>`
`<${node.name} ${attributes}>${nodeContents}</${node.name}>`
);
};
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);
}
Expand Down

0 comments on commit cd2ce0f

Please sign in to comment.