From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from cgl.ntg.nl (Cgl.ntg.nl [5.39.185.202]) by inbox.vuxu.org (Postfix) with ESMTP id D55142BA5F for ; Tue, 20 Feb 2024 20:15:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id ABD2E484203 for ; Tue, 20 Feb 2024 20:12:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Authentication-Results: cgl.ntg.nl (amavisd-new); dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=scorecrow.com header.b="QAAqdo2H"; dkim=fail (2048-bit key) reason="fail (message has been altered)" header.d=messagingengine.com header.b="g2b4rUKe" Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9jZRSG6mdiVr for ; Tue, 20 Feb 2024 20:12:40 +0100 (CET) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 4158A4841A5 for ; Tue, 20 Feb 2024 20:11:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 7AA37483B30 for ; Tue, 20 Feb 2024 20:10:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at cgl.ntg.nl Received: from cgl.ntg.nl ([127.0.0.1]) by localhost (cgl.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rNtCsrbzr1Mx for ; Tue, 20 Feb 2024 20:10:43 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=ntg@scorecrow.com; receiver= Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cgl.ntg.nl (Postfix) with ESMTPS id 8F6A8483B27 for ; Tue, 20 Feb 2024 20:10:43 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 0D100320090C for ; Tue, 20 Feb 2024 14:10:40 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 20 Feb 2024 14:10:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scorecrow.com; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1708456240; x=1708542640; bh=mNOf/H5RIv gM6vk+y1VwMqLzTag8IsiSZ9e6TmNHshU=; b=QAAqdo2HEASfra/CnyKyqom+EB mjxuJx7/Ql0z2xzNYGV2iIPmNaUZdTf7Cb3vQriI6WUllZ3ip5RDiHDHahwCjHh4 c/wfXEE6L81TJfGG5yioTokPjSSo2kN/uxsqj2fgME2aSUyN5SJm0v2sfFSYpMSP W1uRS6K/AFxPlZKheAOsa4LjiUmjy0tnLII/gmlyZqjHdfRY8scFeX7dm0UE8AZ9 upam0391RsbSK4lJm6IT7jIdrTrQycaKRJv+iG5y0CkQ5GHPS7a9GQQCbW3H8/Ys lZY/69JPy9VsKhjzaDUwXPO4gNGURPCOo7b4M54oI1e6QnxfeJ7cEYqpRz9w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708456240; x=1708542640; bh=mNOf/H5RIvgM6vk+y1VwMqLzTag8 IsiSZ9e6TmNHshU=; b=g2b4rUKeNYblwWJQKKvQ+m8ouqnz/DafPZO8BksfJ79m fhbGX/XHD3sgvwhmUdr4tdmb3WH0Z9oOdMlyNc9PwNRlqbYimij1z+MICJI2Zt/z 0D2ICNu1Lw5x4SORosyiSHt/0BWJJBcbbr0yaXnr0szyGr0wcPTs6cib7kR3BQiG MMuEoTzcojKVZjYFV6n+/rk8MOaZV82VvijJcgLMBbtTczzeVtop9Mwu15J/KuNS EIMBbc2+eosn0dknh+OgMq7QFv/dq6pKuZ/RxUsLSLmZVLLsTC99cX4c5Gbd6aBY HNiiQ0Fsvmp1aHCADPa0Yb/PPv6mwmLQoPgVLik5xA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedtgdduvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfgtggfuffhfvfgjkffosehmtdhmrehhtdejnecuhfhrohhmpeeurhhutggv ucfjohhrrhhotghkshcuoehnthhgsehstghorhgvtghrohifrdgtohhmqeenucggtffrrg htthgvrhhnpeekheeufeelueegheevgfevuedtjeetkeeivdevgeeihfffteetuddukefh fedttdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hnthhgsehstghorhgvtghrohifrdgtohhm X-ME-Proxy: Feedback-ID: ib6b14750:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 20 Feb 2024 14:10:39 -0500 (EST) From: Bruce Horrocks Content-Type: multipart/mixed; boundary="Apple-Mail=_75CCD336-5EEB-4CCD-AC7A-6AF7216F2F91" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.400.31\)) Date: Tue, 20 Feb 2024 19:10:18 +0000 References: <170843395043.3180173.12511363966774513204@cgl.ntg.nl> To: ntg-context mailing list In-Reply-To: <170843395043.3180173.12511363966774513204@cgl.ntg.nl> Message-Id: <744177EC-F639-400E-BFB4-07731DE86B9F@scorecrow.com> X-Mailer: Apple Mail (2.3774.400.31) Message-ID-Hash: UX6PQKKHCK5UK3E6G6YFJZ4XREURREOG X-Message-ID-Hash: UX6PQKKHCK5UK3E6G6YFJZ4XREURREOG X-MailFrom: ntg@scorecrow.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list Reply-To: mailing list for ConTeXt users Subject: [NTG-context] Re: using an end of line as parameter List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --Apple-Mail=_75CCD336-5EEB-4CCD-AC7A-6AF7216F2F91 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 20 Feb 2024, at 12:59, madiazm.eoicc@gmail.com wrote: >=20 > no, I just want to split at the end of each sentence to get the four = arguments: now I pass this four lines to my macro \tareaAbc (with the = dirty trick of =C3=B1) >=20 > In den B=C3=BCchereien gibt es auch =E2=80=A6=C3=B1=20 > =E2=80=A6 Kuchen.=C3=B1 =20 > =E2=80=A6 Theater.=C3=B1 =20 > =E2=80=A6 Workshops.=C3=B1=20 >=20 > and I wish your context.foo(lines[i]) iteration would become a single = context.tareaAbc(the four arguments somehow separated so that I can = manage each line with the corresponding context formatting) >=20 > As you see my definition is: \def\tareaAbc #1=C3=B1#2=C3=B1#3=C3=B1#4=C3= =B1{...context formating for each #)}; Its the clue to pass each = sentence as an independent argument that I don't get to work. > thanks again >=20 A variation on Hans original suggestion is to use a buffer instead of a = separate text file, combined with Lua. \startluacode userdata =3D userdata or {} =20 function userdata.formatTestQuestions() local the_buffer =3D buffers.getlines("TestQuestions") local tracker =3D 0 local the_question =3D {} local letters =3D {"-", "a", "b", "c"} =20 -- Go through the buffer of questions one line at a time for i =3D 1,#the_buffer do -- Skip blank lines but 'collect' non-blank lines until we have = four -- (which is assumed to be a whole question) if string.strip(the_buffer[i]) =3D=3D "" then tracker =3D 0 the_question =3D {} else tracker =3D tracker + 1 the_question[tracker] =3D the_buffer[i] end =20 -- If tracker has got to 4 then we've read four lines if tracker =3D=3D 4 then context.startlines() context("{\\bf Beispiel:} %s", the_question[1]) context(true) for answer =3D 2,4 do context("\\qquad %s) %s", letters[answer], = the_question[answer]) context(true) end context.stoplines() =20 -- Reset for the next question (in case no blank line) tracker =3D 0 the_question =3D {} end =20 end end \stopluacode \def\startTestQuestions {\dostartbuffer[TestQuestions][startTestQuestions][stopTestQuestions]} \def\stopTestQuestions {\ctxlua{userdata.formatTestQuestions()}} \starttext Here are some questions: \startTestQuestions In den B=C3=BCchereien gibt es auch =E2=80=A6=20 =E2=80=A6 Kuchen. =E2=80=A6 Theater. =E2=80=A6 Workshops. In den B=C3=BCchereien gibt es auch =E2=80=A6=20 =E2=80=A6 Kuchen. =E2=80=A6 Theater. =E2=80=A6 Workshops. In den B=C3=BCchereien gibt es auch =E2=80=A6=20 =E2=80=A6 Kuchen. =E2=80=A6 Theater. =E2=80=A6 Workshops. \stopTestQuestions How do you think you did on that test? Here's another one. \startTestQuestions In den B=C3=BCchereien gibt es auch =E2=80=A6=20 =E2=80=A6 Kuchen. =E2=80=A6 Theater. =E2=80=A6 Workshops. \stopTestQuestions \stoptext =E2=80=94 Bruce Horrocks Hampshire, UK --Apple-Mail=_75CCD336-5EEB-4CCD-AC7A-6AF7216F2F91 Content-Disposition: attachment; filename=tt.tex Content-Type: application/octet-stream; x-unix-mode=0644; name="tt.tex" Content-Transfer-Encoding: quoted-printable \startluacode=0A=20=20userdata=20=3D=20userdata=20or=20{}=0A=20=20=0A=20=20= function=20userdata.formatTestQuestions()=0A=20=20=20=20local=20= the_buffer=20=3D=20buffers.getlines("TestQuestions")=0A=20=20=20=20local=20= tracker=20=3D=200=0A=20=20=20=20local=20the_question=20=3D=20{}=0A=20=20=20= =20local=20letters=20=3D=20{"-",=20"a",=20"b",=20"c"}=0A=20=20=20=20=0A=20= =20=20=20--=20Go=20through=20the=20buffer=20of=20questions=20one=20line=20= at=20a=20time=0A=20=20=20=20for=20i=20=3D=201,#the_buffer=20do=0A=0A=20=20= =20=20=20=20--=20Skip=20blank=20lines=20but=20'collect'=20non-blank=20= lines=20until=20we=20have=20four=0A=20=20=20=20=20=20--=20(which=20is=20= assumed=20to=20be=20a=20whole=20question)=0A=20=20=20=20=20=20if=20=20= string.strip(the_buffer[i])=20=3D=3D=20""=20then=0A=20=20=20=20=20=20=20=20= tracker=20=3D=200=0A=20=20=20=20=20=20=20=20the_question=20=3D=20{}=0A=20= =20=20=20=20=20else=0A=20=20=20=20=20=20=20=20tracker=20=3D=20tracker=20= +=201=0A=20=20=20=20=20=20=20=20the_question[tracker]=20=3D=20= the_buffer[i]=0A=20=20=20=20=20=20end=0A=20=20=20=20=20=20=0A=20=20=20=20= =20=20--=20If=20tracker=20has=20got=20to=204=20then=20we've=20read=20= four=20lines=0A=20=20=20=20=20=20if=20tracker=20=3D=3D=204=20then=0A=20=20= =20=20=20=20=20=20context.startlines()=0A=20=20=20=20=20=20=20=20= context("{\\bf=20Beispiel:}=20%s",=20the_question[1])=0A=20=20=20=20=20=20= =20=20context(true)=0A=20=20=20=20=20=20=20=20for=20answer=20=3D=202,4=20= do=0A=20=20=20=20=20=20=20=20=20=20context("\\qquad=20%s)=20%s",=20= letters[answer],=20the_question[answer])=0A=20=20=20=20=20=20=20=20=20=20= context(true)=0A=20=20=20=20=20=20=20=20end=0A=20=20=20=20=20=20=20=20= context.stoplines()=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=0A=20=20=20=20=20=20=20=20--=20Reset=20for=20the=20next=20question=20= (in=20case=20no=20blank=20line)=0A=20=20=20=20=20=20=20=20tracker=20=3D=20= 0=0A=20=20=20=20=20=20=20=20the_question=20=3D=20{}=0A=20=20=20=20=20=20= end=0A=20=20=20=20=20=20=0A=20=20=20=20end=0A=20=20end=0A\stopluacode=0A=0A= \def\startTestQuestions=0A=20=20= {\dostartbuffer[TestQuestions][startTestQuestions][stopTestQuestions]}=0A= \def\stopTestQuestions=0A=20=20{\ctxlua{userdata.formatTestQuestions()}}=0A= =0A\starttext=0AHere=20are=20some=20questions:=0A=0A\startTestQuestions=0A= In=20den=20B=C3=BCchereien=20gibt=20es=20auch=20=E2=80=A6=20=0A=E2=80=A6=20= Kuchen.=0A=E2=80=A6=20Theater.=0A=E2=80=A6=20Workshops.=0A=0AIn=20den=20= B=C3=BCchereien=20gibt=20es=20auch=20=E2=80=A6=20=0A=E2=80=A6=20Kuchen.=0A= =E2=80=A6=20Theater.=0A=E2=80=A6=20Workshops.=0AIn=20den=20B=C3=BCchereien= =20gibt=20es=20auch=20=E2=80=A6=20=0A=E2=80=A6=20Kuchen.=0A=E2=80=A6=20= Theater.=0A=E2=80=A6=20Workshops.=0A\stopTestQuestions=0A=0AHow=20do=20= you=20think=20you=20did=20on=20that=20test?=20Here's=20another=20one.=0A=0A= \startTestQuestions=0AIn=20den=20B=C3=BCchereien=20gibt=20es=20auch=20= =E2=80=A6=20=0A=E2=80=A6=20Kuchen.=0A=E2=80=A6=20Theater.=0A=E2=80=A6=20= Workshops.=0A\stopTestQuestions=0A=0A\stoptext= --Apple-Mail=_75CCD336-5EEB-4CCD-AC7A-6AF7216F2F91 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_75CCD336-5EEB-4CCD-AC7A-6AF7216F2F91 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________ --Apple-Mail=_75CCD336-5EEB-4CCD-AC7A-6AF7216F2F91--