From a6eb3e0c2c97bd916e7dd9e3a56c8909c993a0d8 Mon Sep 17 00:00:00 2001 From: Phyks Date: Thu, 7 Aug 2014 22:38:43 +0200 Subject: [PATCH] Typography for markdown files --- pre-commit.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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.