From 9299eb36e640349a036f2516696844242c0ec11e Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Thu, 1 Aug 2019 21:21:55 -0600 Subject: [PATCH] [YAML Exporter] apply fix just applied to Markdown Exporter --- jrnl/plugins/yaml_exporter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 1442adcc..c0735811 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -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 = ''