55*
66*/
77
8- import { findMissingFontsAndPackages } from "../../../src/command/render/latexmk/parse-error.ts"
8+ import { findMissingFontsAndPackages , findMissingHyphenationFiles } from "../../../src/command/render/latexmk/parse-error.ts"
99import { unitTest } from "../../test.ts" ;
1010import { assert } from "testing/asserts" ;
1111
@@ -42,6 +42,9 @@ unitTest("Detect missing files with `findMissingFontsAndPackages`", async () =>
4242 (babel) If it’s the main language, try adding \`provide=*'
4343 (babel) to the babel package options.` , "ngerman.ldf" )
4444 assertFound ( "! Package babel Error: Unknown option 'english'." , "english.ldf" ) ;
45+ assertFound ( `! Package babel Error: Unknown option 'ngerman'.
46+ (babel) Suggested actions:
47+ (babel) * Make sure you haven't misspelled it` , "ngerman.ldf" ) ;
4548 assertFound ( "!pdfTeX error: pdflatex (file 8r.enc): cannot open encoding file for reading" , "8r.enc" ) ;
4649 assertFound ( "! CTeX fontset `fandol' is unavailable in current mode" , "fandol" ) ;
4750 assertFound ( 'Package widetext error: Install the flushend package which is a part of sttools' , "flushend.sty" ) ;
@@ -51,4 +54,61 @@ unitTest("Detect missing files with `findMissingFontsAndPackages`", async () =>
5154 assertFound ( "luaotfload-features.lua:835: module 'lua-uni-normalize' not found:" , "lua-uni-algos.lua" ) ;
5255} , {
5356 cwd : ( ) => "unit/latexmk/"
57+ } )
58+
59+ unitTest ( "Detect missing hyphenation with babel warnings" , async ( ) => {
60+ // Test backtick-quote format (old format)
61+ const logWithBacktick = `Package babel Warning: No hyphenation patterns were preloaded for
62+ (babel) the language \`Spanish' into the format.
63+ (babel) Please, configure your TeX system to add them and
64+ (babel) rebuild the format. Now I will use the patterns
65+ (babel) preloaded for \\language=0 instead on input line 51.` ;
66+ assert (
67+ findMissingHyphenationFiles ( logWithBacktick ) === "hyphen-spanish" ,
68+ "Should detect hyphen-spanish from backtick-quote format"
69+ ) ;
70+
71+ // Test straight-quote format (new format - the bug we're fixing)
72+ const logWithStraightQuotes = `Package babel Warning: No hyphenation patterns were preloaded for
73+ (babel) the language 'Spanish' into the format.
74+ (babel) Please, configure your TeX system to add them and
75+ (babel) rebuild the format. Now I will use the patterns
76+ (babel) preloaded for \\language=0 instead on input line 51.` ;
77+ assert (
78+ findMissingHyphenationFiles ( logWithStraightQuotes ) === "hyphen-spanish" ,
79+ "Should detect hyphen-spanish from straight-quote format"
80+ ) ;
81+
82+ // Test ngerman special case (should return hyphen-german, not hyphen-ngerman)
83+ const logGerman = `Package babel Warning: No hyphenation patterns were preloaded for
84+ (babel) the language 'ngerman' into the format.` ;
85+ assert (
86+ findMissingHyphenationFiles ( logGerman ) === "hyphen-german" ,
87+ "Should map ngerman to hyphen-german"
88+ ) ;
89+
90+ // Test Chinese - no hyphen package exists
91+ const logChinese = `Package babel Warning: No hyphenation patterns were preloaded for
92+ (babel) the language 'chinese' into the format.` ;
93+ assert (
94+ findMissingHyphenationFiles ( logChinese ) === undefined ,
95+ "Should return undefined for Chinese (no hyphen package)"
96+ ) ;
97+
98+ // Test alternative Info pattern (issue #10291)
99+ const logInfoChinese = `Package babel Info: Hyphen rules for 'chinese-hans' set to \\l@nil
100+ (babel) (\\language10). Reported on input line 143.` ;
101+ assert (
102+ findMissingHyphenationFiles ( logInfoChinese ) === undefined ,
103+ "Should return undefined for chinese-hans via Info pattern"
104+ ) ;
105+
106+ // Test no warning present
107+ const logNoWarning = "Some other log text without babel warnings" ;
108+ assert (
109+ findMissingHyphenationFiles ( logNoWarning ) === undefined ,
110+ "Should return undefined when no babel warning present"
111+ ) ;
112+ } , {
113+ cwd : ( ) => "unit/latexmk/"
54114} )
0 commit comments