diff --git a/python/markdown/markdown.py b/python/markdown/markdown.py index 6f83971..f9824e9 100644 --- a/python/markdown/markdown.py +++ b/python/markdown/markdown.py @@ -2,34 +2,29 @@ import re def parse(markdown): - res = '' - in_list = False + result = '' for line in markdown.splitlines(): - match = re.match(r'^(#{1,6}) (.*)', line) - if match: - level = len(match.group(1)) - res += f'{match.group(2)}' - continue - line = re.sub(r'__(.*)__', r'\1', line) line = re.sub(r'_(.*)_', r'\1', line) - match = re.match(r'\* (.*)', line) + match = re.match(r'^(#{1,6}) (.*)', line) if match: - if not in_list: - in_list = True - res += '' + match = re.match(r'\* (.*)', line) + if match: - res += '

' + line + '

' + if result.endswith(''): + result = result[:-5] + else: + result += '' + result += '
  • ' + match.group(1) + '
  • ' + continue - return res + result += '

    ' + line + '

    ' + + return result