ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Thomas A. Schmitz via ntg-context" <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: "Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de>
Subject: Xml - lua - context
Date: Mon, 28 Mar 2022 15:32:10 +0200	[thread overview]
Message-ID: <BBC48A7B-8561-4DF6-ACBF-971DC0C333FD@uni-bonn.de> (raw)

Dear all,

For a small project, I have two questions (without MWE…) on processing xml via Lua and context. I’ll write two messages so eager volunteers can reply more easily!

So question one: given an xml structure like this

  <section>
    <sectiontitle>
      Introduction: the <em>Iliad</em>
    </sectiontitle>
    <sectionlist>
      Introduction: the <em>Iliad</em>
    </sectionlist>
  </section>

I want to typeset the section title with some added information. Since I’m processing in a loop, I thought this would be easier in Lua, so I have something like this:

local i = 0

local sessions = { “April 2”, “April 9”, “April 16” } -- etc.

function xml.functions.section(t)
	i = i + 1
	local raw_section = xml.text (t, "/sectiontitle")
	local section_head = i .. ". session, " .. sessions [i] .. ": " .. raw_section
	context.startsection { title=section_head }
	lxml.flush (t)
	context.stopsection ()
end

However, this means that the section_head is serialized as a string and not processed according to the xml setups, so I have “the <em>Iliad</em>” in my typeset document. How can this be avoided? How can I have the <em>...</em> processed instead of serialized in the section title? 

Thanks for looking at my code!

Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

             reply	other threads:[~2022-03-28 13:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 13:32 Thomas A. Schmitz via ntg-context [this message]
2022-03-28 13:40 Xml - Lua " Thomas A. Schmitz via ntg-context
2022-03-28 16:21 ` Adam Reviczky via ntg-context
2022-03-28 17:06   ` Thomas A. Schmitz 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=BBC48A7B-8561-4DF6-ACBF-971DC0C333FD@uni-bonn.de \
    --to=ntg-context@ntg.nl \
    --cc=thomas.schmitz@uni-bonn.de \
    /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).