ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Map XML attributes to variables, dynamically
@ 2023-08-10  7:10 Thangalin
  2023-08-10  7:43 ` [NTG-context] " Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Thangalin @ 2023-08-10  7:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-10  8:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-10  7:10 [NTG-context] Map XML attributes to variables, dynamically Thangalin
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

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).