ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Parallel texts: verse with blanks between stanzas via tabulate
@ 2022-08-26 20:00 Denis Maier via ntg-context
  2022-08-26 21:26 ` Henning Hraban Ramm via ntg-context
  0 siblings, 1 reply; 13+ messages in thread
From: Denis Maier via ntg-context @ 2022-08-26 20:00 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier


[-- Attachment #1.1: Type: text/plain, Size: 721 bytes --]

Hi,

I need to typeset two poems side by side. Usually, I use the tabulate environment for typesetting parallel texts. However, for poems this does not quite work as tabulate does not seem to allow blanks between the stanzas. See MWE below. Am I missing someting? Is there a better way to achieve this?

Best,
Denis

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\startbuffer[lines]
\startlines[after={\blank}]
this
is
a
poem

with
two
stanzas
\stoplines
\stopbuffer

\starttext

With a blank between the stanzas:
\getbuffer[lines]

Without a blank between the stanzas:
\starttabulate[|p|p|]
\NC \getbuffer[lines]
\NC \getbuffer[lines]
\NC\NR
\stoptabulate
\stoptext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[-- Attachment #1.2: Type: text/html, Size: 3458 bytes --]

[-- Attachment #2: 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  2022-08-26 20:00 Parallel texts: verse with blanks between stanzas via tabulate 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 21:19   ` Denis Maier via ntg-context
  0 siblings, 2 replies; 13+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-08-26 21:26 UTC (permalink / raw)
  To: Denis Maier via ntg-context; +Cc: Henning Hraban Ramm

Am 26.08.22 um 22:00 schrieb Denis Maier via ntg-context:
> Hi,
> 
> I need to typeset two poems side by side. Usually, I use the tabulate 
> environment for typesetting parallel texts. However, for poems this does 
> not quite work as tabulate does not seem to allow blanks between the 
> stanzas. See MWE below. Am I missing someting? Is there a better way to 
> achieve this?

How about columnsets or paragraphs?

\definecolumnset[Zwei][n=2]
\startcolumnset[Zwei]
\startlines
Starlight, star bright,
first star I see tonight;
\stoplines
\column
\startlines
I wish I may, I wish I might
have the wish I wish tonight.
\stoplines
\stopcolumnset


\defineparagraphs[Zwei][n=2]
\setupparagraphs[Zwei][1][
   width=.45\textwidth, distance=2em,
   align={verytolerant,stretch}]
% width of 2nd column is calculated automatically

\startZwei
...
\nextZwei
...
\stopZwei


Hraban
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  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:19   ` Denis Maier via ntg-context
  1 sibling, 1 reply; 13+ messages in thread
From: Denis Maier via ntg-context @ 2022-08-27  7:17 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier

Thanks. I'll try that. But, iirc, these had some other drawbacks.... I'll check if it works for my use case.

Is there a way to have blanks in the tabulate?
Denis



________________________________________
Von: ntg-context <ntg-context-bounces@ntg.nl> im Auftrag von Henning Hraban Ramm via ntg-context <ntg-context@ntg.nl>
Gesendet: Freitag, 26. August 2022 23:26:56
An: Denis Maier via ntg-context
Cc: Henning Hraban Ramm
Betreff: Re: [NTG-context] Parallel texts: verse with blanks between stanzas via tabulate

Am 26.08.22 um 22:00 schrieb Denis Maier via ntg-context:
> Hi,
>
> I need to typeset two poems side by side. Usually, I use the tabulate
> environment for typesetting parallel texts. However, for poems this does
> not quite work as tabulate does not seem to allow blanks between the
> stanzas. See MWE below. Am I missing someting? Is there a better way to
> achieve this?

How about columnsets or paragraphs?

\definecolumnset[Zwei][n=2]
\startcolumnset[Zwei]
\startlines
Starlight, star bright,
first star I see tonight;
\stoplines
\column
\startlines
I wish I may, I wish I might
have the wish I wish tonight.
\stoplines
\stopcolumnset


\defineparagraphs[Zwei][n=2]
\setupparagraphs[Zwei][1][
   width=.45\textwidth, distance=2em,
   align={verytolerant,stretch}]
% width of 2nd column is calculated automatically

\startZwei
...
\nextZwei
...
\stopZwei


Hraban
___________________________________________________________________________________
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
___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2022-08-27  7:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Wolfgang Schuster

Denis Maier via ntg-context schrieb am 27.08.2022 um 09:17:
> Thanks. I'll try that. But, iirc, these had some other drawbacks.... I'll check if it works for my use case.
>
> Is there a way to have blanks in the tabulate?

\startlines[inbetween={\dontleavehmode\crlf}]
...

Wolfgang

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  2022-08-26 21:26 ` Henning Hraban Ramm via ntg-context
  2022-08-27  7:17   ` Denis Maier via ntg-context
@ 2022-08-27 21:19   ` Denis Maier via ntg-context
  1 sibling, 0 replies; 13+ messages in thread
