Bug 438901

Summary: Add a command-line option to save buffer as HTML
Product: [Applications] konsole Reporter: Christopher Yeleighton <giecrilj>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: REPORTED ---    
Severity: wishlist CC: ninjalj
Priority: NOR    
Version: 21.04.2   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

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.