On 8/27/2022 11:25 PM, Denis Maier via ntg-context wrote:
Thanks, Wolfgang. That gives me a blank between the verses. However the blank
is rather huge and I don't see how I could make it smaller? Is it possible to
do this?
morning exercise attached (you can run the file)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
%D \module
%D [ file=m-poetry,
%D version=2022.08.28
%D title=\CONTEXT\ Extra Modules,
%D subtitle=Whatever comes up,
%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.
% For Denis Maier (see mails to list end of August 2022)
\startluacode
local poetry = moduledata.poetry or { }
moduledata.poetry = poetry
function poetry.sidebyside(specification)
local first = string.splitlines(buffers.getcontent(specification.left))
local second = string.splitlines(buffers.getcontent(specification.right))
local template = specification.template or "|||"
context.starttabulate { template }
for i=1,#first do
local f = first [i] or ""
local s = second[i] or ""
if f == "" and s == "" then
context.TB { "medium" }
else
context.NC() context(f)
context.NC() context(s)
context.NC() context.NR()
end
end
context.stoptabulate()
end
function poetry.sidebyside(specification)
local left = specification.left
local right = specification.right
local first = left and string.splitlines(buffers.getcontent(left )) or {
}
local second = right and string.splitlines(buffers.getcontent(right)) or {
}
if #first > 0 and #second == 0 then
for i=1,#first do
local t = string.split(first[i], "|")
first[i] = string.strip(t[1] or "")
second[i] = string.strip(t[2] or "")
end
end
local template = specification.template or "|||"
context.starttabulate { template }
for i=1,#first do
local f = first [i] or ""
local s = second[i] or ""
if f == "" and s == "" then
context.TB { "medium" }
else
context.NC() context(f)
context.NC() context(s)
context.NC() context.NR()
end
end
context.stoptabulate()
end
interfaces.implement {
name = "poetrysidebyside",
protected = true,
public = true,
actions = poetry.sidebyside,
arguments = "hash",
}
\stopluacode
\continueifinputfile{m-poetry.mkxl}
\starttext
\startbuffer[lines-1]
THIS
IS
A
POEM
WITH
TWO
STANZAS
\stopbuffer
\startbuffer[lines-2]
this
is
a
poem
with
two
stanzas
\stopbuffer
\startbuffer[lines-3]
this | THIS
is | IS
a | A
poem | POEM
|
with | WITH
two | TWO
stanzas | STANZAS
\stopbuffer
\ctxlua {
moduledata.poetry.sidebyside {
left = "lines-1",
right = "lines-2",
template = "|l|i2r|"
}
}
\ctxlua {
moduledata.poetry.sidebyside {
left = "lines-3",
template = "|r|il|"
}
}
\poetrysidebyside
[left=lines-3,
template={|r|il|}]
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________