Browse Source

Protects some sequences for being ligaturized

pull/134/head
John Mager 2 years ago
parent
commit
7506577e37
  1. 22
      Scripts/features.py

22
Scripts/features.py

@ -59,6 +59,16 @@ def rule(liga):
rules.append(ignore([liga[-2]], liga[0], liga[1:]))
rules.append(ignore(head=liga[0], suffix=(liga[1:] + [liga[1]])))
# Don't cut into `prefix` to complete a ligature.
# i.e. regex `(?=`> is not `(?`=>.
rules.extend(
[
ignore(prefix[:-n], liga[0], liga[1:])
for prefix in ignore_prefixes
for n in range(1, len(liga))
if prefix[-n:] == liga[:n]
]
)
# hardcoded ignores, i.e. `<||>`
rules.extend(ignores[tuple(liga)])
@ -198,5 +208,17 @@ ignores = defaultdict(
)
ignore_prefixes = [
["parenleft", "question", "colon"],
# Regexp lookahead/lookbehind
["parenleft", "question", "equal"],
["parenleft", "question", "less", "equal"],
["parenleft", "question", "exclam"],
["parenleft", "question", "less", "exclam"],
# PHP <?=
["less", "question", "equal"],
]
def indent(text, prefix):
return '\n'.join(prefix + line for line in text.split('\n'))

Loading…
Cancel
Save