diff options
Diffstat (limited to 'tex/context/base/s-phy-01.mkiv')
-rw-r--r-- | tex/context/base/s-phy-01.mkiv | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/tex/context/base/s-phy-01.mkiv b/tex/context/base/s-phy-01.mkiv new file mode 100644 index 000000000..789aeb187 --- /dev/null +++ b/tex/context/base/s-phy-01.mkiv @@ -0,0 +1,101 @@ +%D \module +%D [ file=s-phy-01, +%D version=2011-11-24, +%D title=\CONTEXT\ Modules, +%D subtitle=Units Tables, +%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. + +\unprotect + +% todo: better breaks of head line + +\startluacode +moduledata.units = moduledata.units or { } + +local tables = physics.units.tables + +local HL = context.HL +local NC = context.NC +local NR = context.NR + +local function typeset(category,name,list,followup) + if followup then + context.TB() + end + HL() + NC() + context.rlap(category .. ":" .. name) + NC() + NC() + NR() + HL() + for k, v in table.sortedhash(list) do + NC() + context(k) + NC() + if isunit then + context(v) + else + context.type(v) + end + NC() + NR() + end + HL() +end + +function moduledata.units.show_table(name) + context.starttabulate { "|lT|l|" } + if name and name ~= "" then + local first, second = string.match("(.-):(.-)") + if first then + local t = tables[first] + if t then + t = t[second] + end + if t then + typeset(first,second,t,false) + end + else + local t = tables.entries[name] + if t then + typeset("entries",name,t,false) + end + end + else + local done = false + for what, list in table.sortedhash(tables.units) do + typeset("units",what,list,done) + done = true + end + for what, list in table.sortedhash(tables.shortcuts) do + typeset("shortcuts",what,list,done) + done = true + end + end + context.stoptabulate() +end + +\stopluacode + +\unexpanded\def\ShowUnitsTable + {\dosingleempty\Show_Units_Table} + +\def\Show_Units_Table[#1]% + {\ctxlua{moduledata.units.show_table("#1")}} + +\protect + +\continueifinputfile{s-phy-01.mkiv} + +\usemodule[art-01] + +\starttext + \ShowUnitsTable +\stoptext |