From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30482 invoked from network); 11 Aug 2023 21:54:50 -0000 Received: from cgl.ntg.nl (5.39.185.202) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2023 21:54:50 -0000 Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id 12741482562 for ; Fri, 11 Aug 2023 23:54:22 +0200 (CEST) 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 mTxInnYqeUjl for ; Fri, 11 Aug 2023 23:54:21 +0200 (CEST) Received: from cgl.ntg.nl (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id B88DD482571 for ; Fri, 11 Aug 2023 23:53:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cgl.ntg.nl (Postfix) with ESMTP id CF46C4822E3 for ; Fri, 11 Aug 2023 23:53:21 +0200 (CEST) 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 n2O6LJNhTT9A for ; Fri, 11 Aug 2023 23:53:21 +0200 (CEST) Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.186]) (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 563074822D4 for ; Fri, 11 Aug 2023 23:53:21 +0200 (CEST) X-KPN-MessageId: 5d8bc453-3891-11ee-87d3-00505699b430 Received: from smtp.kpnmail.nl (unknown [10.31.155.5]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 5d8bc453-3891-11ee-87d3-00505699b430; Fri, 11 Aug 2023 23:52:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=content-type:from:to:subject:mime-version:date:message-id; bh=B2OyV1kqHRDDYzOtpMBgfxJ45+Io27RrtiMRY3YIu9M=; b=cmIpI00WrM4Btkq239DrI2KzpxKr3jBqeCstPE1nvf+aZmJHFcFIwNKXx51DuUTBIYjsUmd1oxbli HZHw5lPp6mQZbpCh46EK1xuf8eQlTvk+x5ReZd1OmV2eh4MviQdhyxD8xoPc5ombtcCK7wvCodE2H4 7RTSIYF829irjTyiB1Xs/0NW6430xIZe0xARgRHDy6yZv99ke8dW8R6FizmPEgWGuZa2DVmq/9Ofhz FftdGsLVQC5oYjJYeHe/70vdr7B4wj6roTE+0GVDvyaOAtaQYQb0UeFOao1LuKSZ1tARXM3Yxcpzcb lPnasxIyYlYwIUgYJj9mkyc2FIzy+Pw== X-KPN-MID: 33|4yTkfIbo559MVvSfgdvMmC3opFWUiZRjPUbaNrfKa7L4YUI1tfYhen8kAqSO+BH MzZGA7Nzzs26xInfqe0ZTlvU2llif2IZ5cQE5yR7eVJE= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|NX+0JeQLmM6Th43H2051pSyKz62kpkGSxjMNXf6ZfNi9CvEHVEJw/wgImEOnmvf 7KPvJKHDuwLvr5tUxy8LfiA== X-Originating-IP: 213.125.29.162 Received: from [10.100.1.105] (d57d1da2.static.ziggozakelijk.nl [213.125.29.162]) by smtp.xs4all.nl (Halon) with ESMTPSA id 7c9afc38-3891-11ee-af02-00505699b758; Fri, 11 Aug 2023 23:53:21 +0200 (CEST) Message-ID: <550cf663-274f-106c-e930-03fb0b092643@xs4all.nl> Date: Fri, 11 Aug 2023 23:53:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-US To: Thangalin , mailing list for ConTeXt users References: From: Hans Hagen In-Reply-To: Message-ID-Hash: CK7JWZPWMMBJPTDYIQL47I3MCW5QMET5 X-Message-ID-Hash: CK7JWZPWMMBJPTDYIQL47I3MCW5QMET5 X-MailFrom: j.hagen@xs4all.nl 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: Pass string into text background graphic List-Id: mailing list for ConTeXt users Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii"; format="flowed" Content-Transfer-Encoding: 7bit On 8/11/2023 9:57 PM, Thangalin wrote: > Hi list, > > I'm attempting to make a stylized border around paragraphs that can span > pages. The border runs along the side and the top. (Ideally the top border > wouldn't repeat, but that's a minor issue.) The issue I'm having is that > the title for the text doesn't always appear. Instead, there's a small gap > along the top border where the title should be. > > Am I going about this the wrong way? > > % SOT > \startbuffer[demo] > > >
> Text Goes Here >
>
> Different Text Goes Here >
> > \stopbuffer > \startxmlsetups xml:xhtml > \xmlsetsetup{\xmldocument}{*}{-} > \xmlsetsetup{\xmldocument}{html|body}{xml:*} > \xmlsetsetup{\xmldocument}{div}{xml:*}\stopxmlsetups > \xmlregistersetup{xml:xhtml} > \startxmlsetups xml:html > \xmlflush{#1}\stopxmlsetups > \startxmlsetups xml:body > \xmlflush{#1}\stopxmlsetups > \startxmlsetups xml:div > \setvariable{div}{\xmlatt{#1}{class}}{#1} > \start[\xmlatt{#1}{class}]\xmlflush{#1}\stop\stopxmlsetups > \startusableMPgraphic{GraphicConcurrent} > begingroup; > string legend; > > picture title; > picture border; > picture bg; > > numeric tw; > numeric th; > > legend := \MPstring{concurrent}; > > title := nullpicture; > border := nullpicture; > bg := textext( "\strut " & legend ); > > tw := xpart lrcorner bg - xpart llcorner bg; > th := ypart ulcorner bg - ypart llcorner bg; > > addto title also image( > fill unitsquare > xysized (tw + 8, th) > shifted ulcorner multipars[1] > shifted 28 right > shifted 8 down > withcolor white; > > draw > textext.drt( legend ) > shifted ulcorner multipars[1] > shifted 32 right > shifted 3 down; > ); > > addto border also image( > for i = 1 upto nofmultipars: > draw > llcorner multipars[i] -- > ulcorner multipars[i] shifted 8 down .. > ulcorner multipars[i] shifted 8 right -- > urcorner multipars[i] > withpen pencircle scaled 0.75 withcolor black; > endfor; > ); > > draw image( > draw border; > draw title; > ); > endgroup;\stopusableMPgraphic > \definetextbackground[TextConcurrentFrame][ > mp=GraphicConcurrent, > frame=off, > topoffset=1em, > leftoffset=1em, > location=paragraph, > ] > \definestartstop[concurrent][ > before={% > \blank[big]% > LEGEND: \xmlatt{\getvariable{div}{concurrent}}{data-title}% > \blank[big]% > \setMPtext{concurrent}{\xmlatt{\getvariable{div}{concurrent}}{data-title}} > \startTextConcurrentFrame}, > after={\stopTextConcurrentFrame\blank[big]}, > ] > \starttext > \xmlprocessbuffer{main}{demo}{}\stoptext > % EOT > > If I change the following line: > > legend := \MPstring{concurrent}; > > to: > > legend := "some string"; > > Then the title "some string" is repeated. It seems like the value for > \MPstring{concurrent} is being cached in some situations and ignored in > others. > > Essentially, I'm trying to visually offset multiple paragraphs using a > left-hand vertical rule along with a top horizontal rule that has a title. > Each new "concurrent" section needs its own header that doesn't repeat. > > Is there a ConTeXt-way to accomplish this feat? There's always a way out but not always a pretty one. One problem is that these graphics are done later, when a page gets assembled, so you get the current value at that time. Then there is grouping so you need to assign global. Now, there can be caching but you use expanded string so that's not the issue. % draw image ( draw rawtextext(legend) notcached) ; That is seldom needed. So below is a solution. When you cross pages with a frame you need to make sure the text is done once. I let you figure that out (after all you came this far so i guess you know). For historic reasons (mkii / performance) it's not the easiest mechanism. % We store each one independent: \newinteger\ConcurrentTextSetCounter \newinteger\ConcurrentTextGetCounter \protected\def\ConcurrentTextSet#1% {\global\advance\ConcurrentTextSetCounter\plusone \setxvariable {concurrent} {text:\the\ConcurrentTextSetCounter} {#1}} \def\ConcurrentTextGet % we want full expansion here {\localcontrolled{\global\advance\ConcurrentTextGetCounter\plusone}% \getvariable {concurrent} {text:\the\ConcurrentTextGetCounter}} % We also use the helpers (so at least we can see what we do): \startuseMPgraphic{GraphicConcurrent}{text} % % {mpos:region:draw} % draw_multi_pars ; string legend ; legend := "\ConcurrentTextGet"; show legend; % draw image ( draw rawtextext(legend) notcached) ; picture p ; p := textext.rt(legend) shifted ulcorner multipars[1] shifted (1cm,0) ; draw llcorner multipars[1] -- ulcorner multipars[1] -- ulcorner multipars[1] shifted (9mm,0) ; draw ulcorner multipars[1] shifted (1mm + xpart lrcorner p,0) -- urcorner multipars[1] ; draw p ; \stopuseMPgraphic % Watch how i moved the before/after blanks here: \definetextbackground [TextConcurrentFrame] [mp=GraphicConcurrent, % mp=mpos:region:draw, method=mpos:region, frame=off, topoffset=1em, leftoffset=1em, before=\blank[2*big], after=\blank, location=paragraph] % And use setups to get a nicer definition: \startsetups concurrent:before \ConcurrentTextSet{\xmlatt{\getvariable{div}{concurrent}}{data-title}} \startTextConcurrentFrame \stopsetups \startsetups concurrent:after \stopTextConcurrentFrame \stopsetups \definestartstop [concurrent] [before=\directsetup{concurrent:before}, after=\directsetup{concurrent:after}] One problem with variables is that currently we cannot bind a "current" value so I need to think a bit about it. Maybe the solution here, a bit more robust is one. One can actually pass variables with a graphic but again, these are then overwritten by a later one. In lmtx we have a few better tex-mp communication tricks but these are not yet documented in the manual. Contrary to mkii (intermediate as well as runtime processing) and mkiv (runtime two pass in a run processing) we can make some interfaces a bit simpler in mkxl but that happens stepwise because we need to remain compatible. Much of the positional graphic trickery is stil a bit mkii-ish in nature (where we had more mem and runtime constraints). 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 ___________________________________________________________________________________