Skip to content

Commit cca940f

Browse files
authored
Fix logfile parsing for filenames with whitespace (#1694)
This commit adds support for unquoted filenames with whitespace appearing at the beginning of blocks. It's MikTeX, which creates such output.
1 parent 8f8a925 commit cca940f

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

LaTeXTools Log.sublime-syntax

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ first_line_match: '^This is (?:Lua(?:HB)?|pdfe?|Xe)?TeXk?, Version '
88

99
variables:
1010
drive_char: '[a-zA-Z]'
11-
file_name: '{{file_char}}+{{file_ext}}{{file_break}}'
12-
file_char: '[\w.-]' # note: assume sane path names
11+
file_name: '{{file_char}}*?{{file_ext}}{{file_break}}'
12+
file_char: '[\s\w.-]' # note: assume sane path names
1313
file_ext: '\.{{file_ext_start}}{{file_ext_char}}*'
1414
file_ext_start: '[a-zA-Z]'
1515
file_ext_char: '[a-zA-Z0-9]'
@@ -108,7 +108,7 @@ contexts:
108108

109109
block-path-begin-continuation:
110110
# possible incomplete relative path or filename, starting at eol
111-
- match: '[\w-]+\.?\n'
111+
- match: '[\s\w-]+\.?\n'
112112
set:
113113
- block-unquoted-path-meta
114114
- block-unquoted-path-expect-file
@@ -188,7 +188,7 @@ contexts:
188188

189189
block-unquoted-path-expect-file:
190190
# file name or extentions beginning with period
191-
- match: ^{{file_char}}*?{{file_ext}}{{file_break}}
191+
- match: ^{{file_name}}
192192
pop: 2
193193
# file extension without period
194194
- match: ^{{file_ext_char}}+{{file_break}}
@@ -204,12 +204,10 @@ contexts:
204204
1: punctuation.separator.path.log
205205
pop: 1
206206
# consume very long file or folder name
207-
- match: ^[\w-]{79}\n
208-
set: block-unquoted-path-expect-segment
209-
- match: ^[\w.-]{79}\n
207+
- match: ^{{file_char}}{79}\n
210208
pop: 1
211209
# file name or exteions beginning with period
212-
- match: ^{{file_char}}*?{{file_ext}}{{file_break}}
210+
- match: ^{{file_name}}
213211
pop: 1
214212
# otherwise it is not a block
215213
- match: ^
@@ -221,7 +219,7 @@ contexts:
221219
block-unquoted-ext:
222220
- meta_scope: entity.name.section.filename.log
223221
# file name or exteions beginning with period
224-
- match: ^{{file_char}}*?{{file_ext}}{{file_break}}
222+
- match: ^{{file_name}}
225223
pop: 1
226224
# file extension without period
227225
- match: ^{{file_ext_char}}+{{file_break}}
@@ -236,7 +234,7 @@ contexts:
236234
# begin of normal block body
237235
- match: ^(?![{{file_char}}\\/]+{{file_break}})
238236
pop: 1
239-
- match: (?=[ \t()])
237+
- match: (?=\s*[\[\]\{\}\(\)])
240238
pop: 1
241239
- match: '[\\/]'
242240
scope: punctuation.separator.path.log

tests/syntax/syntax_test_latex.log

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,28 @@ A-TeX_File
136136
# ^ punctuation.section.block.end.log
137137
# ^ - meta.block
138138

139+
# filename with spaces
140+
141+
(test 1691.tex)
142+
# <- meta.block.log punctuation.section.block.begin.log
143+
#^^^^^^^^^^^^^^ meta.block.log
144+
#^^^^^^^^^^^^^ entity.name.section.filename.log
145+
# ^ punctuation.section.block.end.log
146+
147+
(test 1691.
148+
tex)
149+
# <- meta.block.log entity.name.section.filename.log
150+
#^^^ meta.block.log
151+
#^^ entity.name.section.filename.log
152+
# ^ punctuation.section.block.end.log
153+
154+
(test
155+
1691.tex)
156+
# <- meta.block.log entity.name.section.filename.log
157+
#^^^^^^^^^ meta.block.log
158+
#^^^^^^^^ entity.name.section.filename.log
159+
# ^ punctuation.section.block.end.log
160+
139161
# -----------------------------------------------------------------------------
140162
# File Paths
141163
# -----------------------------------------------------------------------------
@@ -524,6 +546,24 @@ _File.tex)
524546
# ^ punctuation.section.block.end.log
525547
# ^ - meta.block
526548

549+
(F:\LaTeX\test-1691\.aux\test 1691.aux
550+
# <- meta.block.log punctuation.section.block.begin.log
551+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.log entity.name.section.filename.log
552+
# ^^ punctuation.separator.path.log
553+
# ^ punctuation.separator.path.log
554+
# ^ punctuation.separator.path.log
555+
# ^ punctuation.separator.path.log
556+
)
557+
# <- meta.block.log punctuation.section.block.end.log
558+
559+
(F:\LaTeX\test-1691\test
560+
1691
561+
.aux
562+
# <- meta.block.log entity.name.section.filename.log
563+
#^^^ meta.block.log entity.name.section.filename.log
564+
)
565+
# <- meta.block.log punctuation.section.block.end.log
566+
527567
# -----------------------------------------------------------------------------
528568
# Block boundary tests
529569
# -----------------------------------------------------------------------------

tests/test_log_parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,15 @@ def test_filepath_processing(self):
235235
folder\name\a file.tex"
236236
Package pkgname Error: An error message on input line 40.
237237
)
238+
(D:\any unquoted
239+
folder\name\a file.tex
240+
Package pkgname Error: An error message on input line 50.
241+
)
238242
)
239243
""",
240244
expected_errors=[
241245
f"D:{os.sep}any quoted folder{os.sep}name{os.sep}a file.tex:40: An error message on input line 40",
246+
f"D:{os.sep}any unquoted folder{os.sep}name{os.sep}a file.tex:50: An error message on input line 50",
242247
f"D:{os.sep}any{os.sep}folder{os.sep}name{os.sep}a-file.tex:30: An error message on input line 30",
243248
f"{os.sep}{os.sep}wsl${os.sep}localhost{os.sep}distro{os.sep}A-TeX_File.tex:20: An error message on input line 20",
244249
f"{os.sep}{os.sep}wsl.localhost{os.sep}distro{os.sep}A-TeX_File.tex:10: An error message on input line 10",

0 commit comments

Comments
 (0)