diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2014-06-19 07:53:17 -0400 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2014-06-19 07:53:17 -0400 |
commit | 819be506a669713354a96b478b2175396fe75d9c (patch) | |
tree | 2e3e36c68de508f8b0681646ee9cbee0d663c1e9 /markdown/extensions/smarty.py | |
parent | 51857fd458c991a10c7a9d8797ba8fb03af2f4d8 (diff) | |
parent | 2d47fcedc08973b0250d29c456609c8a687037cd (diff) | |
download | markdown-819be506a669713354a96b478b2175396fe75d9c.tar.gz markdown-819be506a669713354a96b478b2175396fe75d9c.tar.bz2 markdown-819be506a669713354a96b478b2175396fe75d9c.zip |
Merge pull request #319 from mitya57/master
smarty: add support for angled quotes
Diffstat (limited to 'markdown/extensions/smarty.py')
-rw-r--r-- | markdown/extensions/smarty.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py index 21f30a4..8131591 100644 --- a/markdown/extensions/smarty.py +++ b/markdown/extensions/smarty.py @@ -137,6 +137,7 @@ class SmartyExtension(Extension): def __init__(self, configs): self.config = { 'smart_quotes': [True, 'Educate quotes'], + 'smart_angled_quotes': [False, 'Educate angled quotes'], 'smart_dashes': [True, 'Educate dashes'], 'smart_ellipses': [True, 'Educate ellipses'] } @@ -162,6 +163,14 @@ class SmartyExtension(Extension): ellipsesPattern = SubstituteTextPattern(r'(?<!\.)\.{3}(?!\.)', ('…',), md) self.inlinePatterns.add('smarty-ellipses', ellipsesPattern, '_begin') + def educateAngledQuotes(self, md): + leftAngledQuotePattern = SubstituteTextPattern(r'\<\<', ('«',), md) + rightAngledQuotePattern = SubstituteTextPattern(r'\>\>', ('»',), md) + self.inlinePatterns.add('smarty-left-angle-quotes', + leftAngledQuotePattern, '_begin') + self.inlinePatterns.add('smarty-right-angle-quotes', + rightAngledQuotePattern, '>smarty-left-angle-quotes') + def educateQuotes(self, md): patterns = ( (singleQuoteStartRe, (rsquo,)), @@ -186,6 +195,8 @@ class SmartyExtension(Extension): self.educateEllipses(md) if configs['smart_quotes']: self.educateQuotes(md) + if configs['smart_angled_quotes']: + self.educateAngledQuotes(md) if configs['smart_dashes']: self.educateDashes(md) inlineProcessor = InlineProcessor(md) |