diff --git a/javascripts/wrap-code-terms.js b/javascripts/wrap-code-terms.js index c28a30320ca6..95d07b23062b 100644 --- a/javascripts/wrap-code-terms.js +++ b/javascripts/wrap-code-terms.js @@ -1,7 +1,8 @@ -const wordsLongerThan18Chars = /[\w:/\\]{18,}/g +const wordsLongerThan18Chars = /[\S]{18,}/g const camelCaseChars = /([a-z])([A-Z])/g const underscoresAfter12thChar = /([\w:]{12}[^_]*?)_/g const slashChars = /([/\\])/g +const { escape } = require('lodash') // This module improves table rendering on reference pages by inserting a // tag in code terms that use camelcase, slashes, or underscores, inspired by @@ -12,7 +13,7 @@ export default function () { codeTerms.forEach(node => { // Do the wrapping on the inner text only, so we don't modify hrefs - const oldText = node.textContent + const oldText = escape(node.textContent) const newText = oldText.replace(wordsLongerThan18Chars, (str) => { return str