Skip to content
Snippets Groups Projects
Commit 78ff4a06 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Add some regex for #12

parent 7324f3e9
Branches
No related tags found
No related merge requests found
......@@ -45,12 +45,20 @@ logger.addHandler(ch)
def header(s):
"""
SPIP: {{{..}}}
SPIP: {{{...}}}
md: ## ...
"""
return re.sub(r"(^|[^{]){{{([^}]+)}}}([^}]|$)", r"\1\n## \2\n\3", s)
def header_extended(s):
"""
SPIP: {{{{{...}}}}}
md: ### ...
"""
return re.sub(r"(^|[^{]){{{{{([^}]+)}}}}}([^}]|$)", r"\1\n### \2\n\3", s)
def italic(s):
"""
SPIP: {...}
......@@ -58,6 +66,7 @@ def italic(s):
"""
return re.sub(r"(^|[^{]){([^}]+)}([^}]|$)", r"\1*\2*\3", s)
def italic_spaces(s):
"""
SPIP: { ... }
......@@ -66,6 +75,14 @@ def italic_spaces(s):
return re.sub(r"(^|[^{]){ ([^}]+) }([^}]|$)", r"\1*\2*\3", s)
def italic_firstspace(s):
"""
SPIP: { ... }
md: *...*
"""
return re.sub(r"(^|[^{]){ ([^}]+)}([^}]|$)", r"\1*\2*\3", s)
def bold(s):
"""
SPIP: {{...}}
......@@ -268,9 +285,12 @@ def spip_to_markdown(s, website):
s = italic(s)
s = bold(s)
s = italic_spaces(s)
s = italic_firstspace(s)
s = bold(s)
s = ordered_list(s)
s = unordered_list(s)
s = header(s)
s = header_extended(s)
s = horizontal_rule(s)
s = document(s, website)
s = link(s, website)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment