ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: damien thiriet via ntg-context <ntg-context@ntg.nl>
To: ntg-context@ntg.nl
Cc: damien@thiriet.web4me.fr
Subject: filling buffers in cld documents
Date: Sun, 27 Nov 2022 13:05:11 +0100	[thread overview]
Message-ID: <275c56b4bee1ed8bf6debfdbbaaa07a4@thiriet.web4me.fr> (raw)

Hi,


I am used to giving very extensive feedbacks to my pupils.
These are buffers with xtables flushing lua vectors.
Here is their basic structures:

* an environment that stores xtables. Turned into MWE, look like:

    \startenvironment env_corrige.mkiv

    \startluacode
       userdata = userdata or {}
    function userdata.Critere (commentaire,note,notemax)
       context.startxcell {"width=11cm","height=2.75cm"}
          context(Eleve[commentaire])
       context.stopxcell ()
       context.startxcell {"width=1.5cm","align=flushright"}
          context(Eleve[note])
          context("/")
          context(notemax)
       context.stopxcell ()
    end
    \stopluacode

    \startbuffer [grille]
    \startxtable
       \startxrow
          \startxcell
             \ctxlua {userdata.Critere ("structure","NoteStructure",2)}
          \stopxcell
       \stopxrow
    \stopxtable
    \stopbuffer
    \stopenvironment

* The main file is divided in subjects, each one of them
being the feedback to one pupil. In a MWE fashion

    \useenvironment [env_corrige]
    \starttext
    \startsubject[title={Astérix}]
    \startluacode
    Eleve = {
       structure = "analyse très fine",
       NoteStructure = 2,
    }
    \stopluacode
    \getbuffer [grille]
    \stopsubject

    \startsubject[title={Obélix}]
    Eleve = {
       structure = "le détail doit être travaillé. Pensez à la finesse de 
vos menhirs…"
       NoteStructure = 1,
    }
    \stopsubject
    \getbuffer [grille]
    \stoptext

Since whatever I fill in those files is written
inside luacode environment, I tried to switch to
cld documents.

Here is my main file in cld version

    context.useenvironment({"env_corrige"})

    context.starttext()

    context.startsubject({title="Asterix"})

    Eleve = {
       structure = "analyse très fine",
       NoteStructure = 2,
    }
    context.getbuffer({"ExoCorrection"})
    context.stopsubsubject()

    context.startsubject({title="Obélix"})

    Eleve = {
       structure = "le détail doit être travaillé. Pensez à la finesse de 
vos menhirs…"
       NoteStructure = 1,
    }
    context.getbuffer({"ExoCorrection"})
    context.stopsubsubject()
    context.stoptext()

The troubles is that buffers are filled with
the last version of Eleve table.
I guess this is because the whole file
is parsed and then filled in buffers.
My understanding of the cld manuel is that
context.tobuffer()
and
context.direct()

should be used, but couldn't figure out how.
Tried several times, also with context.step but
all failed.
I think I didn't properly understand the "temp"
and str of context.tobuffer description in manual.

What changes should I introduce to my cld files?

Best regards,

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

             reply	other threads:[~2022-11-27 12:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-27 12:05 damien thiriet via ntg-context [this message]
2022-11-27 13:04 ` Hans Hagen 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=275c56b4bee1ed8bf6debfdbbaaa07a4@thiriet.web4me.fr \
    --to=ntg-context@ntg.nl \
    --cc=damien@thiriet.web4me.fr \
    /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).