Document xterm HTML structure dependency in trimHtmlOutput

Add warning about dependency on xterm's HTML format and the risk
if xterm changes it. Suggest filing an upstream issue for a native
trimEmpty option.
This commit is contained in:
Jared Miller 2026-01-31 12:02:23 -05:00
parent 4502be8d06
commit f2a60658cf
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -46,7 +46,16 @@ export function serializeAsHTML(session: TerminalSession): string {
/**
* Trim empty trailing rows and trailing whitespace from xterm HTML output.
*
* Structure: <html><body><!--StartFragment--><pre><div style='...'><div><span>...</span></div>...</div></pre><!--EndFragment--></body></html>
* WARNING: This function depends on xterm's specific HTML structure from serializeAsHTML().
* If xterm changes their HTML format, this will need updating. Consider filing an issue
* with xterm to add a native trimEmpty option.
*
* Current structure expected:
* - Outer: <pre class="xterm-screen">
* - Rows: <div style="..."><div><span>content</span></div></div>
* - Empty cells: &nbsp; or plain spaces
*
* Full structure: <html><body><!--StartFragment--><pre><div style='...'><div><span>...</span></div>...</div></pre><!--EndFragment--></body></html>
* Each row is: <div><span>content</span></div>
*/
function trimHtmlOutput(html: string): string {