1%D \module 2%D [ file=blob-ini, 3%D version=2010.04.06, 4%D title=\CONTEXT\ \LUA\ Typesetting, 5%D subtitle=Initialization, 6%D author=Hans Hagen, 7%D date=\currentdate, 8%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] 9%C 10%C This module is part of the \CONTEXT\ macro||package and is 11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for 12%C details. 13 14\writestatus{loading}{ConTeXt Lua Typesetting / Initialization} 15 16%D This is a prelude to typesetting at the \LUA\ end. The code 17%D is already quite old but will only get nice when we are further 18%D down the road (close to version 1.00 of \LUATEX). Typesetting in 19%D pure \LUA\ sometimes makes sense. 20 21\registerctxluafile{node-typ}{autosuffix} % experimental 22\registerctxluafile{blob-ini}{autosuffix} 23 24\unprotect 25 26% \widthofstring % defined in lua 27% \heightofstring % defined in lua 28% \depthofstring % defined in lua 29% \heightanddepthofstring % defined in lua 30 31\permanent\def\wdofstring#1{\dimexpr\widthofstring {#1}\relax} % assured an dimen 32\permanent\def\htofstring#1{\dimexpr\heightofstring{#1}\relax} % assured an dimen 33\permanent\def\dpofstring#1{\dimexpr\depthofstring {#1}\relax} % assured an dimen 34\permanent\def\hdofstring#1{\dimexpr\totalofstring {#1}\relax} % assured an dimen 35 36\aliased\let\heightanddepthofstring\totalofstring 37\aliased\let\htdpofstring \hdofstring 38 39% \let\hd\htdp % if yes then move this 40 41% This one takes anything that can be typeset 42 43\permanent\protected\def\setwidthof#1\to#2{\edef#2{\widthofstring{#1}}} 44 45\protect \endinput 46 47% \starttext 48% 49% \startluacode 50% local b = blobs.new() 51% blobs.append(b,"Hello world.\n Here we are.\n\n And Again!") 52% blobs.pack(b) 53% blobs.write(b) 54% \stopluacode 55% 56% \stoptext 57 |