adityam / filter

ConTeXt module to process contents of a start-stop environment through an external program
47 stars 10 forks source link

Fix filter module runtime errors under LMTX Beta #48

Closed gucci-on-fleek closed 3 years ago

gucci-on-fleek commented 3 years ago

The vim module is broken in the most recent (2021.08.06) LMTX beta. It fails with the following message:

system          > ConTeXt  ver: 2021.08.06 01:21 LMTX  fmt: 2021.8.6  int: english/english
system          >
system          > 'cont-new.mkxl' loaded
open source     > level 1, order 1, name 'C:/context/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system          > beware: some patches loaded from cont-new.mkiv
close source    > level 1, order 1, name 'C:/context/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system          > files > jobname './test2', input './test2', result './test2'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
open source     > level 1, order 2, name './test2.tex'
modules         > 'vim' is loaded
open source     > level 2, order 3, name 'C:/context/tex/texmf-local/tex/context/third/vim/t-vim.tex'
loading         > Vim syntax highlighting (ver: 2021.05.31)
modules         > 'filter' is loaded
loading         > Filter (ver: 2020.06.29)
modules         > 'module-catcodes' is loaded
open source     > level 4, order 5, name 'C:/context/tex/texmf-local/tex/context/third/filter/t-module-catcodes.mkiv'
loading         > Module Catcodes (ver: 2018.04.16)
close source    > level 4, order 5, name 'C:/context/tex/texmf-local/tex/context/third/filter/t-module-catcodes.mkiv'
close source    > level 3, order 5, name 'C:/context/tex/texmf-local/tex/context/third/filter/t-filter.mkiv'
modules         > 'syntax-highlight' is loaded
open source     > level 3, order 6, name 'C:/context/tex/texmf-local/tex/context/third/vim/t-syntax-highlight.mkxl'
loading         > Code syntax highlighting (ver: 2021.05.31)
modules         > 'syntax-groups' is loaded
open source     > level 4, order 7, name 'C:/context/tex/texmf-local/tex/context/third/vim/t-syntax-groups.mkiv'
loading         > Syntax highlighting groups (ver: 2021.05.23)
modules         > 'module-catcodes' is already loaded
close source    > level 4, order 7, name 'C:/context/tex/texmf-local/tex/context/third/vim/t-syntax-groups.mkiv'
modules         > 'filter' is already loaded
close source    > level 3, order 7, name 'C:/context/tex/texmf-local/tex/context/third/vim/t-syntax-highlight.mkxl'
close source    > level 2, order 7, name 'C:/context/tex/texmf-local/tex/context/third/vim/t-vim.tex'
fonts           > preloading latin modern fonts (second stage)
fonts           > 'fallback modern-designsize rm 12pt' is loaded
lua error       > lua error on line 5 in file ./test2.tex:

token call, execute: C:/context/tex/texmf-context/tex/context/base/mkiv/l-io.lua:70: bad argument #1 to '?' (string expected, got nil)
stack traceback:
        [C]: in ?
        (...tail calls...)
        C:/context/tex/texmf-context/tex/context/base/mkiv/l-io.lua:70: in function 'io.loaddata'
        ...ontext/tex/texmf-context/tex/context/base/mkiv/l-md5.lua:91: in upvalue 'checksum'
        ...ext/tex/texmf-context/tex/context/base/mkiv/grph-fil.lua:97: in field 'run'
        [ctxlua]:1: in main chunk
1     \usemodule[vim]
2     \definevimtyping[TEX][syntax=tex]
3
4     \starttext
5 >>      \inlineTEX{\relax}
6     \stoptext
7
mtx-context     | fatal error: return code: 1

The recent ConTeXt Beta (LMTX 2021.08.04) changes the signature of the Lua function job.files.run. It now takes a table instead of a string and a table.

This PR duplicates t-filter.mkiv into t-filter.mkxl, then changes line 461 to use the new job.files.run signature.

gucci-on-fleek commented 3 years ago

It seems like the job.files.run(...) function will only run context and not arbitrary programs now. The original commit causes tons of errors if the highlighted text is invalid ConTeXt. I was using a test file that only contained valid TeX commands, so I didn't notice that it was running context on the highlighted text in the background.

However, just removing the code that calls this function seems to fix the error. This code probably was doing something before, so this will likely cause errors somewhere else, but I haven't noticed any problems when testing it with some fairly complex documents.

adityam commented 3 years ago

Thank you for the bug report and patch. I am on vacation and will look at it when I am back. However, I don't think that simply removing jobs.files.run is the way to go as that function is responsible for caching the content. So, if we remove that caching will not work.

adityam commented 3 years ago

The change that caused this has been reverted in context upstream (see https://github.com/contextgarden/context-mirror/commit/d3d93bc4f0d21a259fdafee5ba1a744999474c28#diff-0aac9f9e71a36725439103dfcc9110e42ff63722bca66c4deec2c9d49baedb99R93), so this will be fixed automatically at the next release.

adityam commented 3 years ago

The error is now fixed with the latest release of ConTeXt, so I am closing this issue. Thank you for reporting and tracking down the error which made it easy to fix.