diff --git a/news/changelog-1.10.md b/news/changelog-1.10.md index ce22b2fe2e1..1079e57fa75 100644 --- a/news/changelog-1.10.md +++ b/news/changelog-1.10.md @@ -6,3 +6,9 @@ All changes included in 1.10: - ([#14261](https://github.com/quarto-dev/quarto-cli/issues/14261)): Fix theorem/example block titles containing inline code producing invalid Typst markup when syntax highlighting is applied. +## Commands + +### `quarto check` + +- ([#14265](https://github.com/quarto-dev/quarto-cli/issues/14265)): Fix `quarto check` not detecting MiKTeX on Windows even when available in system PATH. + diff --git a/src/command/check/check.ts b/src/command/check/check.ts index 46c6ed15728..25a555078bd 100644 --- a/src/command/check/check.ts +++ b/src/command/check/check.ts @@ -414,8 +414,23 @@ async function checkInstall(conf: CheckConfiguration) { latexOutput.push(`${kIndent}Version: ${version}`); latexJson["version"] = version; } else { - latexOutput.push(`${kIndent}Tex: (not detected)`); - latexJson["installed"] = false; + // Check for MiKTeX (uses initexmf instead of tlmgr) + const miktexDetection = await detectMiktex(); + if (miktexDetection) { + latexOutput.push(`${kIndent}Using: MiKTeX`); + if (miktexDetection.path) { + latexOutput.push(`${kIndent}Path: ${miktexDetection.path}`); + latexJson["path"] = miktexDetection.path; + } + latexJson["source"] = "miktex"; + if (miktexDetection.version) { + latexOutput.push(`${kIndent}Version: ${miktexDetection.version}`); + latexJson["version"] = miktexDetection.version; + } + } else { + latexOutput.push(`${kIndent}Tex: (not detected)`); + latexJson["installed"] = false; + } } }; if (conf.jsonResult) { @@ -561,3 +576,50 @@ async function detectChromeForCheck(): Promise { return result; } + +interface MiktexDetectionResult { + path?: string; + version?: string; +} + +async function detectMiktex(): Promise { + try { + const initexmfPath = await which("initexmf"); + if (!initexmfPath) { + return undefined; + } + + const result: MiktexDetectionResult = { + path: dirname(initexmfPath), + }; + + // Get MiKTeX version via initexmf --version + try { + const versionResult = await execProcess({ + cmd: "initexmf", + args: ["--version"], + stdout: "piped", + stderr: "piped", + }); + if (versionResult.code === 0 && versionResult.stdout) { + // initexmf --version outputs lines like: + // MiKTeX Configuration Utility 4.12 (MiKTeX 24.1) + // The parenthesized version is the distribution version + const distVersionMatch = versionResult.stdout.match( + /\(MiKTeX\s+(\d[\d.]*)\)/i, + ); + const versionMatch = distVersionMatch || + versionResult.stdout.match(/MiKTeX\s+(\d[\d.]*)/i); + if (versionMatch) { + result.version = versionMatch[1]; + } + } + } catch { + // Version detection is best-effort + } + + return result; + } catch { + return undefined; + } +}