Skip to content

Commit

Permalink
Disable universal newlines for writer (#140)
Browse files Browse the repository at this point in the history
Problems noticed on Windows where preformatted blocks (e.g. source & literal blocks) have an extra space between each line.  In fact, *all* lines have this extra space, but it is only noticeable on preformatted blocks where the extra line spacing is visible.

By default, Python 3 has universal newlines mode enabled, which makes outputting files with various line endings simpler.  However, AsciiDoc is already handling this internally, so we ended up with extra lines being inserted.  In the actual output file, every line on Windows ended with "/r/r/n".  This was not a problem on systems that used UNIX line endings.

Solve this by disabling universal newlines when outputting the file.
  • Loading branch information
hoadlck committed Aug 22, 2020
1 parent 01fd9b7 commit 9b9dc0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion asciidoc.py
Expand Up @@ -4594,7 +4594,7 @@ def open(self, fname, bom=None):
if fname == '<stdout>':
self.f = sys.stdout
else:
self.f = open(fname, 'w+', encoding='utf-8')
self.f = open(fname, 'w+', encoding='utf-8', newline="")
message.verbose('writing: ' + writer.fname, False)
if bom:
self.f.write(bom)
Expand Down

0 comments on commit 9b9dc0d

Please sign in to comment.