From: Denis Maier via ntg-context @ 2022-08-27 21:19 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier

> -----Ursprüngliche Nachricht-----
> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Henning
> Hraban Ramm via ntg-context
> Gesendet: Freitag, 26. August 2022 23:27
> An: Denis Maier via ntg-context <ntg-context@ntg.nl>
> Cc: Henning Hraban Ramm <texml@fiee.net>
> Betreff: Re: [NTG-context] Parallel texts: verse with blanks between stanzas
> via tabulate
> 
> Am 26.08.22 um 22:00 schrieb Denis Maier via ntg-context:
> > Hi,
> >
> > I need to typeset two poems side by side. Usually, I use the tabulate
> > environment for typesetting parallel texts. However, for poems this
> > does not quite work as tabulate does not seem to allow blanks between
> > the stanzas. See MWE below. Am I missing someting? Is there a better
> > way to achieve this?
> 
> How about columnsets or paragraphs?
> 
> \definecolumnset[Zwei][n=2]
> \startcolumnset[Zwei]
> \startlines
> Starlight, star bright,
> first star I see tonight;
> \stoplines
> \column
> \startlines
> I wish I may, I wish I might
> have the wish I wish tonight.
> \stoplines
> \stopcolumnset
> 
> 
> \defineparagraphs[Zwei][n=2]
> \setupparagraphs[Zwei][1][
>    width=.45\textwidth, distance=2em,
>    align={verytolerant,stretch}]
> % width of 2nd column is calculated automatically
> 
> \startZwei
> ...
> \nextZwei
> ...
> \stopZwei
> 
> 

Ok, I've had a chance to look into this. Maybe I'm missing something, but paragraphs cannot be split across pages. Is that correct? That's a bit of a problem.

As for columnsets, they seem to change the output routine for the entire page. Also not ideal in this case.

Denis
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Denis Maier via ntg-context @ 2022-08-27 21:25 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier

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?

Denis

> -----Ursprüngliche Nachricht-----
> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Wolfgang
> Schuster via ntg-context
> Gesendet: Samstag, 27. August 2022 09:27
> An: mailing list for ConTeXt users <ntg-context@ntg.nl>
> Cc: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
> Betreff: Re: [NTG-context] Parallel texts: verse with blanks between stanzas
> via tabulate
> 
> Denis Maier via ntg-context schrieb am 27.08.2022 um 09:17:
> > Thanks. I'll try that. But, iirc, these had some other drawbacks.... I'll check
> if it works for my use case.
> >
> > Is there a way to have blanks in the tabulate?
> 
> \startlines[inbetween={\dontleavehmode\crlf}]
> ...
> 
> Wolfgang
> 
> ______________________________________________________________
> _____________________
> 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
> ______________________________________________________________
> _____________________
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  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
  2022-08-29 11:31           ` Denis Maier via ntg-context
  0 siblings, 2 replies; 13+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-28  8:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

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: text/plain, Size: 3231 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-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

[-- 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  2022-08-28  8:41         ` Hans Hagen via ntg-context
@ 2022-08-29  9:36           ` Denis Maier via ntg-context
  2022-08-29 11:31           ` Denis Maier via ntg-context
  1 sibling, 0 replies; 13+ messages in thread
