Skip to content

Commit 34c2625

Browse files
committed
Fix babel error issue
when lang: en is passed, babel-english needs to be installed. This follows up fix on tinytex R package too about new error handling cause is new pandoc way to setup babel, and maybe new babel error in log
1 parent 7061456 commit 34c2625

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/command/render/latexmk/parse-error.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ const packageMatchers = [
271271
{ regex: /.*! LaTeX Error: File `([^']+)' not found.*/g },
272272
{ regex: /.* file ['`]?([^' ]+)'? not found.*/g },
273273
{ regex: /.*the language definition file ([^\s]*).*/g },
274+
{
275+
regex: /.*! Package babel Error: Unknown option [`']([^'`]+)'[.].*/g,
276+
filter: (match: string, _text: string) => {
277+
return `${match}.ldf`;
278+
},
279+
},
274280
{ regex: /.* \\(file ([^)]+)\\): cannot open .*/g },
275281
{ regex: /.*file `([^']+)' .*is missing.*/g },
276282
{ regex: /.*! CTeX fontset `([^']+)' is unavailable.*/g },
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: "Babel English Auto-Install (#13633)"
3+
format: pdf
4+
lang: en
5+
_quarto:
6+
tests:
7+
pdf: null
8+
---
9+
10+
```{r}
11+
#| include: false
12+
13+
# Remove babel-english package to test auto-installation
14+
if (tinytex::check_installed("babel-english")) {
15+
message("Removing 'babel-english' package for the render")
16+
tinytex::tlmgr_remove("babel-english")
17+
}
18+
```
19+
20+
This document tests that Quarto correctly detects and auto-installs babel-english when rendering with `lang: en`.

tests/unit/latexmk/parse-error.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ unitTest("Detect missing files with `findMissingFontsAndPackages`", async () =>
4141
(babel) There is a locale ini file for this language.
4242
(babel) If it’s the main language, try adding \`provide=*'
4343
(babel) to the babel package options.`, "ngerman.ldf")
44+
assertFound("! Package babel Error: Unknown option 'english'.", "english.ldf");
4445
assertFound("!pdfTeX error: pdflatex (file 8r.enc): cannot open encoding file for reading", "8r.enc");
4546
assertFound("! CTeX fontset `fandol' is unavailable in current mode", "fandol");
4647
assertFound('Package widetext error: Install the flushend package which is a part of sttools', "flushend.sty");

0 commit comments

Comments
 (0)