@@ -36,11 +36,18 @@ function _compile(s::LaTeXString, cmd::Cmd, ext::String;
3636 open= true ,
3737 kw...
3838 )
39+ name = abspath (name)
3940 mktempdir () do source_dir
4041 cd (source_dir) do
4142 _writetex (s; name= " main" , kw... )
4243 debug || (cmd = pipeline (cmd, devnull ))
43- run (cmd)
44+ try
45+ run (cmd)
46+ catch err
47+ isa (err, ProcessFailedException) || rethrow (err)
48+ mv (" $source_dir /main.log" , " $name .log" ; force= true )
49+ rethrow (LatexifyRenderError (" $name .log" ))
50+ end
4451 end
4552 mv (" $source_dir /main.$ext " , " $name .$ext " ; force= true )
4653 end
226233
227234_packagename (x:: AbstractString ) = " {$x }"
228235_packagename (x:: Tuple ) = " [$(join (x[2 : end ], " , " )) ]{$(first (x)) }"
236+
237+ struct LatexifyRenderError <: Exception
238+ logfilename:: String
239+ end
240+ function Base. showerror (io:: IO , e:: LatexifyRenderError )
241+ isfile (e. logfilename) || return println (io, " an error occured while rendering LaTeX, no log file available." )
242+ println (io, " an error occured while rendering LaTeX: " )
243+ secondline = false
244+ for l = eachline (e. logfilename)
245+ if secondline
246+ println (io, " \t " , l)
247+ break ;
248+ end
249+ m = match (r" ^! (.*)$" , l)
250+ isnothing (m) && continue
251+ println (io, " \t " , m[1 ])
252+ secondline = true
253+ end
254+ println (io, " Check the log file at " , e. logfilename, " for more information" )
255+ end
0 commit comments