theZiz / aha

Ansi HTML Adapter
Other
907 stars 88 forks source link

Reset sequence switches background to highlighted #64

Closed AlexisGofman closed 4 years ago

AlexisGofman commented 5 years ago

While using the black color scheme, the SGR 'reset' parameter 0 turns the background of all following lines to white.

As an example, this line: \033[1mLast segment %d (task index %d) completed: %s\033[0m Gets turned into: </span><span style="color:white;font-weight:bold;">Last segment 0 (task index 2) completed: Succeeded!</span><span style="color:white;"></span><span style="color:white;background-color:white;">

I'm by no mean well versed in those things, but I've looked into it a little and I believe this is caused by some of the content of the background color array having the wrong index.

theZiz commented 5 years ago

I am having a look at this now.

theZiz commented 5 years ago

I can't reproduce with the most recent version of aha. When I am doing this:

echo -e "Meow\n\033[1mLast segment %d (task index %d) completed: %s\033[0m\nMeow" | ./aha -b

I am getting this result:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This file was created with the aha Ansi HTML Adapter. https://github.com/theZiz/aha -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xml+xhtml; charset=UTF-8"/>
<title>stdin</title>
</head>
<body style="color:white; background-color:black">
<pre>
Meow
<span style="font-weight:bold;">Last segment %d (task index %d) completed: %s</span>
Meow
</pre>
</body>
</html>

So the most recent version does already fix your problem or I didn't understand it at all. :sweat_smile:

You can easily test the most recent version by download from this repository and build yourself by just typing make and then call aha with ./aha to use the local version.

AlexisGofman commented 5 years ago

Thanks for having a look. I found a way to reproduce the error, including with the latest version, using part of a log file my system generate : test_file.txt I run: aha -b -f test_file.txt And it outputs:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This file was created with the aha Ansi HTML Adapter. https://github.com/theZiz/aha -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xml+xhtml; charset=UTF-8" />
<title>test_file.txt</title>
</head>
<body style="color:white; background-color:black">
<pre>
[/topological_graph_planner INFO 1568883670.939314]: Planner reset! (Initial vertex: initial_vertex, initial vertex edges: [], target vertex: target_vertex, target vertex edges: [])
[/navigation/navigation_manager INFO 1568883670.991375]: <span style="font-weight:bold;">New plan received: [1800005219900140044: shelf_reposition, 0: stop]</span><span style="color:white;"></span><span style="color:white;background-color:white;">
[/navigation/navigation_manager INFO 1568883671.000147]: Plan optimized. Modified tasks: approximate: 0, give-way-to-ctrl: 0, stop-if-dockable: 0
</span>
</pre>
</body>
</html>```

I'm not sure whether the flags are right in my file, since I can't seem to display them properly. Maybe something upstream is messing them up, in which case I apologise for bothering :)
bhaak commented 4 years ago

You can easily reproduce the wrong behavior with echo "\e[39mdefault foreground \e[49mdefault background" | aha -b -n.

aha was incorrectly treating SGR 39 and 49 as fixed colors and set them to color 9 instead of resetting the color back to the default value.

I opened PR #67 for this.

theZiz commented 4 years ago

Thank you for giving me an example, figuring out the error and fixing this! :smiley: