From 3ac41e92e4cef87c0f833b58a49718088eb05dd7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 12 Jul 2026 20:57:47 +0000 Subject: [PATCH] feat(docx2html): add tracked-changes and story rendering flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The docx2html CLI always accepted revisions before converting, so a redline document rendered as if every change had been applied — there was no way to preview a redline in a browser. Add flags mapping straight onto the existing WmlToHtmlConverterSettings: --track-changes render revisions as ins/del/move markup --no-render-moves lower move markup to plain ins/del --render-comments render document comments --render-footnotes render footnotes and endnotes --render-headers-footers render document headers and footers Defaults are unchanged (all off, moves on), so existing invocations behave identically. This is the preview half of the docx-redlines GitHub Action (JSv4/Python-Redlines#12): the action redlines changed .docx files with the redline CLI and uses docx2html --track-changes to publish browser-viewable previews. Verified: redline over WC001-Digits fixtures reports 4 revisions; converting that output without the flag yields 0 ins/del elements (revisions accepted, prior behavior), with --track-changes yields 4. --- CHANGELOG.md | 3 +++ tools/docx2html/Program.cs | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bffaaf8..d1973587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added +- **`docx2html` CLI: tracked-changes and story rendering flags.** The `docx2html` tool previously always accepted revisions before converting, so a redline document rendered as if every change had been applied — there was no way to preview a redline in a browser. New flags map straight onto the existing `WmlToHtmlConverterSettings`: `--track-changes` (render revisions as `ins`/`del`/move markup instead of accepting them — `RenderTrackedChanges`), `--no-render-moves` (lower move markup to plain ins/del — `RenderMoveOperations`), `--render-comments`, `--render-footnotes`, and `--render-headers-footers`. Defaults are unchanged (all off, moves on), so existing invocations behave identically. This is the preview half of the docx-redlines GitHub Action (JSv4/Python-Redlines#12): the action redlines changed `.docx` files with the `redline` CLI and uses `docx2html --track-changes` to publish browser-viewable previews. + ## [7.0.1] - 2026-07-11 ### Changed diff --git a/tools/docx2html/Program.cs b/tools/docx2html/Program.cs index 6f8f5b52..8436dabc 100644 --- a/tools/docx2html/Program.cs +++ b/tools/docx2html/Program.cs @@ -13,7 +13,7 @@ namespace Docx2Html; class Program { - const string Version = "1.0.0"; + const string Version = "1.1.0"; static int Main(string[] args) { @@ -36,6 +36,11 @@ static int Main(string[] args) string cssPrefix = "pt-"; bool embedImages = true; bool inlineStyles = false; + bool trackChanges = false; + bool renderMoves = true; + bool renderComments = false; + bool renderFootnotes = false; + bool renderHeadersFooters = false; for (int i = 0; i < args.Length; i++) { @@ -57,6 +62,26 @@ static int Main(string[] args) { embedImages = false; } + else if (args[i] == "--track-changes") + { + trackChanges = true; + } + else if (args[i] == "--no-render-moves") + { + renderMoves = false; + } + else if (args[i] == "--render-comments") + { + renderComments = true; + } + else if (args[i] == "--render-footnotes") + { + renderFootnotes = true; + } + else if (args[i] == "--render-headers-footers") + { + renderHeadersFooters = true; + } else if (args[i].StartsWith("-")) { Console.Error.WriteLine($"Error: Unknown option: {args[i]}"); @@ -138,6 +163,11 @@ static int Main(string[] args) CssClassPrefix = cssPrefix, RestrictToSupportedLanguages = false, RestrictToSupportedNumberingFormats = false, + RenderTrackedChanges = trackChanges, + RenderMoveOperations = renderMoves, + RenderComments = renderComments, + RenderFootnotesAndEndnotes = renderFootnotes, + RenderHeadersAndFooters = renderHeadersFooters, ImageHandler = imageInfo => { if (imageInfo.ContentType == null) @@ -293,6 +323,11 @@ static void PrintUsage() Console.WriteLine(" --css-prefix= CSS class prefix (default: pt-)"); Console.WriteLine(" --inline-styles Use inline styles instead of CSS classes"); Console.WriteLine(" --extract-images Save images to separate files instead of embedding"); + Console.WriteLine(" --track-changes Render tracked changes as ins/del markup instead of accepting them"); + Console.WriteLine(" --no-render-moves Render moves as plain ins/del (only with --track-changes)"); + Console.WriteLine(" --render-comments Render document comments"); + Console.WriteLine(" --render-footnotes Render footnotes and endnotes"); + Console.WriteLine(" --render-headers-footers Render document headers and footers"); Console.WriteLine(" -h, --help Show this help message"); Console.WriteLine(" -v, --version Show version information"); Console.WriteLine(); @@ -301,6 +336,7 @@ static void PrintUsage() Console.WriteLine(" docx2html document.docx output.html"); Console.WriteLine(" docx2html document.docx --title=\"My Document\""); Console.WriteLine(" docx2html document.docx --extract-images --inline-styles"); + Console.WriteLine(" docx2html redline.docx --track-changes --render-footnotes"); Console.WriteLine(); Console.WriteLine("Environment Variables:"); Console.WriteLine(" DOCX2HTML_DEBUG=1 Show detailed error information");