From: Denis Maier via ntg-context @ 2022-08-29  9:36 UTC (permalink / raw)
  To: j.hagen, ntg-context; +Cc: denis.maier

[-- 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  2022-08-28  8:41         ` Hans Hagen via ntg-context
  2022-08-29  9:36           ` Denis Maier via ntg-context
@ 2022-08-29 11:31           ` Denis Maier via ntg-context
  2022-08-29 11:58             ` Hans Hagen via ntg-context
  1 sibling, 1 reply; 13+ messages in thread
From: Denis Maier via ntg-context @ 2022-08-29 11:31 UTC (permalink / raw)
  To: j.hagen, ntg-context; +Cc: denis.maier

> -----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

Another, more general question on this: why is the function poetry.sidebyside defined twice? If I understand correctly, depending on the input one or the other will be used, but I don't see where that happens...

Best,
Denis
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-29 11:58 UTC (permalink / raw)
  To: ntg-context; +Cc: Hans Hagen

[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]

On 8/29/2022 1:31 PM, Denis Maier via ntg-context wrote:
>> -----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
> 
> Another, more general question on this: why is the function poetry.sidebyside defined twice? If I understand correctly, depending on the input one or the other will be used, but I don't see where that happens...
the first can be commented as it is the first simple variant

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: text/plain, Size: 4529 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 }
        local fi = 1
        local si = 1
        local n  = #first > #second and #first or #second

        local function flush(f,s)
            context.NC() context(f)
            context.NC() context(s)
            context.NC() context.NR()
            if f ~= "" then
                fi = fi + 1
            end
            if s ~= "" then
                si = si + 1
            end
        end

        while fi <= n and si <= n do
            local f = first [fi] or ""
            local s = second[si] or ""
            if f ~= "" and s ~= "" then
                flush(f,s)
            else
                while true do
                    if f ~= "" or s ~= "" then
                        flush(f,s)
                    else
                        while f == "" do
                            fi = fi + 1
                            f = first [fi] or ""
                        end
                        while s == "" do
                            si = si + 1
                            s = second[si] or ""
                        end
                        break
                    end
                    f = first [fi] or ""
                    s = second[si] or ""
                end
             -- context.HL()
                context.TB { "medium" }
            end
        end
    context.stoptabulate()
end

interfaces.implement {
    name      = "poetrysidebyside",
    protected = true,
    public    = true,
    actions   = poetry.sidebyside,
    arguments = "hash",
}

\stopluacode

\continueifinputfile{m-poetry.mkxl}

\starttext

\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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Denis Maier via ntg-context @ 2022-08-30 11:40 UTC (permalink / raw)
  To: ntg-context; +Cc: denis.maier


