From: Thangalin <thangalin@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: [NTG-context] Map XML attributes to variables, dynamically
Date: Thu, 10 Aug 2023 00:10:58 -0700 [thread overview]
Message-ID: <CAANrE7qGC=urT4az6jSthrk1X2hbPJL-7xycPQYyYEv=mS=j-Q@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1563 bytes --]
Hello!
A Markdown document resembles the following:
::: {.concurrent title="Berth 5" location="San Diego"}
Text Goes Here
:::
::: {.concurrent title="Road" location="Beale AFB"}
Different Text Goes Here
:::
The XHTML generated from that document resembles:
<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>
Environments for the DIV element gets translated using:
\startxmlsetups xml:div
\start[\xmlatt{#1}{class}]\xmlflush{#1}\stop
\stopxmlsetups
This creates "\startconcurrent" and "\stopconcurrent", which are later
defined using "\definestartstop[concurrent]".
I'd like to dynamically define all the data- attributes to make key/value
pairs accessible from the document. For example, I have this:
\definestartstop[concurrent][
before={%
\blank[big]%
\setMPtext{1}{Berth 5}%
\startTextConcurrentFrame},
after={\stopTextConcurrentFrame\blank[big]},
]
I'd like to replace \setMPText calls with a reference to a dynamically
created variable reference. For example:
\setMPtext{1}{\usermap[concurrent.title]}
\setMPtext{2}{\usermap[concurrent.location]}
I can verify the attribute values exist by exporting them to the document:
\startxmlsetups xml:div
title:\xmlatt{#1}{data-title} location:\xmlatt{#1}{data-location}
\start[\xmlatt{#1}{class}]\xmlflush{#1}\stop
\stopxmlsetups
How would you change the xml:div setup to create a map of its attributes as
key/value pairs?
Thank you!
[-- Attachment #1.2: Type: text/html, Size: 2296 bytes --]
[-- Attachment #2: 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-10 7:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 7:10 Thangalin [this message]
2023-08-10 7:43 ` [NTG-context] " Hans Hagen
2023-08-10 8:14 ` Thangalin
2023-08-10 8:37 ` Hans Hagen
2023-08-10 8:50 ` Hans Hagen via ntg-context
2023-08-10 8:55 ` 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='CAANrE7qGC=urT4az6jSthrk1X2hbPJL-7xycPQYyYEv=mS=j-Q@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).