Code Duplication    Length = 20-23 lines in 2 locations

jrnl/plugins/yaml_exporter.py 1 location

@@ 46-68 (lines=23) @@
43
        previous_line = ""
44
        warn_on_heading_level = False
45
        for line in body.splitlines(True):
46
            if re.match(r"^#+ ", line):
47
                """ATX style headings"""
48
                newbody = newbody + previous_line + heading + line
49
                if re.match(r"^#######+ ", heading + line):
50
                    warn_on_heading_level = True
51
                line = ""
52
            elif re.match(r"^=+$", line.rstrip()) and not re.match(
53
                r"^$", previous_line.strip()
54
            ):
55
                """Setext style H1"""
56
                newbody = newbody + heading + "# " + previous_line
57
                line = ""
58
            elif re.match(r"^-+$", line.rstrip()) and not re.match(
59
                r"^$", previous_line.strip()
60
            ):
61
                """Setext style H2"""
62
                newbody = newbody + heading + "## " + previous_line
63
                line = ""
64
            elif multi_tag_regex.match(line):
65
                """Tag only lines"""
66
                line = ""
67
            else:
68
                newbody = newbody + previous_line
69
            previous_line = line
70
        newbody = newbody + previous_line  # add very last line
71

jrnl/plugins/markdown_exporter.py 1 location

@@ 37-56 (lines=20) @@
34
        previous_line = ""
35
        warn_on_heading_level = False
36
        for line in body.splitlines(True):
37
            if re.match(r"^#+ ", line):
38
                """ATX style headings"""
39
                newbody = newbody + previous_line + heading + line
40
                if re.match(r"^#######+ ", heading + line):
41
                    warn_on_heading_level = True
42
                line = ""
43
            elif re.match(r"^=+$", line.rstrip()) and not re.match(
44
                r"^$", previous_line.strip()
45
            ):
46
                """Setext style H1"""
47
                newbody = newbody + heading + "# " + previous_line
48
                line = ""
49
            elif re.match(r"^-+$", line.rstrip()) and not re.match(
50
                r"^$", previous_line.strip()
51
            ):
52
                """Setext style H2"""
53
                newbody = newbody + heading + "## " + previous_line
54
                line = ""
55
            else:
56
                newbody = newbody + previous_line
57
            previous_line = line
58
        newbody = newbody + previous_line  # add very last line
59