Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def convert_rst_to_md(text):
return pypandoc.convert_text(text, "md", format="rst")
def test_converts_valid_format(self):
self.assertEqualExceptForNewlineEnd(pypandoc.convert_text("ok", format='md', to='rest'), 'ok')
def convert_org_to_html5(self, orgmode):
"""Converts an arbitrary Org mode syntax element (a string) to its
corresponding HTML5 representation.
@param orgmode: Org mode text
@param return: HTML5 representation of Org mode text
"""
assert(isinstance(orgmode, str))
self.stats_external_org_to_html5_conversion += 1
return pypandoc.convert_text(orgmode, 'html5', format='org')
def annotations(self, issue, issue_obj):
if 'type' not in issue:
# Subtask
return []
comments = self._comments(issue)
if comments is None:
return []
return self.build_annotations(
((
c['user'],
pypandoc.convert_text(c['body'], 'md', format='html').rstrip()
) for c in comments),
issue_obj.get_processed_url(issue_obj.record['permalink']),
)
def read_description(filename):
with codecs.open(filename, encoding='utf-8') as f:
try:
import pypandoc
return pypandoc.convert_text(f.read(), format='md', to='rst')
except ImportError:
return f.read()
print(md)
if find_tables:
# find all tables
for table in soup.findAll("table"):
if table.findParent("table") is None:
# remove long LaTeX strings
for i in table.findAll('span', class_="math inline"):
if len(i.string)>max_math_length:
i.string = "(hidden math)" # we could also delete w. `i.decompose`
# tag = text in upper left corner of table
tag = table.thead.tr.findAll('th')[0].string
if tag!=None:
md = pypandoc.convert_text(table, 'plain', format='html')
md = re.sub(r'\n+', '\n', md) # remove double newline
tables[tag] = md
# store dictionary as JSON file
out = json.dumps(tables, indent=2)
with open('tips.json', 'w') as f:
f.write(out)