Changes

Jump to navigation Jump to search
591 bytes added ,  20:46, 20 June 2013
m
→‎Basic reading: update source link
== Basic reading ==
* [http://www.pragma-ade.com/general/manuals/cld-mkiv.pdf The CLD manual] by Hans Hagen.
* [[source:mult{{src|cldf-cldini.lua| The source code}}: the entry point for the '''cldf-*''' files that contain the CLD implementation.]]
== An Example ==
</context>
With CLDs As <em>CLD</em> this will require more verbosity because nesting -- in the present example a <code>framed</code> inside a <code>placefigure</code> -- has to be expressed through functions.
Optional and key-value style arguments are expressed as arrays and dictionaries respectively, which is a transparent representation of their ConTeXt ancestors.
Mandatory (grouped) arguments are given either as strings or as functions.
=== Nesting 1: Functions ===The following example shows two ways of rewriting the above TeX code: the first one closely resembles its structure while the second calls the function <code>test</code> from inside the <code>placefigure</code> macro -- NB: it is compulsory to call a declared function by means of another function, otherwise ConTeXt can't process it.(Works with latest ConTeXt beta as of 2010-03-10.)
<pre>
context.placefigure(
</pre>
 
=== Nesting 2: Delayed ===
 
An alternative to the function encapsulation is provided by
the <tt>context.delayed.f()</tt> method.
This way execution of the <tt>\input</tt>
command is prevented until <tt>\placefigure</tt> is passed to TeX,
the obvious advantage being that the source code follows the
original TeX code and that it eliminates the need to create
a separate function.
 
<pre>
context.placefigure(
"none",
function()
context.framed( {
frame="on",
align="middle"
},
context.delayed.input("knuth")
)
end
)
</pre>
 
 
[[Category:Lua]]
[[Category:LuaTeX]]
[[Category:Programming]]
188

edits

Navigation menu