Compare commits

...

11 Commits

Author SHA1 Message Date
AlexVonB
9231704988 Merge branch 'develop' 2021-12-11 14:44:58 +01:00
AlexVonB
c8f7cf63e3 bump to v0.10.1 2021-12-11 14:44:34 +01:00
AlexVonB
12a68a7d14 allow flake8 v4.x
closes #57
2021-12-11 14:43:14 +01:00
AlexVonB
1613c302bc Merge branch 'develop' 2021-11-17 17:11:01 +01:00
AlexVonB
478b1c7e13 bump to v0.10.0 2021-11-17 17:10:15 +01:00
AlexVonB
ffcf6cbcb2 fix readme for code_language 2021-11-17 17:09:47 +01:00
AlexVonB
0ab0452414 add readme for code_language 2021-11-17 17:08:14 +01:00
AlexVonB
b62b067cbd Merge branch 'Inzaniak-develop' into develop 2021-11-17 17:05:07 +01:00
AlexVonB
cb2646cd93 differentiated between text and code language 2021-11-17 17:03:31 +01:00
AlexVonB
9692b5e714 satisfy linter 2021-11-17 16:55:00 +01:00
Umberto Grando
ac68c53a7d added language for multiline code 2021-11-01 21:19:35 +01:00
5 changed files with 16 additions and 3 deletions

1
.gitignore vendored
View File

@@ -8,3 +8,4 @@
/MANIFEST
/venv
build/
.vscode/settings.json

View File

@@ -96,6 +96,12 @@ newline_style
newline). While the latter convention is non-standard, it is commonly
preferred and supported by a lot of interpreters.
code_language
Defines the language that should be assumed for all ``<pre>`` sections.
Useful, if all code on a page is in the same programming language and
should be annotated with `````python`` or similar.
Defaults to ``''`` (empty string) and can be any string.
Options may be specified as kwargs to the ``markdownify`` function, or as a
nested ``Options`` class in ``MarkdownConverter`` subclasses.

View File

@@ -76,6 +76,7 @@ class MarkdownConverter(object):
strong_em_symbol = ASTERISK
sub_symbol = ''
sup_symbol = ''
code_language = ''
class Options(DefaultOptions):
pass
@@ -324,7 +325,7 @@ class MarkdownConverter(object):
def convert_pre(self, el, text, convert_as_inline):
if not text:
return ''
return '\n```\n%s\n```\n' % text
return '\n```%s\n%s\n```\n' % (self.options['code_language'], text)
convert_s = convert_del

View File

@@ -10,7 +10,7 @@ read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()
pkgmeta = {
'__title__': 'markdownify',
'__author__': 'Matthew Tretter',
'__version__': '0.9.4',
'__version__': '0.10.1',
}
@@ -70,7 +70,7 @@ setup(
zip_safe=False,
include_package_data=True,
setup_requires=[
'flake8>=3.8,<4',
'flake8>=3.8,<5',
],
tests_require=[
'pytest>=6.2,<7',

View File

@@ -210,3 +210,8 @@ def test_sub():
def test_sup():
assert md('<sup>foo</sup>') == 'foo'
assert md('<sup>foo</sup>', sup_symbol='^') == '^foo^'
def test_lang():
assert md('<pre>test\n foo\nbar</pre>', code_language='python') == '\n```python\ntest\n foo\nbar\n```\n'
assert md('<pre><code>test\n foo\nbar</code></pre>', code_language='javascript') == '\n```javascript\ntest\n foo\nbar\n```\n'