hugo-theme-learn icon indicating copy to clipboard operation
hugo-theme-learn copied to clipboard

Fix mermaid highlight

Open dirkkelly opened this issue 6 years ago • 4 comments

Resolves https://github.com/matcornic/hugo-theme-learn/issues/235

Attempted to use https://github.com/vjeantet/hugo-theme-docdock/pull/113/files but that wasn't working

dirkkelly avatar Jun 11 '19 09:06 dirkkelly

This seems to still be happening for me on the preview website. Searching for Alice is erasing that term from the sequence chart. https://deploy-preview-300--learn.netlify.com/en/shortcodes/mermaid/

(Firefox 68)

matalo33 avatar Jul 30 '19 20:07 matalo33

Searching for Alice on this doesn't break it and actually works. The scope of this change seems fairly benign is there any reason this doesn't make life better for people instead of breaking pages?

EdBondArcher avatar May 19 '20 22:05 EdBondArcher

something like this might work better to allow for subgraphs

if (match) {
                if (
                    $(node).parents(".language-mermaid").length > 0 ||
                    $(node).parents(".mermaid").length > 0
                ) {
                    return 0;
                }
                var highlight = document.createElement(nodeName || 'span');
                highlight.className = className || 'highlight';

                var wordNode = node.splitText(match.index);
                wordNode.splitText(match[0].length);
                var wordClone = wordNode.cloneNode(true);
                highlight.appendChild(wordClone);
                wordNode.parentNode.replaceChild(highlight, wordNode);
                return 1; //skip added node in parent
            }

EdBondArcher avatar May 19 '20 22:05 EdBondArcher

I provided a different more robust solution in #451

McShelby avatar Sep 13 '20 13:09 McShelby