Skip to content

Commit

Permalink
Renamed 'smart_substitutions' option to 'substitutions'. Fixed a typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinAltmayer committed Aug 15, 2014
1 parent e90687e commit e7b6a33
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/extensions/smarty.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ASCII symbol | Replacements | HTML Entities
`--` | – | `–`
`---` | — | `—`

Using the configuration option 'smart_substitutions' you can overwrite the
Using the configuration option 'substitutions' you can overwrite the
default substitutions. Just pass a dict mapping (a subset of) the following
keys to the substitution strings.

Expand All @@ -34,7 +34,7 @@ keys to the substitution strings.
Use e.g. the following config to get correct quotes for the German language:

extensionConfigs = {
'smarty': [('smart_substitutions', {
'smarty': [('substitutions', {
'left-single-quote': '‚', # sb is not a typo!
'right-single-quote': '‘',
'left-double-quote': '„',
Expand Down Expand Up @@ -71,7 +71,7 @@ Option | Default value | Description
`smart_quotes` | enabled | whether to convert straight quotes
`smart_angled_quotes` | disabled | whether to convert angled quotes
`smart_ellipses` | enabled | whether to convert ellipses
`smart_substitutions` | {} | Overwrite default substitutions
`substitutions` | {} | overwrite default substitutions

Further reading
---------------
Expand Down
5 changes: 2 additions & 3 deletions markdown/extensions/smarty.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,11 @@ def __init__(self, *args, **kwargs):
'smart_angled_quotes': [False, 'Educate angled quotes'],
'smart_dashes': [True, 'Educate dashes'],
'smart_ellipses': [True, 'Educate ellipses'],
'smart_substitutions' : [{}, 'Overwrite default substitutions'],
'substitutions' : [{}, 'Overwrite default substitutions'],
}
super(SmartyExtension, self).__init__(*args, **kwargs)
self.substitutions = dict(substitutions)
self.substitutions.update(self.getConfig('smart_substitutions',
default={}))
self.substitutions.update(self.getConfig('substitutions', default={}))

def _addPatterns(self, md, patterns, serie):
for ind, pattern in enumerate(patterns):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def setUp(self):
config = {
'smarty': [
('smart_angled_quotes', True),
('smart_substitutions', {
('substitutions', {
'ndash': '\u2013',
'mdash': '\u2014',
'ellipsis': '\u2026',
Expand All @@ -615,4 +615,4 @@ def testCustomSubstitutions(self):
"""<p>[ The &bdquo;Unicode char of the year 2014&ldquo;
is the &sbquo;mdash&lsquo;: \u2014
Must not be confused with &sbquo;ndash&lsquo; (\u2013) \u2026 ]</p>"""
self.assertEqual(self.md.convert(text), correct)
self.assertEqual(self.md.convert(text), correct)

0 comments on commit e7b6a33

Please sign in to comment.