diff --git a/README.rst b/README.rst index e4004ea..6e914b7 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,11 @@ strong_em_symbol *emphasized* texts. Either of these symbols can be chosen by the options ``ASTERISK`` (default) or ``UNDERSCORE`` respectively. +sub_symbol, sup_symbol + Define the chars that surround ```` and ```` text. Defaults to an + empty string, because this is non-standard behavior. Could be something like + ``~`` and ``^`` to result in ``~sub~`` and ``^sup^``. + newline_style Defines the style of marking linebreaks (``
``) in markdown. The default value ``SPACES`` of this option will adopt the usual two spaces and a newline, diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 013b1b4..ffde006 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -66,14 +66,16 @@ def _todict(obj): class MarkdownConverter(object): class DefaultOptions: - strip = None - convert = None autolinks = True + bullets = '*+-' # An iterable of bullet types. + convert = None default_title = False heading_style = UNDERLINED - bullets = '*+-' # An iterable of bullet types. - strong_em_symbol = ASTERISK newline_style = SPACES + strip = None + strong_em_symbol = ASTERISK + sub_symbol = '' + sup_symbol = '' class Options(DefaultOptions): pass @@ -325,6 +327,10 @@ class MarkdownConverter(object): convert_samp = convert_code + convert_sub = abstract_inline_conversion(lambda self: self.options['sub_symbol']) + + convert_sup = abstract_inline_conversion(lambda self: self.options['sup_symbol']) + def convert_table(self, el, text, convert_as_inline): return '\n\n' + text + '\n' diff --git a/tests/test_conversions.py b/tests/test_conversions.py index b90067a..b88d887 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -201,3 +201,13 @@ def test_strong_em_symbol(): assert md('Hello', strong_em_symbol=UNDERSCORE) == '__Hello__' assert md('Hello', strong_em_symbol=UNDERSCORE) == '_Hello_' assert md('Hello', strong_em_symbol=UNDERSCORE) == '_Hello_' + + +def test_sub(): + assert md('foo') == 'foo' + assert md('foo', sub_symbol='~') == '~foo~' + + +def test_sup(): + assert md('foo') == 'foo' + assert md('foo', sup_symbol='^') == '^foo^'