import glob, os, pipes, re, string, sys
-from lyxpreview_tools import copyfileobj, error, filter_pages, find_exe, \
- find_exe_or_terminate, join_metrics_and_rename, latex_commands, \
+from lyxpreview_tools import check_latex_log, copyfileobj, error, filter_pages,\
+ find_exe, find_exe_or_terminate, join_metrics_and_rename, latex_commands, \
latex_file_re, make_texcolor, mkstemp, pdflatex_commands, progress, \
run_command, run_latex, warning, write_metrics_info
filter_pages(latex_file, pdf_latex_file, failed_pages)
# pdflatex call
+ error_pages = []
pdflatex_status, pdflatex_stdout = run_latex(pdflatex, pdf_latex_file)
+ if pdflatex_status:
+ error_pages = check_latex_log(latex_file_re.sub(".log", pdf_latex_file))
pdf_file = latex_file_re.sub(".pdf", pdf_latex_file)
latex_file_root = latex_file_re.sub("", pdf_latex_file)
pdf_log_file = latex_file_re.sub(".log", pdf_latex_file)
pdf_metrics = legacy_extract_metrics_info(pdf_log_file)
+ # Invalidate metrics for pages that produced errors
+ if len(error_pages) > 0:
+ for index in error_pages:
+ pdf_metrics.pop(index - 1)
+ pdf_metrics.insert(index - 1, (index, -1.0))
+
original_bitmap = latex_file_re.sub("%d." + output_format, pdf_latex_file)
destination_bitmap = latex_file_re.sub("%d." + output_format, latex_file)
log_file = latex_file_re.sub(".log", latex_file)
resolution = extract_resolution(log_file, dpi)
+ # Check whether some pages produced errors
+ error_pages = check_latex_log(log_file)
+
# Older versions of gs have problems with a large degree of
# anti-aliasing at high resolutions
alpha = 4
use_pdftocairo, conv, gs_device, gs_ext, alpha, resolution,
output_format)
+ # Invalidate metrics for pages that produced errors
+ if len(error_pages) > 0:
+ for index in error_pages:
+ if index not in failed_pages:
+ legacy_metrics.pop(index - 1)
+ legacy_metrics.insert(index - 1, (index, -1.0))
+
# Crop the ppm images
if pnmcrop != None and output_format == "ppm":
crop_files(pnmcrop, latex_file_root)