HTMLDump plugin for Take Command / TCC / TCC/LE

Version 1.2.8     2020-06-12

Charles Dye

Purpose:

This plugin provides a new command HTMLDUMP, which saves the contents of the console buffer to an HTML file.

Installation:

To use this plugin, copy HTMLDump.dll to some known location on your hard drive. (If you are using the 64-bit version of Take Command, take HTMLDump-x64.dll instead.) Load it with a PLUGIN /L command. For example:

plugin /l c:\bin\tcmd\test\htmldump.dll

If you copy the .DLL file to a subdirectory named PlugIns within your Take Command program directory, the plugin will be loaded automatically by each new instance of TCC.

Syntax Note:

The syntax definitions in the following text use these conventions for clarity:

BOLD CODEindicates text which must be typed exactly as shown.
CODEindicates optional text, which may be typed as shown or omitted.
Bold italicnames a required argument; a value must be supplied.
Regular italicnames an optional argument.
ellipsis…after an argument means that more than one may be given.

Plugin Features:


HTMLDUMP command — saves the console buffer to a file as HTML.

Syntax:
HTMLDUMP /BG:color /D /H /HH /K:class /L /N /Nbcls /O /Q /S:style /T:title /U /V /X:cssfile filename

/BG:colorspecify a background color for the page
/Ddo not save color info
/Hadd a header line with the console window’s title
/HHadd a header line with the console window’s title, the date and time
/K:classspecify CSS class name for the <PRE> tag
/Lline numbers
/Ndump the console text only, no HTML head or body
/Nbclsdisable features:
    B: do not write a Byte Order Mark
    C: disable color (same as /D)
    L: do not declare the local language
    S: do not create an internal style sheet
/Oopen the output file
/Qquietly; no message to the console
/S:stylespecify CSS style info for the <PRE> tag
/T:titlespecify a title for the page; the default is “Console Dump” followed by the date and time
/Uoutput UTF-16
/Vdump only the visible region of the buffer
/X:cssfilespecify an external style sheet

If filename matches an existing file, then that file will be overwritten. If filename is not specified, or if it names a directory, then HTMLDUMP will attempt to generate a unique filename. Directory aliases are legal in filename, and CLIP: may be specified to save to the clipboard.


/BG:color lets you choose the background color for the page. Color should be a W3C color name, not a TCC color name. You can also give a six-digit hex value prefixed with a # sign; e.g. /BG:#F0F8FF instead of /BG:ALICEBLUE.


Any class specified with /K:, and/or style specified with /S:, will be applied to the <PRE> tag. Remember to double-quote any value containing spaces, and to double any percent signs. /K: will have no visible effect unless an external style sheet is specified via /X: or the resulting file is edited.

rem  Make the text bigger:
htmldump /o /s:"font-size: 125%%;" test1.html


If /N is specified, the output will contain only the console text, not an HTML header and body. The resulting file will not be a valid web page. This option might be useful when saving to CLIP: to paste into an existing HTML file.


/O will open the output file in the default web browser after the dump is completed. This option will be ignored if the filename is CLIP:.


/U saves as UTF-16. This option may cause the resulting web page to fail validation, but it should still display properly in any common web browser.


/V: By default, HTMLDUMP saves the contents of the console buffer from the top of the buffer, not just the top of the visible window. Text which has scrolled off the top of the window, but remains in the scrollback buffer, will appear in the dump file. Text is saved down to the current cursor position. Any text below the cursor will not be saved. (Usually there isn’t any.) Use CLS /C to empty the console buffer and start over with a clean slate. If you specify /V then only the visible region of the console buffer will be dumped.


/X: adds a link to an external style sheet. Note that HTMLDUMP does not create this file or verify its existence. /X: merely inserts the appropriate reference in the output file; providing cssfile is up to you.

rem  Use an external style sheet:
htmldump /x:style.css test1.html

Style.css might be used to override the internal style sheet:

BODY   { background-color: #6cd; }
PRE    { border: 4px solid #ee0; font-family: "Courier New", Courier, monospace; }


_HTMLDUMP variable — contains the filename of the last successful dump.

This variable is useful because the plugin will automatically generate a filename if none was specified. It is empty until the HTMLDUMP command is first used, and set to *ERROR* if an error was detected.



Startup Message

This plugin displays an informational line when it initializes. The message will be suppressed in transient or pipe shells. You can disable it for all shells by defining an environment variable named NOLOADMSG, for example:

set /e /u noloadmsg=1

Changes:


1.2.82020-06-12Removed undocumented options /J and /#. Added the number of disk writes to the final summary.
1.2.72020-06-09Added /BG and /NL. Internal changes to make the code more maintainable. Moved all the buffered-output stuff out to a separate file.
1.2.62020-05-27Fix for a hypothetical bug which never actually occurs. Removed the last vestiges of Windows-1252 support.
1.2.52020-05-07Adds the console dump area (lines and columns) to the final report. Tweak to /L: line numbers are now in the default console color. Documented the (existing, but previously undocumented) /NS.
1.2.42020-04-23Fix for colors being lost in /N mode.
1.2.32020-04-14Further tweaks to make the output file smaller. Added code to prevent splitting surrogate pairs, which could bollix UTF-16 to UTF-8 conversion. New option /H to add a header line at the top with the console’s title.
1.2.22020-04-12Creates an internal style sheet, which should produce a smaller output file for large console dumps. Removed the table; now the PRE block is embordered by CSS.
1.2.12020-04-10Further tweaks, mostly for speed. Also, HTMLDump does not write to stdout until after the console buffer has been captured.
1.2.02020-04-09This is pretty much a total rewrite. HTMLDump now writes HTML 5, and supports Unicode characters outside the BMP. Removed /C and /P; HTMLDump now always uses a PRE tag. Removed /W, along with all Windows-1252 support. Added /L (line numbers) and /NB (no BOM). The exit code is now 2 if errors occurred during the dump. Reduced the plugin’s memory footprint, made the output file smaller, added much more error checking, and generally made the whole thing less stupid.
1.1.102017-01-05Added /V.
1.1.02014-10-29Changes for TCC v17 compatibility.
1.0.72014-02-25Added /Q.
1.0.62013-04-17Fix for nulls appearing in UTF-8 output; upgraded project to Visual Studio 2010.
1.0.52011-12-14Fixed issue with high-order (>127) characters in UTF-8 output; now Unicode files get a BOM. Added /U and /W to select UTF-16 or Windows-1252 output.

Status and Licensing:

This plugin is © Copyright 2020, Charles Dye. Unaltered copies of the binary and documentation files may be freely distributed without restriction. I make no guarantee and give no warranty for its operation. If you find a problem, you can report it in the JP Software support forum.

Download:

You can download the current version of the plugin from http://prospero.unm.edu/dl/htmldump.zip or ftp://prospero.unm.edu/htmldump.zip.