import re
def parse(markdown):
result = ''
for line in markdown.splitlines():
line = re.sub(r'__(.*)__', r'\1', line)
line = re.sub(r'_(.*)_', r'\1', line)
match = re.match(r'^(#{1,6}) (.*)', line)
if match:
level = len(match.group(1))
result += f'
' + line + '
' return result