From 5c00eea122eaf4c645c2eec3b3e01b9ee18c02e0 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 20 Dec 2017 11:35:27 +0100 Subject: [PATCH] Fix stripping of lines in asciidoc2html This broke in #3382 since re.fullmatch does a different thing for trailing newlines: >>> line '===========\n' >>> re.match(r'^=+$', line) <_sre.SRE_Match object; span=(0, 11), match='==========='> >>> re.fullmatch(r'=+', line) >>> This now strips the line by default, and adds newlines if needed. --- scripts/asciidoc2html.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py index dce1f27bd..01af53693 100755 --- a/scripts/asciidoc2html.py +++ b/scripts/asciidoc2html.py @@ -147,13 +147,14 @@ class AsciiDoc: last_line = "" for line in infp: - if line.strip() == '// QUTE_WEB_HIDE': + line = line.rstrip() + if line == '// QUTE_WEB_HIDE': assert not hidden hidden = True - elif line.strip() == '// QUTE_WEB_HIDE_END': + elif line == '// QUTE_WEB_HIDE_END': assert hidden hidden = False - elif line == "The Compiler \n": + elif line == "The Compiler ": continue elif re.fullmatch(r':\w+:.*', line): # asciidoc field @@ -163,16 +164,16 @@ class AsciiDoc: if re.fullmatch(r'=+', line): line = line.replace('=', '-') found_title = True - title = last_line.rstrip('\n') + " | qutebrowser\n" + title = last_line + " | qutebrowser\n" title += "=" * (len(title) - 1) elif re.fullmatch(r'= .+', line): line = '==' + line[1:] found_title = True - title = last_line.rstrip('\n') + " | qutebrowser\n" + title = last_line + " | qutebrowser\n" title += "=" * (len(title) - 1) if not hidden: - outfp.write(line.replace(".asciidoc[", ".html[")) + outfp.write(line.replace(".asciidoc[", ".html[") + '\n') last_line = line current_lines = outfp.getvalue()