From: Thangalin <thangalin@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: [NTG-context] Pass string into text background graphic
Date: Fri, 11 Aug 2023 12:57:48 -0700 [thread overview]
Message-ID: <CAANrE7rTZ5-PEeF4Zn82=wjAn52Z_Pkzf-3BgCh21wc=Q4rqPA@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 3250 bytes --]
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]
<html>
<body>
<div class="concurrent" data-title="Berth 5" data-location="San Diego">
Text Goes Here
</div>
<div class="concurrent" data-title="Road" data-location="Beale AFB">
Different Text Goes Here
</div>
</body>
</html>\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?
Cheers!
[-- Attachment #1.2: Type: text/html, Size: 6166 bytes --]
[-- Attachment #2: t.pdf --]
[-- Type: application/pdf, Size: 7781 bytes --]
[-- Attachment #3: Type: text/plain, Size: 495 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 reply other threads:[~2023-08-11 19:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 19:57 Thangalin [this message]
2023-08-11 21:53 ` [NTG-context] " Hans Hagen
2023-08-12 17:19 ` Thangalin
2023-08-12 20:04 ` Hans Hagen via ntg-context
2023-08-13 19:33 ` Thangalin
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='CAANrE7rTZ5-PEeF4Zn82=wjAn52Z_Pkzf-3BgCh21wc=Q4rqPA@mail.gmail.com' \
--to=thangalin@gmail.com \
--cc=ntg-context@ntg.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).