to_nobr_hyphens(mode=0,
wchars='
' ,
unsafe=False)
|
|
Replace some ordinary hyphens with no-break hyphens [hook
factory].
An ordinary hyphen is replaced in one of the following modes, as given
by the mode parameter:
-
0: if the hyphen is in between two letters, and either preceded or
followed by at most four letters
-
1: if the hyphen is in between two letters and followed by exactly
one letter
Using the wchars parameter, some extra characters other
than letters can be treated as equal to letters.
Note that the function by default substitutes the hyphen only if there
are some Cyrillic letters (or an extra character) in the context, as
otherwise the hyphen may be a part of URL, command, etc. This can be
relaxed by setting unsafe to True , when all
letters are treated equally.
- Parameters:
mode (int) - replacement mode
wchars (string) - extra characters to consider parts of the word
unsafe (bool) - whether to replace hyphen even if no Cyrillic letters nearby
- Returns:
(text) -> text
- type F1A hook
|