[NTG-context] Xml - lua - context

Thomas A. Schmitz thomas.schmitz at uni-bonn.de
Mon Mar 28 15:32:10 CEST 2022

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

      Introduction: the <em>Iliad</em>
      Introduction: the <em>Iliad</em>

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

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!


More information about the ntg-context mailing list