Omikhleia / resilient.sile

Advanced book classes and packages for the SILE typesetting system
MIT License
21 stars 4 forks source link

Handle documents on STDIN and/or via Lua 5.1 #69

Open alerque opened 8 months ago

alerque commented 8 months ago

I noticed while checking my suggestions in this comment that resilient is tripping up on documents coming from STDIN, e.g.:

$ sile -o test.pdf - <<< "\\document[class=resilient.book]{test}"
SILE v0.14.13 (LuaJIT 2.1.1696562864)
<STDIN> as sil

! Unexpected Lua error

error summary:
        Processing at: STDIN: in <snippet>:
                [[\document[class=resilient.book]{test}␤]]
        Using code at: ...es/share/lua/5.1/sile/packages/resilient/styles/init.lua:91: attempt to concatenate field 'masterFilename' (a nil value)

Run with --traceback for more detailed trace leading up to errors.

This should fix that by doing the same thing SILE is internally, but I haven't actually tested it.

alerque commented 8 months ago

I dropped the path normalization function which isn't necessary here and also changed the PR title because my reference to a SILE version seems to have thrown off the discussion. This is not a problem that started with SILE v0.14.11, it only fixes a bug in this library by making use of the more consistent SILE.input array provided in more recent SILE versions, a fix that would not have been quite so easier in earlier releases.

Omikhleia commented 8 months ago

Possibly affected modules (using masterFilename)

Omikhleia commented 8 months ago

The concern with embedders, printoptions, labelrefs and the ToC is a bit different from that of resilient styles

Omikhleia commented 8 months ago

Hmm. In the above sense, styles are perhaps incompatible with content from STDIN. Perhaps this workflow should just be rejected...

alerque commented 8 months ago

These classes seem to work fine when the style or other possible external files are not found. I would still make this change and just let it not find the appropriate file and skip it rather than crashing on not being able to guess a filename.