diff --git a/pre-commit.py b/pre-commit.py index d83c251..203e8e1 100755 --- a/pre-commit.py +++ b/pre-commit.py @@ -73,7 +73,16 @@ def gfm(text): text = re.sub(r'{gfm-extraction-([0-9a-f]{32})\}', pre_insert_callback, text) - return text + def handle_typography(text): + """ Add non breakable spaces before double punctuation signs.""" + text = text.replace(' :', ' :') + text = text.replace(' ;', ' ;') + text = text.replace(' !', ' !') + text = text.replace(' ?', ' ?') + text = text.replace(' /', ' /') + return text + + return handle_typography(text) # Test suite.