mtx-context-common.tex / last modification: 2020-01-30 14:16
%D \module
%D   [       file=mtx-context-common,
%D        version=2009.03.21,
%D          title=\CONTEXT\ Extra Trickry,
%D       subtitle=Common Stuff,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\startluacode
    local combination = document.arguments['combination'] or '2*2'
    local nx, ny = string.match(combination,"^(%d+)%s*[%*x]%s*(%d+)$")
    if not nx then
        nx, ny = 2, 2
    elseif not ny then
        nx = tonumber(combination) or 2
        ny = nx
    else
        nx = tonumber(nx) or 2
        ny = tonumber(ny) or nx or 2
    end
    document.setargument("combination_nx",nx)
    document.setargument("combination_ny",ny)
\stopluacode

\startluacode
    local paperformat = document.arguments['paperformat'] or 'A4*A4'
 -- paperformat = string.upper(paperformat) -- no, as we don't want to uppercase 'landscape'
    local f, t = string.match(paperformat,"^(.-)%s*[%*xX]%s*(.-)$")
    if not f then
        f, t = "A4", "A4"
    elseif not t then
        t = f
    end
    document.setargument("paperformat_paper",f)
    document.setargument("paperformat_print",t)
\stopluacode

\endinput