mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-12 01:18:31 +02:00
[YAML Exporter] apply fix just applied to Markdown Exporter
This commit is contained in:
parent
1884a6ce23
commit
e95290f92f
1 changed files with 5 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
from __future__ import absolute_import, unicode_literals, print_function
|
from __future__ import absolute_import, unicode_literals, print_function
|
||||||
from .text_exporter import TextExporter
|
from .text_exporter import TextExporter
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR
|
from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR
|
||||||
|
@ -34,17 +35,17 @@ class YAMLExporter(TextExporter):
|
||||||
previous_line = ''
|
previous_line = ''
|
||||||
warn_on_heading_level = False
|
warn_on_heading_level = False
|
||||||
for line in entry.body.splitlines(True):
|
for line in entry.body.splitlines(True):
|
||||||
if re.match(r"#+ ", line):
|
if re.match(r"^#+ ", line):
|
||||||
"""ATX style headings"""
|
"""ATX style headings"""
|
||||||
newbody = newbody + previous_line + heading + line
|
newbody = newbody + previous_line + heading + line
|
||||||
if re.match(r"#######+ ", heading + line):
|
if re.match(r"^#######+ ", heading + line):
|
||||||
warn_on_heading_level = True
|
warn_on_heading_level = True
|
||||||
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 H1"""
|
"""Setext style H1"""
|
||||||
newbody = newbody + heading + "# " + previous_line
|
newbody = newbody + heading + "# " + previous_line
|
||||||
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"""
|
"""Setext style H2"""
|
||||||
newbody = newbody + heading + "## " + previous_line
|
newbody = newbody + heading + "## " + previous_line
|
||||||
line = ''
|
line = ''
|
||||||
|
|
Loading…
Add table
Reference in a new issue