14
0
mirror of https://github.com/belluzj/fantasque-sans.git synced 2024-12-22 07:21:31 +01:00

Protects some sequences for being ligaturized

This commit is contained in:
John Mager 2020-06-20 20:24:45 -04:00
parent 2508b90ce9
commit 7506577e37

View File

@ -59,6 +59,16 @@ def rule(liga):
rules.append(ignore([liga[-2]], liga[0], liga[1:])) rules.append(ignore([liga[-2]], liga[0], liga[1:]))
rules.append(ignore(head=liga[0], suffix=(liga[1:] + [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. `<||>` # hardcoded ignores, i.e. `<||>`
rules.extend(ignores[tuple(liga)]) 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): def indent(text, prefix):
return '\n'.join(prefix + line for line in text.split('\n')) return '\n'.join(prefix + line for line in text.split('\n'))