Merge pull request #4937 from overleaf/bg-accept-spaces-in-log-filenames

handle filenames with spaces in latex error log

GitOrigin-RevId: 7ab548eed3c84e7760715512770c0b7782494200
This commit is contained in:
Brian Gough 2021-09-23 09:18:04 +01:00 committed by Copybot
parent fa514d782d
commit f8d65a2004
5 changed files with 516 additions and 9 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "@overleaf/latex-log-parser", "name": "@overleaf/latex-log-parser",
"version": "2.0.0", "version": "2.1.0",
"description": "", "description": "",
"scripts": { "scripts": {
"lint": "eslint --max-warnings 0 --format unix src || /bin/true", "lint": "eslint --max-warnings 0 --format unix src || /bin/true",

View file

@ -307,13 +307,35 @@ define(function () {
this.consumeFilePath = function () { this.consumeFilePath = function () {
// Our heuristic for detecting file names are rather crude // Our heuristic for detecting file names are rather crude
// A file may not contain a space, or ) in it // A file may not contain a ')' in it
// To be a file path it must have at least one / // To be a file path it must have at least one /
if (!this.currentLine.match(/^\/?([^ \)]+\/)+/)) { if (!this.currentLine.match(/^\/?([^ )]+\/)+/)) {
return false return false
} }
const endOfFilePath = this.currentLine.search(RegExp(' |\\)'))
let path = undefined let endOfFilePath = this.currentLine.search(/ |\)/)
// handle the case where there is a space in a filename
while (endOfFilePath !== -1 && this.currentLine[endOfFilePath] === ' ') {
const partialPath = this.currentLine.slice(0, endOfFilePath)
// consider the file matching done if the space is preceded by a file extension (e.g. ".tex")
if (/\.\w+$/.test(partialPath)) {
break
}
// advance to next space or ) or end of line
const remainingPath = this.currentLine.slice(endOfFilePath + 1)
// consider file matching done if current path is followed by any of "()[]
if (/^\s*["()[\]]/.test(remainingPath)) {
break
}
const nextEndOfPath = remainingPath.search(/[ "()[\]]/)
if (nextEndOfPath === -1) {
endOfFilePath = -1
} else {
endOfFilePath += nextEndOfPath + 1
}
}
let path
if (endOfFilePath === -1) { if (endOfFilePath === -1) {
path = this.currentLine path = this.currentLine
this.currentLine = '' this.currentLine = ''

View file

@ -0,0 +1,391 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex 2020.9.10) 1 SEP 2021 10:52
entering extended mode
\write18 enabled.
%&-line parsing enabled.
**main.tex
(/compile/main.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-07-17> (/usr/local/texlive/2020/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
)
\c@part=\count168
\c@section=\count169
\c@subsection=\count170
\c@subsubsection=\count171
\c@paragraph=\count172
\c@subparagraph=\count173
\c@figure=\count174
\c@table=\count175
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen134
) (/usr/local/texlive/2020/texmf-dist/tex/generic/babel/babel.sty
Package: babel 2020/07/13 3.47 The Babel package
(/usr/local/texlive/2020/texmf-dist/tex/generic/babel/babel.def
File: babel.def 2020/07/13 3.47 Babel common definitions
\babel@savecnt=\count176
\U@D=\dimen135
\l@babelnohyphens=\language86
(/usr/local/texlive/2020/texmf-dist/tex/generic/babel/txtbabel.def)
\bbl@readstream=\read2
)
\bbl@dirlevel=\count177
(/usr/local/texlive/2020/texmf-dist/tex/generic/babel-english/english.ldf
Language: english 2017/06/06 v3.3r English support from the babel system
Package babel Info: \l@canadian = using hyphenrules for english
(babel) (\language0) on input line 102.
Package babel Info: \l@australian = using hyphenrules for ukenglish
(babel) (\language21) on input line 105.
Package babel Info: \l@newzealand = using hyphenrules for ukenglish
(babel) (\language21) on input line 108.
)) (/usr/local/texlive/2020/texmf-dist/tex/latex/geometry/geometry.sty
Package: geometry 2020/01/02 v5.9 Page Geometry
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks15
) (/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/ifvtex.sty
Package: ifvtex 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
(/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2020/03/06 v1.0d TeX engine tests
))
\Gm@cnth=\count178
\Gm@cntv=\count179
\c@Gm@tempcnt=\count180
\Gm@bindingoffset=\dimen136
\Gm@wd@mp=\dimen137
\Gm@odd@mp=\dimen138
\Gm@even@mp=\dimen139
\Gm@layoutwidth=\dimen140
\Gm@layoutheight=\dimen141
\Gm@layouthoffset=\dimen142
\Gm@layoutvoffset=\dimen143
\Gm@dimlist=\toks16
) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2020/01/20 v2.17e AMS math features
\@mathmargin=\skip49
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks17
\ex@=\dimen144
)) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen145
) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 2016/03/08 v2.02 operator names
)
\inf@bad=\count181
LaTeX Info: Redefining \frac on input line 227.
\uproot@=\count182
\leftroot@=\count183
LaTeX Info: Redefining \overline on input line 389.
\classnum@=\count184
\DOTSCASE@=\count185
LaTeX Info: Redefining \ldots on input line 486.
LaTeX Info: Redefining \dots on input line 489.
LaTeX Info: Redefining \cdots on input line 610.
\Mathstrutbox@=\box45
\strutbox@=\box46
\big@size=\dimen146
LaTeX Font Info: Redeclaring font encoding OML on input line 733.
LaTeX Font Info: Redeclaring font encoding OMS on input line 734.
\macc@depth=\count186
\c@MaxMatrixCols=\count187
\dotsspace@=\muskip16
\c@parentequation=\count188
\dspbrk@lvl=\count189
\tag@help=\toks18
\row@=\count190
\column@=\count191
\maxfields@=\count192
\andhelp@=\toks19
\eqnshift@=\dimen147
\alignsep@=\dimen148
\tagshift@=\dimen149
\tagwidth@=\dimen150
\totwidth@=\dimen151
\lineht@=\dimen152
\@envbody=\toks20
\multlinegap=\skip50
\multlinetaggap=\skip51
\mathdisplay@stack=\toks21
LaTeX Info: Redefining \[ on input line 2859.
LaTeX Info: Redefining \] on input line 2860.
) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2019/11/30 v1.2a Enhanced LaTeX Graphics (DPC,SPQR)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2019/11/30 v1.4a Standard LaTeX Graphics (DPC,SPQR)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 105.
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
))
\Gin@req@height=\dimen153
\Gin@req@width=\dimen154
) (/usr/local/texlive/2020/texmf-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2020-05-15 v7.00e Hypertext links for LaTeX
(/usr/local/texlive/2020/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty
Package: ltxcmds 2019/12/15 v1.24 LaTeX kernel commands for general use (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO)
(/usr/local/texlive/2020/texmf-dist/tex/generic/infwarerr/infwarerr.sty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
) (/usr/local/texlive/2020/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty
Package: kvsetkeys 2019/12/15 v1.18 Key value parser (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty
Package: kvdefinekeys 2019-12-19 v1.6 Define keys (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/generic/pdfescape/pdfescape.sty
Package: pdfescape 2019/12/09 v1.15 Implements pdfTeX's escape features (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/latex/hycolor/hycolor.sty
Package: hycolor 2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/latex/letltxmacro/letltxmacro.sty
Package: letltxmacro 2019/12/03 v1.6 Let assignment for LaTeX macros (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/latex/auxhook/auxhook.sty
Package: auxhook 2019-12-17 v1.6 Hooks for auxiliary files (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/latex/kvoptions/kvoptions.sty
Package: kvoptions 2019/11/29 v3.13 Key value format for package options (HO)
)
\@linkdim=\dimen155
\Hy@linkcounter=\count193
\Hy@pagecounter=\count194
(/usr/local/texlive/2020/texmf-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2020-05-15 v7.00e Hyperref: PDFDocEncoding definition (HO)
Now handling font encoding PD1 ...
... no UTF-8 mapping file for font encoding PD1
) (/usr/local/texlive/2020/texmf-dist/tex/generic/intcalc/intcalc.sty
Package: intcalc 2019/12/15 v1.3 Expandable calculations with integers (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/generic/etexcmds/etexcmds.sty
Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
)
\Hy@SavedSpaceFactor=\count195
Package hyperref Info: Option `colorlinks' set `true' on input line 4338.
Package hyperref Info: Hyper figures OFF on input line 4464.
Package hyperref Info: Link nesting OFF on input line 4469.
Package hyperref Info: Hyper index ON on input line 4472.
Package hyperref Info: Plain pages OFF on input line 4479.
Package hyperref Info: Backreferencing OFF on input line 4484.
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
Package hyperref Info: Bookmarks ON on input line 4717.
\c@Hy@tempcnt=\count196
(/usr/local/texlive/2020/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip17
Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 5076.
\XeTeXLinkMargin=\dimen156
(/usr/local/texlive/2020/texmf-dist/tex/generic/bitset/bitset.sty
Package: bitset 2019/12/09 v1.3 Handle bit-vector datatype (HO)
(/usr/local/texlive/2020/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty
Package: bigintcalc 2019/12/15 v1.5 Expandable calculations on big integers (HO)
))
\Fld@menulength=\count197
\Field@Width=\dimen157
\Fld@charsize=\dimen158
Package hyperref Info: Hyper figures OFF on input line 6347.
Package hyperref Info: Link nesting OFF on input line 6352.
Package hyperref Info: Hyper index ON on input line 6355.
Package hyperref Info: backreferencing OFF on input line 6362.
Package hyperref Info: Link coloring ON on input line 6365.
Package hyperref Info: Link coloring with OCG OFF on input line 6372.
Package hyperref Info: PDF/A mode OFF on input line 6377.
LaTeX Info: Redefining \ref on input line 6417.
LaTeX Info: Redefining \pageref on input line 6421.
(/usr/local/texlive/2020/texmf-dist/tex/generic/atbegshi/atbegshi.sty
Package: atbegshi 2019/12/05 v1.19 At begin shipout hook (HO)
)
\Hy@abspage=\count198
\c@Item=\count199
\c@Hfootnote=\count266
)
Package hyperref Info: Driver (autodetected): hpdftex.
(/usr/local/texlive/2020/texmf-dist/tex/latex/hyperref/hpdftex.def
File: hpdftex.def 2020-05-15 v7.00e Hyperref driver for pdfTeX
(/usr/local/texlive/2020/texmf-dist/tex/latex/atveryend/atveryend.sty
Package: atveryend 2019-12-11 v1.11 Hooks at the very end of document (HO)
Package atveryend Info: \enddocument detected (standard20110627).
)
\Fld@listcount=\count267
\c@bookmark@seq@number=\count268
(/usr/local/texlive/2020/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
Package: rerunfilecheck 2019/12/05 v1.9 Rerun checks for auxiliary files (HO)
(/usr/local/texlive/2020/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty
Package: uniquecounter 2019/12/15 v1.4 Provide unlimited unique counter (HO)
)
Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 286.
)
\Hy@SectionHShift=\skip52
) (/usr/local/texlive/2020/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def
File: l3backend-pdfmode.def 2020-06-29 L3 backend support: PDF mode
\l__kernel_color_stack_int=\count269
\l__pdf_internal_box=\box47
) (/compile/output.aux)
\openout1 = `output.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 19.
LaTeX Font Info: ... okay on input line 19.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 19.
LaTeX Font Info: ... okay on input line 19.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 19.
LaTeX Font Info: ... okay on input line 19.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 19.
LaTeX Font Info: ... okay on input line 19.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 19.
LaTeX Font Info: ... okay on input line 19.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 19.
LaTeX Font Info: ... okay on input line 19.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 19.
LaTeX Font Info: ... okay on input line 19.
LaTeX Font Info: Checking defaults for PD1/pdf/m/n on input line 19.
LaTeX Font Info: ... okay on input line 19.
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
*geometry* verbose mode - [ preamble ] result:
* driver: pdftex
* paper: letterpaper
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes:
* h-part:(L,W,R)=(85.35826pt, 443.57848pt, 85.35826pt)
* v-part:(T,H,B)=(56.9055pt, 681.15898pt, 56.9055pt)
* \paperwidth=614.295pt
* \paperheight=794.96999pt
* \textwidth=443.57848pt
* \textheight=681.15898pt
* \oddsidemargin=13.08827pt
* \evensidemargin=13.08827pt
* \topmargin=-52.36449pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=10.0pt
* \footskip=30.0pt
* \marginparwidth=49.79231pt
* \marginparsep=11.0pt
* \columnsep=10.0pt
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)
(/usr/local/texlive/2020/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count270
\scratchdimen=\dimen159
\scratchbox=\box48
\nofMPsegments=\count271
\nofMParguments=\count272
\everyMPshowfont=\toks22
\MPscratchCnt=\count273
\MPscratchDim=\dimen160
\MPnumerator=\count274
\makeMPintoPDFobject=\count275
\everyMPtoPDFconversion=\toks23
) (/usr/local/texlive/2020/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 485.
(/usr/local/texlive/2020/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
))
\AtBeginShipoutBox=\box49
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/color.sty
Package: color 2019/11/23 v1.2a Standard LaTeX Color (DPC)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package color Info: Driver file: pdftex.def on input line 147.
)
Package hyperref Info: Link coloring ON on input line 19.
(/usr/local/texlive/2020/texmf-dist/tex/latex/hyperref/nameref.sty
Package: nameref 2019/09/16 v2.46 Cross-referencing by name of section
(/usr/local/texlive/2020/texmf-dist/tex/latex/refcount/refcount.sty
Package: refcount 2019/12/15 v3.6 Data extraction from label references (HO)
) (/usr/local/texlive/2020/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty
Package: gettitlestring 2019/12/15 v1.6 Cleanup title references (HO)
)
\c@section@level=\count276
)
%%%% these are artificial test cases
(/compile/main [1] [2] [3]
LaTeX Warning: Citation `Peeters:2001np' on page 13 undefined on input line 9.
[]
(/compile/main.tex (/compile/otherfile
Overfull \hbox (4.56pt too wide) in paragraph at lines 123--456
[]
%%%% end of artificial test cases
LaTeX Info: Redefining \ref on input line 19.
LaTeX Info: Redefining \pageref on input line 19.
LaTeX Info: Redefining \nameref on input line 19.
(/compile/output.out) (/compile/output.out)
\@outlinefile=\write3
\openout3 = `output.out'.
(/compile/a folder with spaces/a subfolder with spaces/a subsubfolder with spaces/another file with spaces.tex
! Undefined control sequence.
l.1 \anotherbadcommand
{}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
)
<frog.jpg, id=56, 748.7975pt x 741.77126pt>
File: frog.jpg Graphic file (type jpg)
<use frog.jpg>
Package pdftex.def Info: frog.jpg used on input line 49.
(pdftex.def) Requested size: 133.07489pt x 131.8266pt.
[1
{/usr/local/texlive/2020/texmf-var/fonts/map/pdftex/updmap/pdftex.map} </compile/frog.jpg>] [2] (/compile/output.bbl)
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 122.
[3]
Package atveryend Info: Empty hook `AfterLastShipout' on input line 122.
(/compile/output.aux)
Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 122.
Package atveryend Info: Executing hook `AtEndAfterFileList' on input line 122.
Package rerunfilecheck Info: File `output.out' has not changed.
(rerunfilecheck) Checksum: 232689D72843F283B3EE1BBB7D69ECDC;910.
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 122.
)
Here is how much of TeX's memory you used:
7045 strings out of 480906
106112 string characters out of 5908280
398548 words of memory out of 5000000
22494 multiletter control sequences out of 15000+600000
541619 words of font info for 52 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
43i,8n,37p,464b,360s stack positions out of 5000i,500n,10000p,200000b,80000s
{/usr/local/texlive/2020/texmf-dist/fonts/enc/dvips/cm-super/cm-super-ts1.enc}</usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx9.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmr9.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></usr/local/texli
ve/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb></usr/local/texlive/2020/texmf-dist/fonts/type1/public/cm-super/sfrm1000.pfb>
Output written on /compile/output.pdf (3 pages, 246983 bytes).
PDF statistics:
153 PDF objects out of 1000 (max. 8388607)
131 compressed objects within 2 object streams
22 named destinations out of 1000 (max. 500000)
102 words of extra memory for PDF output out of 10000 (max. 10000000)

View file

@ -9,6 +9,7 @@ define([
'text!logs/geometry-warnings.log', 'text!logs/geometry-warnings.log',
'text!logs/caption-warnings.log', 'text!logs/caption-warnings.log',
'text!logs/runaway-arguments.log', 'text!logs/runaway-arguments.log',
'text!logs/filenames.log',
'text!logs/file-line-error.log', 'text!logs/file-line-error.log',
'text!logs/biber.blg', 'text!logs/biber.blg',
'text!logs/bibtex.blg', 'text!logs/bibtex.blg',
@ -23,6 +24,7 @@ define([
geometryWarningsLog, geometryWarningsLog,
captionWarningsLog, captionWarningsLog,
runawayArgumentsLog, runawayArgumentsLog,
filenamesLog,
fileLineErrorLog, fileLineErrorLog,
biberBlg, biberBlg,
bibtexBlg bibtexBlg
@ -350,6 +352,76 @@ define([
} }
}) })
module('Filename Errors')
test('Filename parsing', function () {
var { errors, warnings, typesetting } = LatexParser.parse(filenamesLog)
var expectedErrors = [
[
1,
'Undefined control sequence.',
'/compile/a folder with spaces/a subfolder with spaces/a subsubfolder with spaces/another file with spaces.tex',
] + '',
]
var expectedWarnings = [
[
9,
"Citation `Peeters:2001np' on page 13 undefined on input line 9.",
'/compile/main',
] + '',
]
var expectedTypesetting = [
[
123,
'Overfull \\hbox (4.56pt too wide) in paragraph at lines 123--456',
'/compile/otherfile',
] + '',
]
expect(
expectedErrors.length +
expectedWarnings.length +
expectedTypesetting.length
)
for (var i = 0; i < errors.length; i++) {
if (
expectedErrors.indexOf(
[errors[i].line, errors[i].message, errors[i].file] + ''
) > -1
) {
ok(true, 'Found error: ' + errors[i].message)
} else {
ok(false, 'Unexpected error found: ' + errors[i].message)
}
}
for (var i = 0; i < warnings.length; i++) {
if (
expectedWarnings.indexOf(
[warnings[i].line, warnings[i].message, warnings[i].file] + ''
) > -1
) {
ok(true, 'Found error: ' + warnings[i].message)
} else {
ok(false, 'Unexpected error found: ' + warnings[i].message)
}
}
for (var i = 0; i < typesetting.length; i++) {
if (
expectedTypesetting.indexOf(
[typesetting[i].line, typesetting[i].message, typesetting[i].file] +
''
) > -1
) {
ok(true, 'Found error: ' + typesetting[i].message)
} else {
ok(false, 'Unexpected error found: ' + typesetting[i].message)
}
}
})
module('File Line Errors') module('File Line Errors')
test('File line error parsing', function () { test('File line error parsing', function () {

View file

@ -307,13 +307,35 @@ define(function () {
this.consumeFilePath = function () { this.consumeFilePath = function () {
// Our heuristic for detecting file names are rather crude // Our heuristic for detecting file names are rather crude
// A file may not contain a space, or ) in it // A file may not contain a ')' in it
// To be a file path it must have at least one / // To be a file path it must have at least one /
if (!this.currentLine.match(/^\/?([^ \)]+\/)+/)) { if (!this.currentLine.match(/^\/?([^ )]+\/)+/)) {
return false return false
} }
const endOfFilePath = this.currentLine.search(RegExp(' |\\)'))
let path = undefined let endOfFilePath = this.currentLine.search(/ |\)/)
// handle the case where there is a space in a filename
while (endOfFilePath !== -1 && this.currentLine[endOfFilePath] === ' ') {
const partialPath = this.currentLine.slice(0, endOfFilePath)
// consider the file matching done if the space is preceded by a file extension (e.g. ".tex")
if (/\.\w+$/.test(partialPath)) {
break
}
// advance to next space or ) or end of line
const remainingPath = this.currentLine.slice(endOfFilePath + 1)
// consider file matching done if current path is followed by any of "()[]
if (/^\s*["()[\]]/.test(remainingPath)) {
break
}
const nextEndOfPath = remainingPath.search(/[ "()[\]]/)
if (nextEndOfPath === -1) {
endOfFilePath = -1
} else {
endOfFilePath += nextEndOfPath + 1
}
}
let path
if (endOfFilePath === -1) { if (endOfFilePath === -1) {
path = this.currentLine path = this.currentLine
this.currentLine = '' this.currentLine = ''