Skip to content

Commit

Permalink
Avoid to add the invisible classes in the glossary (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
amieiro committed Jul 27, 2023
1 parent 440b1a3 commit cc09bd2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions gp-templates/helper-functions.php
Expand Up @@ -34,15 +34,6 @@ function( $m ) use ( &$glossary_entries ) {
// Wrap placeholders with notranslate.
$text = preg_replace( '/(%(\d+\$(?:\d+)?)?[bcdefgosuxEFGX])/', '<span class="notranslate">\\1</span>', $text );

// Put the glossaries back!
$text = preg_replace_callback(
'!(<span GLOSSARY=(\d+)>)!',
function( $m ) use ( $glossary_entries ) {
return $glossary_entries[ $m[2] ];
},
$text
);

// Highlight two or more spaces between words.
$text = preg_replace( '/(?!^) +(?!$)/', '<span class="invisible-spaces">$0</span>', $text );
// Highlight leading and trailing spaces in single lines.
Expand All @@ -55,6 +46,15 @@ function( $m ) use ( $glossary_entries ) {
$text = str_replace( array( "\r", "\n" ), "<span class='invisibles' title='" . esc_attr__( 'New line', 'glotpress' ) . "'>&crarr;</span>\n", $text );
$text = str_replace( "\t", "<span class='invisibles' title='" . esc_attr__( 'Tab character', 'glotpress' ) . "'>&rarr;</span>\t", $text );

// Put the glossaries back!
$text = preg_replace_callback(
'!(<span GLOSSARY=(\d+)>)!',
function( $m ) use ( $glossary_entries ) {
return $glossary_entries[ $m[2] ];
},
$text
);

return $text;
}

Expand Down

0 comments on commit cc09bd2

Please sign in to comment.