@@ -11,16 +11,21 @@ export default function () {
1111 if ( ! codeTerms ) return
1212
1313 codeTerms . forEach ( node => {
14- node . innerHTML = node . innerHTML . replace ( wordsLongerThan18Chars , ( str ) => {
14+ // Do the wrapping on the inner text only, so we don't modify hrefs
15+ const oldText = node . textContent
16+
17+ const newText = oldText . replace ( wordsLongerThan18Chars , ( str ) => {
1518 return str
16- // GraphQL code terms use camelcase
19+ // GraphQL code terms use camelcase
1720 . replace ( camelCaseChars , '$1<wbr>$2' )
18- // REST code terms use underscores
19- // to keep word breaks looking nice, only break on underscores after the 12th char
20- // so `has_organization_projects` will break after `has_organization` instead of after `has_`
21+ // REST code terms use underscores
22+ // to keep word breaks looking nice, only break on underscores after the 12th char
23+ // so `has_organization_projects` will break after `has_organization` instead of after `has_`
2124 . replace ( underscoresAfter12thChar , '$1_<wbr>' )
22- // Some Actions reference pages have tables with code terms separated by slashes
25+ // Some Actions reference pages have tables with code terms separated by slashes
2326 . replace ( slashChars , '$1<wbr>' )
2427 } )
28+
29+ node . innerHTML = node . innerHTML . replace ( oldText , newText )
2530 } )
2631}
0 commit comments