Skip to content

Commit

Permalink
! re-escape tags in inline code blocks, needs to be extended further
Browse files Browse the repository at this point in the history
  • Loading branch information
Spuds committed Apr 2, 2024
1 parent 0d56d0a commit ae61aaa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion themes/default/scripts/elk_toolTips.js
Expand Up @@ -52,8 +52,8 @@ class SiteTooltip
{
let title = el.getAttribute('title');

el.setAttribute('data-title', title);
el.removeAttribute('title');
el.setAttribute('data-title', title);
el.addEventListener('mouseenter', this.showTooltip.bind(this));
el.addEventListener('mouseleave', this.hideTooltip.bind(this));
}
Expand Down Expand Up @@ -123,6 +123,16 @@ class SiteTooltip
// Load the tooltip content with our data-title
if (this.settings.tooltipContent === 'html')
{
// Regular expression to match content inside .bbc_code_inline span
let regex = new RegExp('(<span class="bbc_code_inline">).*?(<\/span>)', 's');

title = title.replace(regex, function(match, p1, p2)
{
let content = match.slice(p1.length, -p2.length);
let replacedContent = content.replace(/</g, "&lt;");
return p1 + replacedContent + p2;
});

tooltipText.innerHTML = title;
}
else
Expand Down

0 comments on commit ae61aaa

Please sign in to comment.