Change option to newline_style and use variables like heading_style does
This commit is contained in:
@@ -78,8 +78,8 @@ bullets
|
|||||||
strong_em_symbol
|
strong_em_symbol
|
||||||
In markdown, both ``*`` and ``_`` are used to encode **strong** or *emphasized* texts. The preferred symbol can be passed through this argument, that defaults to ``*``.
|
In markdown, both ``*`` and ``_`` are used to encode **strong** or *emphasized* texts. The preferred symbol can be passed through this argument, that defaults to ``*``.
|
||||||
|
|
||||||
newline
|
newline_style
|
||||||
Defines the style of marking linebreaks (``<br>``) in markdown. The default value ``'spaces'`` of this option means the regular `` \n`` will be used (i.e. two spaces and a newline), while ``'backslash'`` will convert a linebreak to ``\\n`` (a backslash an a newline). While the latter convention is non-standard, it is commonly preferred and supported by a lot of interpreters.
|
Defines the style of marking linebreaks (``<br>``) in markdown. The default value ``SPACES`` of this option means the regular `` \n`` will be used (i.e. two spaces and a newline), while ``BACKSLASH`` will convert a linebreak to ``\\n`` (a backslash an a newline). While the latter convention is non-standard, it is commonly preferred and supported by a lot of interpreters.
|
||||||
|
|
||||||
Options may be specified as kwargs to the ``markdownify`` function, or as a
|
Options may be specified as kwargs to the ``markdownify`` function, or as a
|
||||||
nested ``Options`` class in ``MarkdownConverter`` subclasses.
|
nested ``Options`` class in ``MarkdownConverter`` subclasses.
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ ATX_CLOSED = 'atx_closed'
|
|||||||
UNDERLINED = 'underlined'
|
UNDERLINED = 'underlined'
|
||||||
SETEXT = UNDERLINED
|
SETEXT = UNDERLINED
|
||||||
|
|
||||||
|
# Newline style
|
||||||
|
SPACES = 'spaces'
|
||||||
|
BACKSLASH = 'backslash'
|
||||||
|
|
||||||
def escape(text):
|
def escape(text):
|
||||||
if not text:
|
if not text:
|
||||||
@@ -47,7 +50,7 @@ class MarkdownConverter(object):
|
|||||||
heading_style = UNDERLINED
|
heading_style = UNDERLINED
|
||||||
bullets = '*+-' # An iterable of bullet types.
|
bullets = '*+-' # An iterable of bullet types.
|
||||||
strong_em_symbol = '*'
|
strong_em_symbol = '*'
|
||||||
newline = 'spaces'
|
newline_style = SPACES
|
||||||
|
|
||||||
class Options(DefaultOptions):
|
class Options(DefaultOptions):
|
||||||
pass
|
pass
|
||||||
@@ -156,7 +159,7 @@ class MarkdownConverter(object):
|
|||||||
if convert_as_inline:
|
if convert_as_inline:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
if self.options['newline'] == 'backslash':
|
if self.options['newline_style'] == BACKSLASH:
|
||||||
return '\\\n'
|
return '\\\n'
|
||||||
else:
|
else:
|
||||||
return ' \n'
|
return ' \n'
|
||||||
|
|||||||
Reference in New Issue
Block a user