# [NTG-context] removing # in XML identifiers

Pablo Rodriguez oinos at gmx.es
Thu May 7 20:16:01 CEST 2015

On 05/06/2015 10:49 PM, Thomas A. Schmitz wrote:
> On 05/06/2015 09:38 PM, Pablo Rodriguez wrote:
>> How could I get the following command working?
>>
>>      \ctxlua{tex.print(string.sub(context("\\xmlatt{#1}{href}"),2))}
>
> I'm not sure that this will ever work - you're mixing and nesting lua
> and tex code in a messy way. My suggestion would be: if you need to
> process your xml code with lua, then process things in lua and separate
> the lua part from your tex code. Write a function xml.functions.a which
> does the substring split and the printing to context. I have written a
> page on the wiki http://wiki.contextgarden.net/XML_Lua which may be useful.

I have tried the following:

\startxmlsetups xml:a
\startluacode
function xml.functions.removehash(str)
tex.print(string.sub(str,2))
end
\stopluacode
\unexpanded\def\removehash#1%
{\ctxlua{xml.functions.removehash("#1")}}
\startasciimode\removehash{\xmlatt{#1}{href}}\stopasciimode
\stopxmlsetups

But for some reason unknown to me, it doesn’t work. It works on a
standard file, but now there.

What am I missing?