Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 37 additions & 1 deletion tools/docx2html/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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++)
{
Expand All @@ -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]}");
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -293,6 +323,11 @@ static void PrintUsage()
Console.WriteLine(" --css-prefix=<text> 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();
Expand All @@ -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");
Expand Down
Loading