Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.template_html = json.dumps({
'title': '',
'toc': '',
'main_content': '',
})
self.stdin = StringIO()
self.stdin.read = self.stdin.getvalue
self.stdout = StringIO()
self.backdoc = BackDoc(
markdown_converter=Markdown(extras=['toc']),
template_html=self.template_html,
stdin=self.stdin,
stdout=self.stdout
)
def test_toc_with_persistent_object(self):
"""
Tests that the toc is the same every time it's run on HTML, even if the Markdown object isn't disposed of.
"""
md = markdown2.Markdown(extras=["toc"])
html = """
# Header 1
## Header 1.1
## Header 1.2
### Header 1.3
# Header 2
## Header 2.1
"""
expected_toc_html = """<ul>
<li><a href="#header-1">Header 1</a>
<ul>
<li><a href="#header-11">Header 1.1</a></li>
<li><a href="#header-12">Header 1.2</a>
<ul>
<li><a href="#header-13">Header 1.3</a></li>
</ul></li></ul></li></ul>
def _convert_default (self, content):
import markdown2
tabsize = config.options['tabsize']
content = self._fenced_code_block(content, tabsize)
extras = [ n for n in MD_EXTRAS ]
if config.options['extras']:
for n in config.options['extras'].split(','):
extras.append(n.strip())
md = markdown2.Markdown(extras = extras, tab_width = tabsize)
html = md.convert(content)
if sys.version_info[0] >= 3:
unicode = str
text = unicode(html)
return text
ename, earg = e, None
extras[ename] = earg
else:
extras = None
if opts.link_patterns_file:
link_patterns = []
f = open(opts.link_patterns_file)
try:
for i, line in enumerate(f.readlines()):
if not line.strip(): continue
if line.lstrip().startswith("#"): continue
try:
pat, href = line.rstrip().rsplit(None, 1)
except ValueError:
raise MarkdownError("%s:%d: invalid link pattern line: %r"
% (opts.link_patterns_file, i+1, line))
link_patterns.append(
(_regex_from_encoded_pattern(pat), href))
finally:
f.close()
else:
link_patterns = None
from os.path import join, dirname, abspath, exists
markdown_pl = join(dirname(dirname(abspath(__file__))), "test",
"Markdown.pl")
for path in paths:
if opts.compare:
print "==== Markdown.pl ===="
perl_cmd = 'perl %s "%s"' % (markdown_pl, path)
o = os.popen(perl_cmd)
ename, earg = e, None
extras[ename] = earg
else:
extras = None
if opts.link_patterns_file:
link_patterns = []
f = open(opts.link_patterns_file)
try:
for i, line in enumerate(f.readlines()):
if not line.strip(): continue
if line.lstrip().startswith("#"): continue
try:
pat, href = line.rstrip().rsplit(None, 1)
except ValueError:
raise MarkdownError("%s:%d: invalid link pattern line: %r"
% (opts.link_patterns_file, i+1, line))
link_patterns.append(
(_regex_from_encoded_pattern(pat), href))
finally:
f.close()
else:
link_patterns = None
from os.path import join, dirname, abspath, exists
markdown_pl = join(dirname(dirname(abspath(__file__))), "test",
"Markdown.pl")
if path:
paths = [path]
if not paths:
paths = ['-']
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Operating System :: OS Independent
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Software Development :: Documentation
Topic :: Text Processing :: Filters
Topic :: Text Processing :: Markup :: HTML
"""
script = (sys.platform == "win32" and "lib\\markdown2.py" or "bin/markdown2")
setup(
name="markdown2",
version=markdown2.__version__,
maintainer="Trent Mick",
maintainer_email="trentm@gmail.com",
author="Trent Mick",
author_email="trentm@gmail.com",
url="https://github.com/trentm/python-markdown2",
license="MIT",
platforms=["any"],
py_modules=["markdown2"],
package_dir={"": "lib"},
scripts=[script],
description="A fast and complete Python implementation of Markdown",
classifiers=filter(None, classifiers.split("\n")),
long_description="""markdown2: A fast and complete Python implementation of Markdown.
def _get_markdown_object(buf):
return markdown.markdown("\n".join(buf), extras=['tables', 'codehilite'])
def generate_doc(config):
docdir = os.path.join(cwd,'documentation')
if not os.path.exists(docdir):
print "Couldn't find documentation file at: %s" % docdir
return None
try:
import markdown2 as markdown
except ImportError:
import markdown
documentation = []
for file in os.listdir(docdir):
if file in ignoreFiles or os.path.isdir(os.path.join(docdir, file)):
continue
md = open(os.path.join(docdir,file)).read()
html = markdown.markdown(md)
documentation.append({file:html});
return documentation
if not os.path.exists(docdir):
docdir = os.path.join(cwd,'..','documentation')
if not os.path.exists(docdir):
print "Couldn't find documentation file at: %s" % docdir
return None
try:
import markdown2 as markdown
except ImportError:
import markdown
documentation = []
for file in os.listdir(docdir):
if file in ignoreFiles or os.path.isdir(os.path.join(docdir, file)):
continue
md = open(os.path.join(docdir,file)).read()
html = markdown.markdown(md)
documentation.append({file:html});
return documentation
def get_metadata_div(strategy: bt.Strategy) -> str:
md = ""
md += _get_strategy(strategy)
md += '* * *'
md += _get_datas(strategy)
md += '* * *'
md += _get_observers(strategy)
md += '* * *'
md += _get_analyzers(strategy)
md += '* * *'
css_classes = {'table': 'metaDataTable'}
html = markdown2.markdown(md, extras={
'fenced-code-blocks': None,
'tables': None,
'html-classes': css_classes
})
return html