mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-11 09:08:32 +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 .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 = ''
|
||||
|
|
Loading…
Add table
Reference in a new issue