Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LaTeXTools Build Output.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ contexts:
scope: meta.summary.failure.build.latextools message.error.build.latextools
- match: ^\[Build cancelled by user!\]$\n?
scope: meta.summary.failure.build.latextools message.warning.build.latextools
- match: ^\[(?:Build skipped!|Finished in .+)\]$\n?
- match: ^\[(?:Build skipped!|Finished\b.+)\]$\n?
scope: meta.summary.success.build.latextools message.info.build.latextools
4 changes: 2 additions & 2 deletions latextools/make_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def worker(self, activity_indicator):
else:
log_file = os.path.join(self.caller.builder.tex_dir, log_filename)

errors, warnings, badboxes = parse_log_file(log_file)
errors, warnings, badboxes, num_pages = parse_log_file(log_file)

except FileNotFoundError:
# If no log file was created, and all processes finished with exit code 0,
Expand Down Expand Up @@ -292,7 +292,7 @@ def worker(self, activity_indicator):
elapsed = time.strftime("%M:%S", time.gmtime(elapsed))
else:
elapsed = f"{elapsed:0.1f}s"
self.caller.output(f"\n\n[Finished in {elapsed}]")
self.caller.output(f"\n\n[Finished, {num_pages} pages written in {elapsed}]")

self.caller.errors = errors
self.caller.warnings = warnings
Expand Down
2 changes: 1 addition & 1 deletion latextools/preview/preview_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _create_image(
err_log.append("No log file found.")
else:
try:
errors, warnings, _ = parse_log_file(log_file)
errors, warnings, *_ = parse_log_file(log_file)
except Exception as e:
err_log.append(f"Error while parsing log file: {e}")
errors = warnings = []
Expand Down
12 changes: 10 additions & 2 deletions latextools/utils/tex_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class WarningLogRule(ErrorLogRule):
selector = "meta.warning.log - markup.warning"


def parse_log_view(view: sublime.View) -> tuple[list[str], list[str], list[str]]:
def parse_log_view(view: sublime.View) -> tuple[list[str], list[str], list[str], int]:
"""
Extract errors, warnings and badbox messages from a `sublime.View`.

Expand Down Expand Up @@ -175,15 +175,23 @@ def format_items(items):
for fname, line, msg in sorted(items)
]

pattern = r"Output written on [^\(]+\(([\d\n]+) pages?\b"
region = view.find(pattern, 0)
if region and (match := re.match(pattern, view.substr(region).replace("\n", ""))):
pages = int(match.group(1))
else:
pages = 0

# gather log items
return (
format_items(chain(*map(extract_items, (ExceptionLogRule, ErrorLogRule)))),
format_items(extract_items(WarningLogRule)),
format_items(extract_items(BadboxLogRule)),
pages,
)


def parse_log_file(logfile: str | os.PathLike[str]) -> tuple[list[str], list[str], list[str]]:
def parse_log_file(logfile: str | os.PathLike[str]) -> tuple[list[str], list[str], list[str], int]:
"""
Extract errors, warnings and badbox messages from tex build log.

Expand Down
8 changes: 4 additions & 4 deletions tests/syntax/syntax_test_build.log
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ C:\Data\LaTeX\test-1400\.aux\test-index.log:1: Double-click here to open the ful
# <- meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
#^^^^^^^^^^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile

[Finished in 3.4s]
[Finished, 3 pages written in 3.4s]
# <- meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
#^^^^^^^^^^^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile

[Finished in 14:25]
[Finished, 152 pages written in 14:25]
# <- meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
#^^^^^^^^^^^^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.summary.success.build.latextools message.info.build.latextools - meta.messages - meta.logfile