Skip to content

Commit 15f3f14

Browse files
authored
Tweak code wrapping in tables (#16406)
* tweak code wrapping * empty commit to rerun ci
1 parent cddf7a0 commit 15f3f14

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

javascripts/wrap-code-terms.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const wordsLongerThan18Chars = /[\w:/\\]{18,}/g
1+
const wordsLongerThan18Chars = /[\S]{18,}/g
22
const camelCaseChars = /([a-z])([A-Z])/g
33
const underscoresAfter12thChar = /([\w:]{12}[^_]*?)_/g
44
const slashChars = /([/\\])/g
5+
const { escape } = require('lodash')
56

67
// This module improves table rendering on reference pages by inserting a <wbr>
78
// tag in code terms that use camelcase, slashes, or underscores, inspired by
@@ -12,7 +13,7 @@ export default function () {
1213

1314
codeTerms.forEach(node => {
1415
// Do the wrapping on the inner text only, so we don't modify hrefs
15-
const oldText = node.textContent
16+
const oldText = escape(node.textContent)
1617

1718
const newText = oldText.replace(wordsLongerThan18Chars, (str) => {
1819
return str

0 commit comments

Comments
 (0)