diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-01 13:39:31 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-08-01 13:39:31 +0200 |
commit | c44a9d2f89620e439f335029689e7f0dff9516b7 (patch) | |
tree | 1062a464cb13362d82598c41c437ab1c7eb4f236 /doc/context/sources/general/manuals/lua | |
parent | 665f9095475ffcd1c8750546727c75e5486a266f (diff) | |
download | context-c44a9d2f89620e439f335029689e7f0dff9516b7.tar.gz |
2016-08-01 13:07:00
Diffstat (limited to 'doc/context/sources/general/manuals/lua')
-rw-r--r-- | doc/context/sources/general/manuals/lua/lua-mkiv.tex | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/doc/context/sources/general/manuals/lua/lua-mkiv.tex b/doc/context/sources/general/manuals/lua/lua-mkiv.tex new file mode 100644 index 000000000..40e885eac --- /dev/null +++ b/doc/context/sources/general/manuals/lua/lua-mkiv.tex @@ -0,0 +1,139 @@ +% language=uk + +% author : Hans Hagen +% copyright : PRAGMA ADE & ConTeXt Development Team +% license : Creative Commons Attribution ShareAlike 4.0 International +% reference : pragma-ade.nl | contextgarden.net | texlive (related) distributions +% origin : the ConTeXt distribution +% +% comment : Because this manual is distributed with TeX distributions it comes with a rather +% liberal license. We try to adapt these documents to upgrades in the (sub)systems +% that they describe. Using parts of the content otherwise can therefore conflict +% with existing functionality and we cannot be held responsible for that. Many of +% the manuals contain characteristic graphics and personal notes or examples that +% make no sense when used out-of-context. + +\usemodule[art-01,abr-02] + +\setupbodyfont + [10pt] + +\definecolor + [maincolor] + [b=.4] + +\usesymbols + [cc] + +\setuptype + [color=maincolor] + +\setuptyping + [color=maincolor] + +\definefont + [TitlePageFont] + [file:lmmonolt10-bold.otf] + +\setuphead + [color=maincolor] + +\setupinteraction + [hidden] + +\startdocument + [metadata:author=Hans Hagen, + metadata:title={Lua, the context libraries}, + author=Hans Hagen, + affiliation=PRAGMA ADE, + location=Hasselt NL, + title=Lua, + subtitle=the context libraries, + support=www.contextgarden.net, + website=www.pragma-ade.nl] + +\startMPpage + + StartPage ; + + numeric w ; w := bbwidth(Page) ; + numeric h ; h := bbheight(Page) ; + + fill Page withcolor \MPcolor{maincolor} ; + + draw textext.urt("\TitlePageFont \getvariable{document}{title}") xsized (0.8w) shifted (.1w,.2h) withcolor .80white ; + draw textext.top("\TitlePageFont \getvariable{document}{subtitle}") xsized (0.8w) shifted (.5w,.1h) withcolor .60white ; + + StopPage ; + +\stopMPpage + +\startsubject[title=Contents] + +\placelist[section][alternative=a] + +\stopsubject + +\startsection[title=Introduction] + +Once we started the \LUATEX\ project it didn't take long for \CONTEXT\ to use +the \LUA\ language extensively. And so, rather soon, a bunch of libraries +evolved that provided all kind of helpers. Because \LUATEX\ can also act as +a \LUA\ interpreter, and because we have \type {mtxrun} as script runner +we can also use some of those libraries outside \CONTEXT. So, for me, a rather +natural way to run a \LUA\ script is: + +\starttyping +mtxrun --script myscript.lua <optional arguments> +\stoptyping + +The advantage of this approach is that you operate in the same file domain as +your \TEX\ runs as all file locators are preloaded as well. However, in some +cases this is not possible, for instance when you run a stock \LUA\ or some +embedded version. For this we provide an alternative mechanism. + +\stopsection + +\startsection[title=Making libraries] + +In the \CONTEXT\ distribution there is a script called \type {mtxlibs.lua} that +can create a library for you that has the basic general purpose \CONTEXT\ +libraries on board, as well as whatever more you specify. + +\starttyping +lua mtxlibs.lua --selfmerge myproject-a-libs.lua +lua mtxlibs.lua --selfmerge myproject-b-libs.lua \ + trac-lmx +lua mtxlibs.lua --selfmerge myproject-c-libs.lua \ + util-sql util-sql-imp-client util-sql-imp-library +\stoptyping + +Here we create three libs. The first one has only the core libraries. You can +read more about what they provide in the \type {cld-mkiv.pdf} manual. The second +library includes code for creating web pages. The third variant preloads \SQL\ +support. + +You can best run this file in its own directory, in the \CONTEXT\ tree, so that +it knows where to find the libraries needed. Of course you can put the result +everywhere you want, preferably alongside your normal scripts. As we merge code, +this is a rather good way to prevent compatibility issues. After all, some of +the code might get improved. + +You can \type {require("mtxlibs")} directly in which case it will load the core +libraries runtime. Of course this means that \LUA\ should be able to figure out +where it can find them. + +\stopsection + +\startsubject[title={Colofon}] + +\starttabulate[|B|p|] +\NC author \NC \getvariable{document}{author}, \getvariable{document}{affiliation}, \getvariable{document}{location} \NC \NR +\NC version \NC \currentdate \NC \NR +\NC website \NC \getvariable{document}{website} \endash\ \getvariable{document}{support} \NC \NR +\NC copyright \NC \symbol[cc][cc-by-sa-nc] \NC \NR +\stoptabulate + +\stopsubject + +\stopdocument |