From: Denis Maier via ntg-context <ntg-context@ntg.nl>
To: <j.hagen@freedom.nl>, <ntg-context@ntg.nl>
Cc: denis.maier@unibe.ch
Subject: Re: Parallel texts: verse with blanks between stanzas via tabulate
Date: Mon, 29 Aug 2022 09:36:44 +0000 [thread overview]
Message-ID: <7b0769a710b5416daf5f9e93715cd9ef@unibe.ch> (raw)
In-Reply-To: <79b7b687-b6b2-473a-bc31-9a29e63160f0@freedom.nl>
[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]
Thanks Hans, that's very nice indeed. Looks like I really need to dive into CLD. There seem to be so many possibilies...
However, the major pitfall seems to be that this assumes stanzas of equal length (as it relies on \TB to produce the blanks), which does not apply to my situation. (Modfied version attached.)
Do you see any way to support this kind of situation?
Best,
Denis
> -----Ursprüngliche Nachricht-----
> Von: Hans Hagen <j.hagen@freedom.nl>
> Gesendet: Sonntag, 28. August 2022 10:41
> An: mailing list for ConTeXt users <ntg-context@ntg.nl>
> Cc: Maier, Denis Christian (UB) <denis.maier@unibe.ch>
> Betreff: Re: [NTG-context] Parallel texts: verse with blanks between stanzas
> via tabulate
>
> 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
> -----------------------------------------------------------------
[-- Attachment #2: m-poetry.mkxl --]
[-- Type: application/octet-stream, Size: 3471 bytes --]
%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-1b]
THIS
IS
A
LONGER
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-1b",
right = "lines-2",
template = "|l|i2r|"
}
}
\ctxlua {
moduledata.poetry.sidebyside {
left = "lines-3",
template = "|r|il|"
}
}
\poetrysidebyside
[left=lines-3,
template={|r|il|}]
\stoptext
[-- Attachment #3: Type: text/plain, Size: 496 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2022-08-29 9:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 20:00 Denis Maier via ntg-context
2022-08-26 21:26 ` Henning Hraban Ramm via ntg-context
2022-08-27 7:17 ` Denis Maier via ntg-context
2022-08-27 7:26 ` Wolfgang Schuster via ntg-context
2022-08-27 21:25 ` Denis Maier via ntg-context
2022-08-28 8:41 ` Hans Hagen via ntg-context
2022-08-29 9:36 ` Denis Maier via ntg-context [this message]
2022-08-29 11:31 ` Denis Maier via ntg-context
2022-08-29 11:58 ` Hans Hagen via ntg-context
2022-08-30 11:40 ` Denis Maier via ntg-context
2022-08-30 12:30 ` Hans Hagen via ntg-context
2022-08-30 12:55 ` Denis Maier via ntg-context
2022-08-27 21:19 ` Denis Maier via ntg-context
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b0769a710b5416daf5f9e93715cd9ef@unibe.ch \
--to=ntg-context@ntg.nl \
--cc=denis.maier@unibe.ch \
--cc=j.hagen@freedom.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).