Bug 438901 - Add a command-line option to save buffer as HTML
Summary: Add a command-line option to save buffer as HTML
Status: REPORTED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 21.04.2
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-19 08:03 UTC by Christopher Yeleighton
Modified: 2021-12-30 21:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Yeleighton 2021-06-19 08:03:50 UTC
SUMMARY
I am trying to figure out how to convert a log to HTML.  The build log contains terminal control sequences.  I know I can achieve it using Konsole by streaming it and saving the buffer as HTML.  I would appreciate a command line option --save to automate this process.

STEPS TO REPRODUCE
1. { konsole -s >out.html -e cat out.log; }

OBSERVED RESULT
Unknown option "-s"!

EXPECTED RESULT
A HTML version of the log in file out.html.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: openSUSE Tumbleweed 20210615
(available in About System)
KDE Plasma Version: 5.22.0
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 ninjalj 2021-06-19 18:54:55 UTC
A workaround using xdotool:

konsole -e 'sh -c "rm ~/colors.html; cat ~/colors.txt; xdotool key ctrl+S; sleep 1; xdotool type ~/colors.html; sleep 1; xdotool key Return; sleep 1"'

This workaround uses xdotool to invoke the "Save Output As..." menu, then writes the filename, and sends a Return key to invoke the default "Save" button.

The "sleep"s are important. They let the previous action complete before invoking another action. The last one prevents Konsole from exiting before it has completed the save action.
Comment 2 Christopher Yeleighton 2021-06-20 15:09:47 UTC
(In reply to ninjalj from comment #1)
> A workaround using xdotool:
> 
> konsole -e 'sh -c "rm ~/colors.html; cat ~/colors.txt; xdotool key ctrl+S;
> sleep 1; xdotool type ~/colors.html; sleep 1; xdotool key Return; sleep 1"'
> 
> This workaround uses xdotool to invoke the "Save Output As..." menu, then
> writes the filename, and sends a Return key to invoke the default "Save"
> button.
> 
> The "sleep"s are important. They let the previous action complete before
> invoking another action. The last one prevents Konsole from exiting before
> it has completed the save action.

This workaround requires starting a separate display, I am afraid.