[-- Attachment #1.1: Type: text/plain, Size: 2045 bytes --]

> -----Ursprüngliche Nachricht-----

> Von: ntg-context <ntg-context-bounces@ntg.nl<mailto:ntg-context-bounces@ntg.nl>> Im Auftrag von Hans Hagen

> via ntg-context

> Gesendet: Montag, 29. August 2022 13:58

> An: ntg-context@ntg.nl<mailto:ntg-context@ntg.nl>

> Cc: Hans Hagen <j.hagen@xs4all.nl<mailto:j.hagen@xs4all.nl>>

> Betreff: Re: [NTG-context] Parallel texts: verse with blanks between stanzas

> via tabulate

>

> On 8/29/2022 1:31 PM, Denis Maier via ntg-context wrote:

> >> -----Ursprüngliche Nachricht-----

> >> Von: Hans Hagen <j.hagen@freedom.nl<mailto:j.hagen@freedom.nl>>

> >> Gesendet: Sonntag, 28. August 2022 10:41

> >> An: mailing list for ConTeXt users <ntg-context@ntg.nl<mailto:ntg-context@ntg.nl>>

> >> Cc: Maier, Denis Christian (UB) <denis.maier@unibe.ch<mailto: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

> >

> > Another, more general question on this: why is the function

> poetry.sidebyside defined twice? If I understand correctly, depending on the

> input one or the other will be used, but I don't see where that happens...

> the first can be commented as it is the first simple variant

>



I see.



Thanks for the updated version. So, that means the basic restriction is that blanks will need to be inserted between rows, right? We cannot have to two completely independent formatted poems, right? (For reference, see the attached PNG. This was done with paragraphs, and works as longs as this stays on a single page. One is one long stanza, the other one consists of multiple smaller stanzas.)



Denis

[-- Attachment #1.2: Type: text/html, Size: 6006 bytes --]

[-- Attachment #2: poetry-side-by-side.PNG --]
[-- Type: image/png, Size: 48743 bytes --]

[-- 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-30 12:30 UTC (permalink / raw)
  To: denis.maier, mailing list for ConTeXt users; +Cc: Hans Hagen

On 8/30/2022 1:40 PM, denis.maier@unibe.ch wrote:

> Thanks for the updated version. So, that means the basic restriction is that blanks will need to be inserted between rows, right? We cannot have to two completely independent formatted poems, right? (For reference, see the attached PNG. This was done with paragraphs, and works as longs as this stays on a single page. One is one long stanza, the other one consists of multiple smaller stanzas.)
You need to be more prececise in defining what you want .. this example 
is not a parallel obe right? Just two columns.

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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Parallel texts: verse with blanks between stanzas via tabulate
  2022-08-30 12:30                 ` Hans Hagen via ntg-context
@ 2022-08-30 12:55                   ` Denis Maier via ntg-context
  0 siblings, 0 replies; 13+ messages in thread
From: Denis Maier via ntg-context @ 2022-08-30 12:55 UTC (permalink / raw)
  To: j.hagen, ntg-context; +Cc: denis.maier

> -----Ursprüngliche Nachricht-----
> Von: Hans Hagen <j.hagen@freedom.nl>
> Gesendet: Dienstag, 30. August 2022 14:31
> An: Maier, Denis Christian (UB) <denis.maier@unibe.ch>; mailing list for
> ConTeXt users <ntg-context@ntg.nl>
> Betreff: Re: AW: [NTG-context] Parallel texts: verse with blanks between
> stanzas via tabulate
> 
> On 8/30/2022 1:40 PM, denis.maier@unibe.ch wrote:
> 
> > Thanks for the updated version. So, that means the basic restriction
> > is that blanks will need to be inserted between rows, right? We cannot
> > have to two completely independent formatted poems, right? (For
> > reference, see the attached PNG. This was done with paragraphs, and
> > works as longs as this stays on a single page. One is one long stanza,
> > the other one consists of multiple smaller stanzas.)
> You need to be more prececise in defining what you want .. this example is not
> a parallel obe right? Just two columns.
> 

Sorry for not being precise enough.

I'm not sure I understand. This example shows two poems side by side. Both are totally different in structure. One has a heading, and consists of multiple paragraphs. The other is just one long stanza. Until now, I've used tabulate for these kind of sidebyside texts. Usually there are not poems, just regular paragraphs, but with poems I've realized that blanks seem not be supported in individual table cells.

Denis

\startbuffer[lines1]
\startlines[inbetween={\blank}]
this
is
a
poem
with
one 
longer 
stanza
\stoplines
\stopbuffer

\startbuffer[lines2]
\startlines[inbetween={\blank}]
this
is
a
poem

with
some
stanzas

here is 
another one

and another one
\stoplines
\stopbuffer

\starttext

Just the buffers.

One:

\getbuffer[lines1]

Two:

\getbuffer[lines2]


Via paragraphs

\defineparagraphs[paraverse][n=2 ]
\setupparagraphs[paraverse][1][
   width=.45\textwidth, distance=2em,
   align={verytolerant,stretch}]

\startparaverse
\getbuffer[lines1]
\nextparaverse
\getbuffer[lines2]
\stopparaverse

Via tabulate
\starttabulate[|p|p|]
\NC \getbuffer[lines1]
\NC \getbuffer[lines2]
\NC\NR
\stoptabulate

\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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-08-30 12:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 20:00 Parallel texts: verse with blanks between stanzas via tabulate 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
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

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).