File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -332,7 +332,7 @@ function utilities.error (message, isbug)
332332 utilities .warn (message , isbug )
333333 _skip_traceback_levels = 2
334334 io.stderr :flush ()
335- SILE .outputter :finish () -- Only really useful from the REPL but no harm in trying
335+ SILE .outputter :abort ()
336336 SILE .scratch .caughterror = true
337337 error (" " , 2 )
338338end
Original file line number Diff line number Diff line change 2929
3030function outputter .newPage () end
3131
32+ function outputter :abort ()
33+ return self :finish () -- unless otherwise defined
34+ end
35+
3236function outputter :finish ()
3337 self :runHooks (" prefinish" )
3438end
Original file line number Diff line number Diff line change @@ -46,6 +46,14 @@ function outputter:newPage ()
4646 self :_writeline (" New page" )
4747end
4848
49+ function outputter :abort ()
50+ if started then
51+ self :_writeline (" Aborted" )
52+ outfile :close ()
53+ started = false
54+ end
55+ end
56+
4957function outputter :finish ()
5058 if SILE .status .unsupported then
5159 self :_writeline (" UNSUPPORTED" )
@@ -54,6 +62,7 @@ function outputter:finish ()
5462 self :runHooks (" prefinish" )
5563 self :_writeline (" Finish" )
5664 outfile :close ()
65+ started = false
5766end
5867
5968function outputter .getCursor (_ )
Original file line number Diff line number Diff line change 6767-- pdf structure package needs a tie in here
6868function outputter ._endHook (_ ) end
6969
70+ function outputter .abort ()
71+ if started then
72+ pdf .endpage ()
73+ pdf .finish ()
74+ started = false
75+ lastkey = false
76+ end
77+ end
78+
7079function outputter :finish ()
80+ -- allows generation of empty PDFs
7181 self :_ensureInit ()
7282 pdf .endpage ()
7383 self :runHooks (" prefinish" )
7484 pdf .finish ()
7585 started = false
76- lastkey = nil
86+ lastkey = false
7787end
7888
7989function outputter .getCursor (_ )
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ outputter.extension = "txt"
1515-- function outputter:_init () end
1616
1717function outputter :_ensureInit ()
18- if not outfile then
18+ if not started then
19+ started = true
1920 local fname = self :getOutputFilename ()
2021 outfile = fname == " -" and io.stdout or io.open (fname , " w+" )
2122 end
@@ -34,10 +35,17 @@ function outputter:newPage ()
3435 outfile :write (" " )
3536end
3637
38+ function outputter .abort ()
39+ if started then
40+ outfile :close ()
41+ started = false
42+ end
43+ end
3744function outputter :finish ()
3845 self :_ensureInit ()
3946 self :runHooks (" prefinish" )
4047 outfile :close ()
48+ started = false
4149end
4250
4351function outputter .getCursor (_ )
@@ -79,7 +87,6 @@ function outputter:drawHbox (value, width)
7987 end
8088 self :_writeline (value .text )
8189 if width > 0 then
82- started = true
8390 cursorX = cursorX + width
8491 end
8592end
You can’t perform that action at this time.
0 commit comments