Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
defined:
"""
if (
"sectioning-levels" in definition
and isinstance(definition["sectioning-levels"], MetaInlines)
and len(definition["sectioning-levels"].content) == 1
):
match = re.match(
Numbered.header_regex, definition["sectioning-levels"].content[0].text
)
if match:
# Compute the first and last levels section
defined[category]["first-section-level"] = len(match.group("hidden")) // 2
defined[category]["last-section-level"] = len(match.group("header")) // 2
if "first-section-level" in definition:
if isinstance(definition["first-section-level"], MetaString):
value = definition["first-section-level"].text
elif (
isinstance(definition["first-section-level"], MetaInlines)
and len(definition["first-section-level"].content) == 1
):
value = definition["first-section-level"].content[0].text
else:
debug(
"[WARNING] pandoc-numbering: first-section-level is not correct for category "
+ category
)
return
# Get the level
try:
level = int(value) - 1
def test_all():
md = 'Some *markdown* **text** ~xyz~'
c_md = pf.convert_text(md)
b_md = [pf.Para(pf.Str("Some"), pf.Space,
pf.Emph(pf.Str("markdown")), pf.Space,
pf.Strong(pf.Str("text")), pf.Space,
pf.Subscript(pf.Str("xyz")))]
print("Benchmark MD:")
print(b_md)
print("Converted MD:")
print(c_md)
assert repr(c_md) == repr(b_md)
with io.StringIO() as f:
doc = pf.Doc(*c_md)
pf.dump(doc, f)
c_md_dump = f.getvalue()
with io.StringIO() as f:
link=MetaString("http://www.google.fr"),
),
MetaString("comments"),
),
size=MetaString("36"),
position=MetaString("right"),
),
MetaMap(
classes=MetaList(MetaString("warning")),
icons=MetaString("comments"),
),
MetaMap(
classes=MetaList(MetaString("tip")), position=MetaString("left")
),
MetaMap(
classes=MetaList(MetaString("v5.0")),
icons=MetaList(
MetaMap(
name=MetaString("balance-scale"),
version=MetaString("5.x"),
variant=MetaString("solid"),
color=MetaString("orange"),
)
def metadata(cls):
return {
"pandoc-latex-tip": MetaList(
MetaMap(
classes=MetaList(MetaString("tip"), MetaString("listing")),
icons=MetaList(
MetaMap(
name=MetaString("file-text"),
color=MetaString("darksalmon"),
link=MetaString("http://www.google.fr"),
),
MetaString("comments"),
),
size=MetaString("36"),
position=MetaString("right"),
),
MetaMap(
classes=MetaList(MetaString("warning")),
icons=MetaString("comments"),
),
MetaMap(
classes=MetaList(MetaString("tip")), position=MetaString("left")
),
MetaMap(
classes=MetaList(MetaString("v5.0")),
def metadata(cls):
return {
"pandoc-latex-tip": MetaList(
MetaMap(
classes=MetaList(MetaString("tip"), MetaString("listing")),
icons=MetaList(
MetaMap(
name=MetaString("file-text"),
color=MetaString("darksalmon"),
link=MetaString("http://www.google.fr"),
),
MetaString("comments"),
),
size=MetaString("36"),
position=MetaString("right"),
),
MetaMap(
classes=MetaList(MetaString("warning")),
icons=MetaString("comments"),
),
MetaMap(
classes=MetaList(MetaString("tip")), position=MetaString("left")
),
MetaMap(
classes=MetaList(MetaString("v5.0")),
icons=MetaList(
MetaMap(
name=MetaString("balance-scale"),
version=MetaString("5.x"),
variant=MetaString("solid"),
color=MetaString("orange"),
def metadata(cls):
return {
"pandoc-latex-tip": MetaList(
MetaMap(
classes=MetaList(MetaString("tip"), MetaString("listing")),
icons=MetaList(
MetaMap(
name=MetaString("file-text"),
color=MetaString("darksalmon"),
link=MetaString("http://www.google.fr"),
),
MetaString("comments"),
),
size=MetaString("36"),
position=MetaString("right"),
),
MetaMap(
classes=MetaList(MetaString("warning")),
icons=MetaString("comments"),
),
MetaMap(
classes=MetaList(MetaString("tip")), position=MetaString("left")
),
MetaMap(
classes=MetaList(MetaString("v5.0")),
icons=MetaList(
MetaMap(
classes=MetaList(MetaString("tip"), MetaString("listing")),
icons=MetaList(
MetaMap(
name=MetaString("file-text"),
color=MetaString("darksalmon"),
link=MetaString("http://www.google.fr"),
),
MetaString("comments"),
),
size=MetaString("36"),
position=MetaString("right"),
),
MetaMap(
classes=MetaList(MetaString("warning")),
icons=MetaString("comments"),
),
MetaMap(
classes=MetaList(MetaString("tip")), position=MetaString("left")
),
MetaMap(
classes=MetaList(MetaString("v5.0")),
icons=MetaList(
MetaMap(
name=MetaString("balance-scale"),
version=MetaString("5.x"),
variant=MetaString("solid"),
color=MetaString("orange"),
)
def metadata(cls):
return {
"pandoc-latex-tip": MetaList(
MetaMap(
classes=MetaList(MetaString("tip"), MetaString("listing")),
icons=MetaList(
MetaMap(
name=MetaString("file-text"),
color=MetaString("darksalmon"),
link=MetaString("http://www.google.fr"),
),
MetaString("comments"),
),
size=MetaString("36"),
position=MetaString("right"),
),
MetaMap(
classes=MetaList(MetaString("warning")),
icons=MetaString("comments"),
),
MetaMap(
classes=MetaList(MetaString("tip")), position=MetaString("left")
),
MetaMap(
classes=MetaList(MetaString("v5.0")),
icons=MetaList(
MetaMap(
name=MetaString("balance-scale"),
def metadata(cls):
return {
"pandoc-latex-tip": MetaList(
MetaMap(
classes=MetaList(MetaString("tip"), MetaString("listing")),
icons=MetaList(
MetaMap(
name=MetaString("file-text"),
color=MetaString("darksalmon"),
link=MetaString("http://www.google.fr"),
),
MetaString("comments"),
),
size=MetaString("36"),
position=MetaString("right"),
),
MetaMap(
classes=MetaList(MetaString("warning")),
icons=MetaString("comments"),
),
MetaMap(
print("\nBack and forth conversions... md->json->md")
md = 'Some *markdown* **text** ~xyz~'
print("[MD]", md)
md2json = pf.convert_text(md, input_format='markdown', output_format='json')
print("[JSON]", md2json)
md2json2md = pf.convert_text(md2json, input_format='json', output_format='markdown')
print("[MD]", md2json2md)
assert md == md2json2md
print("\nBack and forth conversions... md->panflute->md")
md = 'Some *markdown* **text** ~xyz~'
print("[MD]", md)
md2panflute = pf.convert_text(md, input_format='markdown', output_format='panflute')
print("[PANFLUTE]", md2panflute)
md2panflute2md = pf.convert_text(md2panflute, input_format='panflute', output_format='markdown')
print("[MD]", md2panflute2md)
assert md == md2panflute2md
print("\nBack and forth conversions... md->panflute(standalone)->md")
md = 'Some *markdown* **text** ~xyz~'
print("[MD]", md)
md2panflute = pf.convert_text(md, input_format='markdown', output_format='panflute', standalone=True)
print("[PANFLUTE]", md2panflute)
md2panflute2md = pf.convert_text(md2panflute, input_format='panflute', output_format='markdown')
print("[MD]", md2panflute2md)
assert md == md2panflute2md
print("\nBack and forth conversions... md table -> json(standalone) -> md table")
md = """lorem