Josef-Friedrich / LuaTeX_Lua-API

Type definitions / Stubs for the Lua API / interface of LuaTeX and related Lua modules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mplib

pgundlach opened this issue Β· comments

I use mplib.new( {...} ) to create new mplib instance.

a) VSCode tells me that there are a few items missing in the argument list. I don't know the mandatory arguments, but in my tests only file finder is needed. (Perhaps this is not needed if no third party code is loaded). How to make the arguments optional?

b) there are a few extra undocumented fields: run_script (takes a lua function with one argument), make_text (a Lua function with two arguments?) and extensions which I need to set to 1 if I want to use run_script or make_text.

This is my mplib.new:

    local mp = mplib.new {
            mem_name = 'plain',
            find_file = finder,
            ini_version=true,
            math_mode = "double",
            random_seed = math.random(100),
            run_script = scriptrunner,
            make_text = maketext,
            extensions = 1,
        }

wich works fine.

I guess the code to be added to mplib.lua is something like this but I am not sure.

---😱 [Types](https://github.com/Josef-Friedrich/LuaTeX_Lua-API/blob/main/library/luatex/mplib.lua) incomplete or incorrect? πŸ™ [Please contribute!](https://github.com/Josef-Friedrich/LuaTeX_Lua-API/pulls)
---@alias MpRunScriptFunc fun(name: string): string

---😱 [Types](https://github.com/Josef-Friedrich/LuaTeX_Lua-API/blob/main/library/luatex/mplib.lua) incomplete or incorrect? πŸ™ [Please contribute!](https://github.com/Josef-Friedrich/LuaTeX_Lua-API/pulls)
---@alias MpMakeTextFunc fun(name: string, what: integer): string

---😱 [Types](https://github.com/Josef-Friedrich/LuaTeX_Lua-API/blob/main/library/luatex/mplib.lua) incomplete or incorrect? πŸ™ [Please contribute!](https://github.com/Josef-Friedrich/LuaTeX_Lua-API/pulls)
---@class MpArguments
---@field? error_line integer # error line width, default 79
---@field? print_line integer # line length in ps output  100
---@field? random_seed integer # the initial random seed   variable
---@field? math_mode `scaled`|`double`|`binary`|`decimal` # the number system to use, default `scaled`
---@field? interaction `batch`|`nonstop`|`scroll`|`errorstop` # the interaction mode, default `errorstop`
---@field? job_name string # `--jobname`, default `mpout`
---@field? find_file MpFindFileFunc # a function to find files only local files
---@field? extensions integer
---@field? run_script MpRunScriptFunc
---@field? make_text MpMakeTextFunc

Thank you, works fine. I didn't know about the other undocumented fields. Thank you for that as well.