diff options
author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-04-26 18:49:15 +0200 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2021-04-26 19:27:20 +0200 |
commit | f58122eaa289b540341d282a3ec7af7afb38d466 (patch) | |
tree | 64ae4499bb8c10b9ee0bf74d7442978b4bb63c38 | |
parent | 8a59e623c1137b965dd711af9baf6c943a8eb8ef (diff) | |
download | vendor_replicant-release-scripts-f58122eaa289b540341d282a3ec7af7afb38d466.tar.gz vendor_replicant-release-scripts-f58122eaa289b540341d282a3ec7af7afb38d466.tar.bz2 vendor_replicant-release-scripts-f58122eaa289b540341d282a3ec7af7afb38d466.zip |
release_notes.py: Add blank line between the elements of a list
Without that, emacs will break the lists when using fill-paragraph
on them: they will end up in a compact single paragraph with * in
the middle of the text.
Since the width limit doesn't seem to work well at least with
recent versions of python and/or beatifulsoup, it's good not to
break the ability to fix it with emacs.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rwxr-xr-x | release_notes.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/release_notes.py b/release_notes.py index a23efc9..f704aa9 100755 --- a/release_notes.py +++ b/release_notes.py @@ -87,6 +87,24 @@ def fix_alignment(string): return new_string +# Emacs breaks lists when doing a fill-paragraph to adjust a paragraph to the +# maximum width so we make sure that there is at least one blank line before +# the '*' +def fix_lists(string): + new_string = '' + nr_lineseps_before_star = 0 + for c in string: + if c == '*' and nr_lineseps_before_star == 1: + new_string += os.linesep + + if c == os.linesep: + nr_lineseps_before_star += 1 + else: + nr_lineseps_before_star = 0 + + new_string += c + return new_string + def convert(html_file_path): with open(html_file_path) as html_file: try: @@ -118,6 +136,7 @@ def convert(html_file_path): text = fix_wordpress_references_link(text) text = fix_alignment(text) + text = fix_lists(text) return text |