[YAML Exporter] apply fix just applied to Markdown Exporter

This commit is contained in:
MinchinWeb 2019-08-01 21:21:55 -06:00
parent 1884a6ce23
commit e95290f92f

View file

@ -3,6 +3,7 @@
from __future__ import absolute_import, unicode_literals, print_function
from .text_exporter import TextExporter
import os
import re
import sys
from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR
@ -34,17 +35,17 @@ class YAMLExporter(TextExporter):
previous_line = ''
warn_on_heading_level = False
for line in entry.body.splitlines(True):
if re.match(r"#+ ", line):
if re.match(r"^#+ ", line):
"""ATX style headings"""
newbody = newbody + previous_line + heading + line
if re.match(r"#######+ ", heading + line):
if re.match(r"^#######+ ", heading + line):
warn_on_heading_level = True
line = ''
elif re.match(r"=+$", line) and not re.match(r"^$", previous_line):
elif re.match(r"^=+$", line.rstrip()) and not re.match(r"^$", previous_line.strip()):
"""Setext style H1"""
newbody = newbody + heading + "# " + previous_line
line = ''
elif re.match(r"-+$", line) and not re.match(r"^$", previous_line):
elif re.match(r"^-+$", line.rstrip()) and not re.match(r"^$", previous_line.strip()):
"""Setext style H2"""
newbody = newbody + heading + "## " + previous_line
line = ''