From a49eb87f59756d917b7200d624e1738603e16e0d Mon Sep 17 00:00:00 2001 From: PatrikBak Date: Sun, 17 May 2026 01:31:13 +0200 Subject: [PATCH] Default \ReviewModetrue; have the CLI inject the publish form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `\ReviewModetrue` was an opt-in toggle authors flipped on while reviewing a draft locally. The hazard: the toggle lived in the .tex source itself, so a forgotten line on a finished handout shipped the review form to the website (it just did, on angle-basics-1.sk.tex). The local workflow is always review; only the Handouts CLI produces the publish form. So invert the default: the template now starts `\ReviewMode` true, and the CLI defines a `\PUBLISH` sentinel on the pdfcsplain command line before \input — the template flips itself off when it sees the sentinel. Manual pdfcsplain compiles keep producing the inline-solutions PDF; the CLI is the single gate that produces the publish PDF. --- backend/src/Tools/MathComps.Cli.Handouts/BuildCommand.cs | 7 +++++-- data/handouts/_template.tex | 8 ++++++-- data/handouts/angle-basics-1.sk.tex | 2 -- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/src/Tools/MathComps.Cli.Handouts/BuildCommand.cs b/backend/src/Tools/MathComps.Cli.Handouts/BuildCommand.cs index 8378db4..961d338 100644 --- a/backend/src/Tools/MathComps.Cli.Handouts/BuildCommand.cs +++ b/backend/src/Tools/MathComps.Cli.Handouts/BuildCommand.cs @@ -519,8 +519,11 @@ private static void CompileTexFile( var compilerParts = compiler.Split(' ', StringSplitOptions.RemoveEmptyEntries); var compilerExecutable = compilerParts[0]; - // Pass each flag as its own argv entry plus the input .tex filename at the end - string[] arguments = [.. compilerParts.Skip(1), texFile.Name]; + // Pass each flag as its own argv entry, then inject \def\PUBLISH{} before \input + // reads the .tex. The template defaults \ReviewModetrue so manual local compiles + // render inline review content; the \PUBLISH sentinel flips it off, producing + // the publish form (where hints and solutions are not below statements but at the end) + string[] arguments = [.. compilerParts.Skip(1), $@"\def\PUBLISH{{}}\input {texFile.Name}"]; // Run the compiler; ProcessRunner drains stdout/stderr and reports the exit code var result = ProcessRunner.Run(compilerExecutable, arguments, workingDirectory.FullName); diff --git a/data/handouts/_template.tex b/data/handouts/_template.tex index ed3ee29..da4e06e 100644 --- a/data/handouts/_template.tex +++ b/data/handouts/_template.tex @@ -24,9 +24,13 @@ \newif\ifDisplayTexts \DisplayTextstrue -% Toggle to inline hints/solutions under each Problem and Exercise (review mode) +% Toggle to inline hints/solutions under each Problem and Exercise (review mode). +% Defaults to TRUE so manual local compiles render the inline review form; the +% Handouts CLI defines \PUBLISH before it reads the handout via \input, which +% flips this off and produces the publish form. \newif\ifReviewMode -\ReviewModefalse +\ReviewModetrue +\ifdefined\PUBLISH\ReviewModefalse\fi % Render #1 if solutions should be inline (review mode OR display-texts), else #2 \long\def\IfShowingTexts#1#2{\ifReviewMode#1\else\ifDisplayTexts#1\else#2\fi\fi} diff --git a/data/handouts/angle-basics-1.sk.tex b/data/handouts/angle-basics-1.sk.tex index ae442b4..b27efda 100644 --- a/data/handouts/angle-basics-1.sk.tex +++ b/data/handouts/angle-basics-1.sk.tex @@ -2,8 +2,6 @@ \setlanguage{SK} -\ReviewModetrue - \Title{Základy počítania uhlov} \MathcompsLink{zaklady-pocitania-uhlov-1}