diff options
author | Florian Bruhin <git@the-compiler.org> | 2017-12-20 11:35:27 +0100 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2017-12-20 11:35:27 +0100 |
commit | 5c00eea122eaf4c645c2eec3b3e01b9ee18c02e0 (patch) | |
tree | 63fc3d05d32db9b0885fe397389bb9a1d607595f | |
parent | 3c0d51c253dfd5e95cf40cbfeaa171bfa7aa4365 (diff) | |
download | qutebrowser-5c00eea122eaf4c645c2eec3b3e01b9ee18c02e0.tar.gz qutebrowser-5c00eea122eaf4c645c2eec3b3e01b9ee18c02e0.zip |
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.
-rwxr-xr-x | scripts/asciidoc2html.py | 13 |
1 files 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 <mail@qutebrowser.org>\n": + elif line == "The Compiler <mail@qutebrowser.org>": 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() |