Add --no-unicode flag to disable combining marks in output - #105
Conversation
This commit adds a new command-line flag `--no-unicode` that allows users to disable Unicode combining marks (strikethrough and underline characters) in the diff output while preserving ANSI color highlighting. This addresses the issue where the dual formatting (colors + unicode marks) creates difficulties when converting output to HTML and LaTeX formats. The implementation: - Adds `--no-unicode` flag to the argument parser in __main__.py - Passes the `enable_unicode` parameter to the Printer constructor - Sets the `CombiningMarkWriter.enabled` property based on user preference When `--no-unicode` is specified, only ANSI colors are used to highlight additions (green) and deletions (red), making the output easier to process downstream while maintaining visual differentiation. Fixes #35 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
cc: @smoelius |
|
This PR doesn't seem to disable combining markers in unicode output, it disables all output, if I am reading the code changes correctly. I need to test it a bit more to confirm. |
ESultanik
left a comment
There was a problem hiding this comment.
Thanks for the patch, and apologies for leaving this sitting for so long.
First, correcting my earlier comment. I said this looked like it disabled all output rather than only the combining marks. I have now tested it, and that reading was wrong. CombiningMarkWriter.write reads enabled only to choose between interleaving marks and a plain raw_write, and the same text reaches the stream either way. The flag does what its help text says.
Your patch was blocked by a separate bug, which is now fixed on master. When I tested this branch, redirected output came out with neither colors nor marks, which made the diff unreadable. That turned out not to be your change: colorama.init() was running at import time and replacing sys.stdout with a wrapper that strips ANSI whenever stdout is not a terminal. Forcing --color into a file produced zero escape bytes on master too, with or without your patch. I filed that as #128 and fixed it in #130.
Could you merge in master or rebase onto master? After that, these are the remaining items:
- Add a test.
test/test_graphtage.pyalready buildsPrinter(ansi_color=True, out_stream=StringIO())and asserts on exact output, so a case that prints the same diff withenable_unicode=Falseand asserts the result equals the marked output withU+0336andU+031Fremoved fits in a few lines. - Consider an
HTMLPrinter.under_plus()override to match thestrike()override atprinter.py:639. Under--html --color --no-unicode, removals keep theirtext-decoration: line-throughspan while insertions lose their marker. - Consider noting in the
--helptext that the flag applies only when color is on. With--no-color,@only_ansi(printer.py:401-417) already suppresses the marks and you get the++/~~fallbacks, so--no-color --no-unicodeand--no-colorproduce identical output. I measured both at 89 bytes.
Item 1 is the one I would like before merging. Items 2 and 3 are optional and I am happy to take them as follow-ups.
This commit adds a new command-line flag
--no-unicodethat allows users to disable Unicode combining marks (strikethrough and underline characters) in the diff output while preserving ANSI color highlighting. This addresses the issue where the dual formatting (colors + unicode marks) creates difficulties when converting output to HTML and LaTeX formats.The implementation:
--no-unicodeflag to the argument parser in main.pyenable_unicodeparameter to the Printer constructorCombiningMarkWriter.enabledproperty based on user preferenceWhen
--no-unicodeis specified, only ANSI colors are used to highlight additions (green) and deletions (red), making the output easier to process downstream while maintaining visual differentiation.Fixes #35
🤖 Generated with Claude Code