tig / winprint

winprint 2.0 - Advanced source code and text file printing. The perfect tool for printing source code, web pages, reports generated by legacy systems, documentation, or any text or HTML file. It works interactively or from the command line making it great for single users or whole enterprises. Works great with Powershell.
https://tig.github.io/winprint/
MIT License
73 stars 5 forks source link

AnsiCte (with text/ansi) adds extra line to end of file #23

Closed tig closed 4 years ago

tig commented 4 years ago

Describe the bug

AnsiCte - text/plain

AnsiCte - text/ansi

tig commented 4 years ago

Describe the bug

AnsiCte - text/plain

  • [x] Zero length files should show as having one line.
  • [x] One line files should show as having one line.
  • [x] 1000 line files should show as having 1000 lines.

AnsiCte - text/ansi

  • [x] Zero length files should show as having one line.
  • [x] One line files should show as having one line.
  • [x] 1000 line files should show as having 1000 lines.

Implemented a workaround for: https://github.com/pygments/pygments/issues/1435

                    if (!string.IsNullOrEmpty($"{file}.an") && File.Exists($"{file}.an")) {
                        Log.Debug("Reading {file}", $"{file}.an");
                        document = await File.ReadAllTextAsync($"{file}.an", Encoding.UTF8).ConfigureAwait(true);

                        // HACK: Because of this bug: https://github.com/pygments/pygments/issues/1435
                        if (document[^1] == '\n')
                            document = document.Remove(document.Length - 1, 1);
                    }