| 1 |
\enableexperiments[fonts.compact] |
| 2 |
\enableexperiments[fonts.accurate] |
| 3 |
|
| 4 |
\startenvironment luametatex-style |
| 5 |
|
| 6 |
\usemodule[system-syntax] |
| 7 |
\usemodule[system-units] |
| 8 |
\usemodule[abbreviations-logos] |
| 9 |
\usemodule[scite] |
| 10 |
|
| 11 |
\definemeasure [document:margin] [\paperheight/20] |
| 12 |
|
| 13 |
\setuplayout |
| 14 |
[topspace=\measure{document:margin}, |
| 15 |
bottomspace=\measure{document:margin}, |
| 16 |
backspace=\measure{document:margin}, |
| 17 |
header=\measure{document:margin}, |
| 18 |
footer=0pt, |
| 19 |
width=middle, |
| 20 |
height=middle] |
| 21 |
|
| 22 |
\setupbodyfont |
| 23 |
[dejavu,10pt] % 12pt is just to large and we use this for all kind of demos |
| 24 |
|
| 25 |
\setupwhitespace |
| 26 |
[big] |
| 27 |
|
| 28 |
\setuplist |
| 29 |
[interaction=all] |
| 30 |
|
| 31 |
\setupalign |
| 32 |
[tolerant,stretch] |
| 33 |
|
| 34 |
\setupdocument |
| 35 |
[title=No Title, |
| 36 |
subtitle={in luametatex}, |
| 37 |
author=No Author, |
| 38 |
coauthor=, |
| 39 |
color=NoColor] |
| 40 |
|
| 41 |
\definecolor[maincolor][darkblue] |
| 42 |
\definecolor[primcolor][darkblue] |
| 43 |
\definecolor[nonecolor][darkgray] |
| 44 |
|
| 45 |
\startMPdefinitions |
| 46 |
vardef MyText (expr txt) = |
| 47 |
image ( |
| 48 |
picture p ; p := lmt_outline [ |
| 49 |
text = txt, |
| 50 |
kind = "path", |
| 51 |
anchor = "lft", |
| 52 |
] ; |
| 53 |
for i within p : |
| 54 |
draw pathpart i |
| 55 |
withpen pencircle scaled 2/5 |
| 56 |
withcolor "white" ; |
| 57 |
draw pathpart i |
| 58 |
withpen pencircle scaled 1/3 |
| 59 |
withcolor "darkgray" ; |
| 60 |
drawcontrollines pathpart i |
| 61 |
withpen pencircle scaled 1/3 |
| 62 |
withcolor "middlegray" ; |
| 63 |
drawcontrolpoints pathpart i |
| 64 |
withpen pencircle scaled 1/3 |
| 65 |
withcolor "white" ; |
| 66 |
drawpoints pathpart i |
| 67 |
withpen pencircle scaled 1/3 |
| 68 |
withcolor "darkyellow" ; |
| 69 |
endfor ; |
| 70 |
) |
| 71 |
enddef ; |
| 72 |
\stopMPdefinitions |
| 73 |
|
| 74 |
\startsetups document:contents |
| 75 |
|
| 76 |
\page |
| 77 |
|
| 78 |
\determinelistcharacteristics[chapter,section] [criterium=previous] |
| 79 |
|
| 80 |
\ifcase\listlength\else |
| 81 |
\startsubjectlevel[title=Contents] |
| 82 |
\placelist[chapter,section] [criterium=previous] |
| 83 |
\stopsubjectlevel |
| 84 |
\fi |
| 85 |
|
| 86 |
\stopsetups |
| 87 |
|
| 88 |
\startrawsetups document:start |
| 89 |
|
| 90 |
% raw keeps the lines |
| 91 |
|
| 92 |
\doifelse {\documentvariable{alternative}} {manual} { |
| 93 |
|
| 94 |
|
| 95 |
\setuppagenumbering |
| 96 |
[alternative=doublesided] |
| 97 |
|
| 98 |
\doifelse {\documentvariable{title}} {luametatex} { |
| 99 |
|
| 100 |
\startMPpage |
| 101 |
StartPage; |
| 102 |
picture p[] ; |
| 103 |
p[1] := image ( |
| 104 |
% draw MyText("LuaMeta\TEX") xsized (0.8PaperWidth) ; |
| 105 |
draw MyText("luametatex") xsized (0.8PaperWidth) ; |
| 106 |
) ; |
| 107 |
draw p[1] shifted (.1PaperWidth,.8PaperHeight) ; |
| 108 |
p[2] := image ( |
| 109 |
draw MyText("the manual") ysized 15mm ; |
| 110 |
) ; |
| 111 |
draw p[2] shifted urcorner Page shifted (-bbwidth p[2] - .1PaperWidth, - bbheight(p[1]) - bbheight(p[2]) - .2PaperHeight); |
| 112 |
p[3] := image ( |
| 113 |
draw MyText("version \luametatexverboseversion") ysized 10mm ; |
| 114 |
) ; |
| 115 |
% draw p[3] shifted lrcorner Page shifted (-bbwidth p[3] - .1PaperWidth, 15mm); |
| 116 |
draw p[3] shifted lrcorner Page shifted (-bbwidth p[3] - .1PaperWidth, 25mm); |
| 117 |
p[4] := image ( |
| 118 |
draw MyText("dev id \luametatexfunctionality") ysized 5mm ; |
| 119 |
) ; |
| 120 |
% draw p[4] shifted lrcorner Page shifted (-bbwidth p[4] - .1PaperWidth, 5mm); |
| 121 |
draw p[4] shifted lrcorner Page shifted (-bbwidth p[4] - .1PaperWidth, 15mm); |
| 122 |
addbackground withcolor "darkblue" ; |
| 123 |
StopPage; |
| 124 |
\stopMPpage |
| 125 |
|
| 126 |
\page[right] |
| 127 |
|
| 128 |
\setups[document:contents] |
| 129 |
|
| 130 |
} { |
| 131 |
|
| 132 |
\startMPpage |
| 133 |
StartPage; |
| 134 |
picture p[] ; |
| 135 |
p[3] := image ( |
| 136 |
draw MyText("\word{\documentvariable{title}}") scaled 6 ; |
| 137 |
) ; |
| 138 |
draw p[3] shifted lrcorner Page shifted (-bbwidth p[3] - .1PaperWidth, 15mm); |
| 139 |
addbackground withcolor "darkblue" ; |
| 140 |
StopPage; |
| 141 |
\stopMPpage |
| 142 |
|
| 143 |
\page[right] |
| 144 |
|
| 145 |
\normalexpanded{\startchapter[title={\documentvariable{title}}]} |
| 146 |
} |
| 147 |
|
| 148 |
} { |
| 149 |
|
| 150 |
\startMPpage |
| 151 |
fill Page |
| 152 |
withcolor "darkgray" ; |
| 153 |
% draw textext("\doifelsedocumentvariable{xtitle}{\sstf \enspace \documentvariable{xtitle}}{\word{\sstf {\white the} \documentvariable{title}}}") |
| 154 |
draw textext("\sstf\enspace\doifelsedocumentvariable{xtitle}{\documentvariable{xtitle}}{\word{\documentvariable{title}}}") |
| 155 |
xysized (.9bbwidth(Page),bbheight(Page)-2cm) |
| 156 |
xsized (.9bbwidth(Page)) |
| 157 |
shifted center Page |
| 158 |
withcolor "maincolor" ; |
| 159 |
draw textext.ulft("\word{\sstf \documentvariable{subtitle}}") |
| 160 |
xysized (.9bbwidth(Page)/3,(bbheight(Page)-2cm)/6) |
| 161 |
shifted center lrcorner Page |
| 162 |
shifted (-.1bbwidth(Page),.05bbwidth(Page)) |
| 163 |
withcolor "white" ; |
| 164 |
setbounds currentpicture to Page ; |
| 165 |
\stopMPpage |
| 166 |
|
| 167 |
\page[right] |
| 168 |
|
| 169 |
\setups[document:contents] |
| 170 |
|
| 171 |
} |
| 172 |
|
| 173 |
\setupdocument |
| 174 |
[title=No Title, |
| 175 |
subtitle={in luametatex}] |
| 176 |
|
| 177 |
\stoprawsetups |
| 178 |
|
| 179 |
\startrawsetups document:stop |
| 180 |
|
| 181 |
\doif {\documentvariable{alternative}} {manual} { |
| 182 |
|
| 183 |
\doifnot {\documentvariable{title}} {luametatex} { |
| 184 |
|
| 185 |
\stopchapter |
| 186 |
|
| 187 |
} |
| 188 |
|
| 189 |
} |
| 190 |
|
| 191 |
\stoprawsetups |
| 192 |
|
| 193 |
\definehead |
| 194 |
[newprimitive] |
| 195 |
[subsubsubsection] |
| 196 |
|
| 197 |
\definehead |
| 198 |
[oldprimitive] |
| 199 |
[subsubsubsection] |
| 200 |
|
| 201 |
\setuphead |
| 202 |
[chapter,title] |
| 203 |
[style=\bfc, |
| 204 |
color=maincolor, |
| 205 |
headerstate=high, |
| 206 |
interaction=all] |
| 207 |
|
| 208 |
\setuphead |
| 209 |
[section] |
| 210 |
[style=\bfb, |
| 211 |
color=maincolor] |
| 212 |
|
| 213 |
\setuphead |
| 214 |
[subsection] |
| 215 |
[style=\bfa, |
| 216 |
color=maincolor] |
| 217 |
|
| 218 |
\setuphead |
| 219 |
[subsubsection] |
| 220 |
[style=\bf, |
| 221 |
color=maincolor, |
| 222 |
after=] |
| 223 |
|
| 224 |
\setuphead |
| 225 |
[Syntax] |
| 226 |
[numberwidth=fit, |
| 227 |
style=\tta\bf] |
| 228 |
|
| 229 |
\pushoverloadmode |
| 230 |
|
| 231 |
\definehead |
| 232 |
[Syntax] |
| 233 |
[subsection] |
| 234 |
[style=\ttbfb, |
| 235 |
numberwidth=0pt, |
| 236 |
after=\blank\startpacked, |
| 237 |
aftersection=\stoppacked] |
| 238 |
|
| 239 |
\popoverloadmode |
| 240 |
|
| 241 |
\setupexternalfigures |
| 242 |
[location={default,global}] |
| 243 |
|
| 244 |
\setupinteraction |
| 245 |
[state=start, |
| 246 |
color=, |
| 247 |
contrastcolor=, |
| 248 |
style=, |
| 249 |
contraststyle=] |
| 250 |
|
| 251 |
% \setuptabulate |
| 252 |
% [blank={small,samepage}, |
| 253 |
% margin=.25em, |
| 254 |
% headstyle=bold, |
| 255 |
% rulecolor=maincolor, |
| 256 |
% rulethickness=1pt, |
| 257 |
% foregroundcolor=white, |
| 258 |
% foregroundstyle=\ss\bfx\WORD, |
| 259 |
% backgroundcolor=maincolor] |
| 260 |
|
| 261 |
\setuptabulate |
| 262 |
[%margin=.25em, |
| 263 |
headstyle=normal, |
| 264 |
headcolor=maincolor, |
| 265 |
rulecolor=maincolor, |
| 266 |
rulethickness=1pt] |
| 267 |
|
| 268 |
%D These are mostly |
| 269 |
|
| 270 |
\setuptyping |
| 271 |
[option=tex] |
| 272 |
|
| 273 |
\setuptype |
| 274 |
[option=tex] |
| 275 |
|
| 276 |
\setuphead |
| 277 |
[newprimitive] |
| 278 |
[color=maincolor] |
| 279 |
|
| 280 |
\def\legacycolor |
| 281 |
{\beginlocalcontrol |
| 282 |
\begingroup |
| 283 |
\let\prm\firstofoneargument |
| 284 |
\expanded |
| 285 |
{\noexpand\endgroup |
| 286 |
\noexpand\endlocalcontrol |
| 287 |
\ifempty{\legacystate{\structurevariable{title}}}% |
| 288 |
nonecolor% |
| 289 |
\else |
| 290 |
darkred% |
| 291 |
\fi}} |
| 292 |
|
| 293 |
\setuphead |
| 294 |
[oldprimitive] |
| 295 |
[%color=nonecolor, |
| 296 |
% color=\ifcstok{\structureuservariable{obsolete}}{yes}darkred\else nonecolor\fi] |
| 297 |
textcolor=, |
| 298 |
numbercolor=, |
| 299 |
color=\legacycolor] % called quite often |
| 300 |
|
| 301 |
\setuplist |
| 302 |
[newprimitive] |
| 303 |
[textcolor=maincolor] |
| 304 |
|
| 305 |
\setuplist |
| 306 |
[oldprimitive] |
| 307 |
[textcolor=nonecolor] |
| 308 |
|
| 309 |
\setuplist |
| 310 |
[chapter] |
| 311 |
[color=maincolor, |
| 312 |
style=bold, |
| 313 |
before={\testpage[3]\blank}] |
| 314 |
|
| 315 |
% We use the next one because we want to check what has been done. In a document |
| 316 |
% like this using \type {\foo} makes more sense. |
| 317 |
|
| 318 |
\protected\def\prm#1% |
| 319 |
% {\doifmode{*bodypart}{\index{\tex{#1}}}\tex{#1}} |
| 320 |
% {\ifmode{*bodypart}\index{\tex{#1!\string#1!}}\fi\tex{#1}} |
| 321 |
{%ctxlua{if string.find("#1","^U") then context.writestatus("!!!!!!","#1") end}% |
| 322 |
\ifmode{*bodypart}\index{\tex{#1}}\fi\tex{#1}} |
| 323 |
|
| 324 |
\protected\def\stx#1% |
| 325 |
{\ctxlua{moduledata.engine.specification("#1")}} % only for checking |
| 326 |
|
| 327 |
% This is why we need to tag bodymatter. |
| 328 |
|
| 329 |
% for nodes and tokens and such |
| 330 |
|
| 331 |
\definehead |
| 332 |
[enginesubject] |
| 333 |
[subsubsubject] |
| 334 |
[before=\testpage[4]\blank, |
| 335 |
after=\blank, |
| 336 |
style=bold] |
| 337 |
|
| 338 |
\startluacode |
| 339 |
-- no_usage_target = 0, |
| 340 |
-- direct_usage_target = 1, /* only available for direct nodes */ |
| 341 |
-- userdata_usage_target = 2, /* only available for userdata nodes */ |
| 342 |
-- separate_usage_target = 3, /* dedicated versions for direct and userdata nodes */ |
| 343 |
-- hybrid_usage_target = 4, /* shared version for direct and userdata nodes */ |
| 344 |
-- general_usage_target = 5, /* no direct or userdata arguments */ |
| 345 |
local getusage = node.direct.getusage |
| 346 |
local hasusage = node.direct.hasusage |
| 347 |
local nodecodes = nodes.nodecodes |
| 348 |
function moduledata.showrepertoire(name, target) |
| 349 |
local t = getusage(name, target) -- functionname -> id list |
| 350 |
if t == true then |
| 351 |
context("all nodes") |
| 352 |
elseif t and #t > 0 then |
| 353 |
for i=1,#t do |
| 354 |
t[i] = nodecodes[t[i]] |
| 355 |
end |
| 356 |
context("% t",t) |
| 357 |
else |
| 358 |
context("(yet) unknown") |
| 359 |
end |
| 360 |
end |
| 361 |
function moduledata.showusagepernode(name, target) |
| 362 |
local t = getusage(nodecodes[name], target) -- id : list per node |
| 363 |
if t and #t > 0 then |
| 364 |
table.sort(t) |
| 365 |
context("% t",t) |
| 366 |
else |
| 367 |
context("nothing (yet)") |
| 368 |
end |
| 369 |
end |
| 370 |
|
| 371 |
local report = logs.reporter("manual","todo") |
| 372 |
|
| 373 |
for name, value in table.sortedhash(node.direct, target) do |
| 374 |
if type(value) == "function" and not hasusage(name, target) then |
| 375 |
report("helper %s",name) |
| 376 |
end |
| 377 |
end |
| 378 |
|
| 379 |
local ignore = { id = true } |
| 380 |
|
| 381 |
function moduledata.showfieldsupport(name,what) |
| 382 |
local id = tonumber(name) or nodes.nodecodes[name] |
| 383 |
if id then |
| 384 |
node.setfielderror(1) |
| 385 |
local fields = node.fields(id) |
| 386 |
local n = node.new(id ) |
| 387 |
local t = { } |
| 388 |
for k, v in table.sortedhash(fields) do |
| 389 |
if not ignore[v] then |
| 390 |
node[what](n,v) |
| 391 |
if node.getfielderror() ~= 0 then |
| 392 |
t[#t+1] = v |
| 393 |
end |
| 394 |
end |
| 395 |
end |
| 396 |
node.free(n) |
| 397 |
if next(t) then |
| 398 |
report("") |
| 399 |
report("%s %s : % t",name,what,t) |
| 400 |
report("") |
| 401 |
context("% t",t) |
| 402 |
else |
| 403 |
context("-") |
| 404 |
end |
| 405 |
node.setfielderror(0) |
| 406 |
end |
| 407 |
end |
| 408 |
\stopluacode |
| 409 |
|
| 410 |
\tolerant\protected\def\showenginerepertoire[#1]#*#:#2% |
| 411 |
{\startenginesubject[title={targets}] |
| 412 |
\ctxlua{moduledata.showrepertoire("#2")} |
| 413 |
\stopenginesubject} |
| 414 |
|
| 415 |
\tolerant\protected\def\showenginesetget[#1]#*#:#2% |
| 416 |
{\startenginesubject[title={#2}] |
| 417 |
no get: \start \tttf \veryraggedright \ctxlua{moduledata.showfieldsupport("#2","getfield")} \stop \par |
| 418 |
no set: \start \tttf \veryraggedright \ctxlua{moduledata.showfieldsupport("#2","setfield")} \stop \par |
| 419 |
\stopenginesubject} |
| 420 |
|
| 421 |
\enablemode[checkfield] |
| 422 |
|
| 423 |
\tolerant\protected\def\showengineusagepernode[#1]#*#:#2% |
| 424 |
{\startenginesubject[title={direct helpers}] |
| 425 |
\start \tttf \veryraggedright |
| 426 |
\ctxlua{moduledata.showusagepernode("#2", 1)} |
| 427 |
\stop |
| 428 |
\stopenginesubject |
| 429 |
\startenginesubject[title={userdata helpers}] |
| 430 |
\start \tttf \veryraggedright |
| 431 |
\ctxlua{moduledata.showusagepernode("#2", 2)} |
| 432 |
\stop |
| 433 |
\stopenginesubject |
| 434 |
\startmode[checkfield] |
| 435 |
\startenginesubject[title={userdata helpers}] |
| 436 |
\startlines |
| 437 |
no get: \start \tttf \veryraggedright \ctxlua{moduledata.showfieldsupport("#2","getfield")} \stop \par |
| 438 |
no set: \start \tttf \veryraggedright \ctxlua{moduledata.showfieldsupport("#2","setfield")} \stop \par |
| 439 |
\stoplines |
| 440 |
\stopenginesubject |
| 441 |
\stopmode} |
| 442 |
|
| 443 |
\tolerant\protected\def\showenginevalues[#1]#*#:#2% |
| 444 |
{\startenginesubject[title={#2}] |
| 445 |
\startrows[n=\ifparameter#1\or#1\else2\fi,before=\blank,after=\blank] |
| 446 |
\ctxlua{moduledata.engine.codes("get#2", 1)} |
| 447 |
\stoprows |
| 448 |
\stopenginesubject} |
| 449 |
|
| 450 |
\tolerant\protected\def\showenginefields[#1]#*#:#2% |
| 451 |
{\startenginesubject[title=fields] |
| 452 |
\startrows[n=\ifparameter#1\or#1\else3\fi,before=\blank,after=\blank] |
| 453 |
\ctxlua{moduledata.node.codes("fields","#2",true)} |
| 454 |
\stoprows |
| 455 |
\stopenginesubject} |
| 456 |
|
| 457 |
\tolerant\protected\def\showenginesubtypes[#1]#*#:#2% |
| 458 |
{\startenginesubject[title=subtypes] |
| 459 |
\startrows[n=\ifparameter#1\or#1\else3\fi,before=\blank,after=\blank] |
| 460 |
\ctxlua{moduledata.node.codes("subtypes","#2",true)} |
| 461 |
\stoprows |
| 462 |
\stopenginesubject} |
| 463 |
|
| 464 |
\tolerant\protected\def\showengineprimitives[#1]% |
| 465 |
{%\startenginesubject[title=primitives] |
| 466 |
\startrows[n=\ifparameter#1\or#1\else2\fi,before=\blank,after=\blank] |
| 467 |
\startluacode |
| 468 |
local p = token.getprimitives() |
| 469 |
table.sort(p,function(a,b) |
| 470 |
if a[1] == b[1] then |
| 471 |
return a[2] < b[2] |
| 472 |
else |
| 473 |
return a[1] < b[1] |
| 474 |
end |
| 475 |
end) |
| 476 |
local skiplist = { [106] = true } |
| 477 |
local skipping = false |
| 478 |
context.starttabulate { "|r|r|l|" } |
| 479 |
for i=1,\letterhash p do |
| 480 |
local pi = p[i] |
| 481 |
local pc = pi[1] |
| 482 |
if skiplist[pc] then |
| 483 |
if not skipping then |
| 484 |
context.NC() context(pc) |
| 485 |
context.NC() |
| 486 |
context.NC() context.tex("Umath...") |
| 487 |
context.NC() context.NR() |
| 488 |
skipping = true |
| 489 |
end |
| 490 |
else |
| 491 |
context.NC() context(pc) |
| 492 |
context.NC() context(pi[2]) |
| 493 |
context.NC() context.tex(pi[3]) |
| 494 |
context.NC() context.NR() |
| 495 |
skipping = false |
| 496 |
end |
| 497 |
end |
| 498 |
context.stoptabulate() |
| 499 |
\stopluacode |
| 500 |
\stoprows |
| 501 |
}%\stopenginesubject} |
| 502 |
|
| 503 |
\tolerant\protected\def\showenginekeylist#1% |
| 504 |
{\startluacode |
| 505 |
local t = #1 |
| 506 |
table.sort(t) |
| 507 |
context.typ(t[1]) |
| 508 |
for i=2,\letterhash t do |
| 509 |
context(", ") |
| 510 |
context.typ(t[i]) |
| 511 |
end |
| 512 |
\stopluacode} |
| 513 |
|
| 514 |
% \setuptyping |
| 515 |
% [align=hangright, |
| 516 |
% keeptogether=yes, |
| 517 |
% keeptogether=paragraph, |
| 518 |
% numbering=] |
| 519 |
|
| 520 |
\definerows[two] [n=2,before=\blank,after=\blank] |
| 521 |
\definerows[three][n=3,before=\blank,after=\blank] |
| 522 |
\definerows[four] [n=4,before=\blank,after=\blank] |
| 523 |
|
| 524 |
\definerows[tworows] [define=yes,n=2,before=\blank,after=\blank] |
| 525 |
\definerows[threerows][define=yes,n=3,before=\blank,after=\blank] |
| 526 |
\definerows[fourrows] [define=yes,n=4,before=\blank,after=\blank] |
| 527 |
|
| 528 |
\setuplinenumbering |
| 529 |
[margin=0em, |
| 530 |
style=\ttx, |
| 531 |
width=\margindistance, |
| 532 |
distance=-\margindistance] |
| 533 |
|
| 534 |
\stopenvironment |