* TeX control sequence inside XML param
@ 2005-01-27 9:45 Vit Zyka
2005-01-27 11:53 ` Hans Hagen
0 siblings, 1 reply; 5+ messages in thread
From: Vit Zyka @ 2005-01-27 9:45 UTC (permalink / raw)
Hallo,
it is possible to use TeX control sequence inside XML param? How?
Example:
<figure file="file.pdf" width=".45\textwidth" />
^^^^^^^^^^
\defineXMLenvironment[figure][file=,width=]
{}
{\externalfigure[\XMLop{file}][width=\XMLop{width}]}
Thank you
Vit Zyka
----------------------------------------------
Error message (from a bit complex source):
! Missing \endcsname inserted.
<to be read again>
\texescape
\XML:ent:tex-backslash ...kslash \else \texescape
\fi
\param:1 ->width=.45\getXMLentity {tex-backslash}
textwidth
\getvalue #1->\csname #1
\endcsname
\calculateexternalfigure ...guresvg #1[#4][#5][#6]
\doifsomething
\@@efmaxwid...
<argument> ...dummy ][\filewithpath ][\param ][][]
\calculateexternalscreenfi...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TeX control sequence inside XML param
2005-01-27 9:45 TeX control sequence inside XML param Vit Zyka
@ 2005-01-27 11:53 ` Hans Hagen
2005-01-27 15:54 ` Vit Zyka
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2005-01-27 11:53 UTC (permalink / raw)
Vit Zyka wrote:
> Hallo,
>
> it is possible to use TeX control sequence inside XML param? How?
> Example:
>
> <figure file="file.pdf" width=".45\textwidth" />
> ^^^^^^^^^^
> \defineXMLenvironment[figure][file=,width=]
> {}
> {\externalfigure[\XMLop{file}][width=\XMLop{width}]}
Hm. You're lucky. We should make a test suite (at the wiki) to make sure that
this kind of stuff keeps working -)
\starttext
\defineXMLentity[ctx-var-textwidth] {\textwidth}
\defineXMLcommand[test][width=\textwidth]
{\the\dimexpr\XMLop{width}\relax}
\startXMLdata
<test width=".45&ctx-var-textwidth;"/>
<test width="&ctx-var-textwidth;"/>
\stopXMLdata
\stoptext
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TeX control sequence inside XML param
2005-01-27 11:53 ` Hans Hagen
@ 2005-01-27 15:54 ` Vit Zyka
2005-01-28 17:18 ` Hans Hagen
0 siblings, 1 reply; 5+ messages in thread
From: Vit Zyka @ 2005-01-27 15:54 UTC (permalink / raw)
Hans Hagen wrote:
> Vit Zyka wrote:
>
>> Hallo,
>>
>> it is possible to use TeX control sequence inside XML param? How?
>> Example:
>>
>> <figure file="file.pdf" width=".45\textwidth" />
>> ^^^^^^^^^^
>> \defineXMLenvironment[figure][file=,width=]
>> {}
>> {\externalfigure[\XMLop{file}][width=\XMLop{width}]}
>
>
> Hm. You're lucky. We should make a test suite (at the wiki) to make sure
> that this kind of stuff keeps working -)
>
> \starttext
>
> \defineXMLentity[ctx-var-textwidth] {\textwidth}
I seeee! I might come to me... Actually I'd like to solve a bit more
complex task:
\starttext
\defineXMLentity[ctx-var-textwidth] {\textwidth}
\newcount\FigNo
\defineXMLenvironment[float][]
{\defineXMLpush[caption]%
\global\FigNo=0
}
{\placefigure{\XMLflush{caption}}%
{\dorecurse{\FigNo}%
{\edef\filewithpath{\XMLpop{dir-fig}\getvalue{file:\recurselevel}}%
\edef\param{\getvalue{param:\recurselevel}}%
\externalfigure[\filewithpath][\param]}}%
}
\defineXMLenvironment[figure][file=,context=]
{}
{\global\advance\FigNo by1 %
\expanded{\setvalue{file:\the\FigNo}{\XMLop{file}}}%
\expanded{\setvalue{param:\the\FigNo}{\XMLop{context}}}%
}
\startXMLdata
<float>
<figure file="cow.pdf" context="width=.5&ctx-var-textwidth;" />
<figure file="hacker.jpg" context="width=3cm" />
<caption>Cow and hacker.</caption>
</float>
\stopXMLdata
\stoptext
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TeX control sequence inside XML param
2005-01-27 15:54 ` Vit Zyka
@ 2005-01-28 17:18 ` Hans Hagen
2005-01-31 9:30 ` Vit Zyka
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2005-01-28 17:18 UTC (permalink / raw)
Vit Zyka wrote:
> I seeee! I might come to me... Actually I'd like to solve a bit more
> complex task:
some day ...
> \externalfigure[\filewithpath][\param]}}%
you need to expand the parameters
\expanded{\external...[...][...]}
food for thought ... (and the wiki)
\starttext
\useMPlibrary[dum]
\defineXMLentity[ctx-var-textwidth] {\textwidth}
\defineXMLenvironmentsave
[float]
{\bgroup
\defineXMLsave[caption]%
\defineXMLignore[figure]}
{\XMLflush{float}%
\defineXMLignore
[caption]
\defineXMLcommand
[figure]
[file=dummy,context=]
{\expanded{\externalfigure
[\XMLflush{dir-fig}\XMLop{file}][\XMLop{context}]}%
\kern1em
\ignorespaces}%
\placefigure
{\XMLflush{caption}}
{\hbox{\ignorespaces\XMLflush{float}\removeunwantedspaces}}%
\egroup}
\startXMLdata
<float>
<figure file="cow.pdf" context="width=.5&ctx-var-textwidth;" />
<figure file="hacker.jpg" context="width=3cm" />
<caption>Cow and hacker.</caption>
</float>
\stopXMLdata
\stoptext
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TeX control sequence inside XML param
2005-01-28 17:18 ` Hans Hagen
@ 2005-01-31 9:30 ` Vit Zyka
0 siblings, 0 replies; 5+ messages in thread
From: Vit Zyka @ 2005-01-31 9:30 UTC (permalink / raw)
Hans Hagen wrote:
> Vit Zyka wrote:
>
> \startXMLdata
> <float>
> <figure file="cow.pdf" context="width=.5&ctx-var-textwidth;" />
> <figure file="hacker.jpg" context="width=3cm" />
> <caption>Cow and hacker.</caption>
> </float>
> \stopXMLdata
>
> food for thought ... (and the wiki)
That is a clever solution! This two pass tag processing. I have not been
thinking this way yet. Thank you, Hans. (Wiki:
http://contextgarden.net/Two_pass_tag_processing_example)
Unfortunately I have next two problems:
1) How to process <pre> HTML tag. I have tried many solution derived from
-----
\starttext
\defineXMLenvironment[pre]
{\starttyping}
{\stoptyping}
\startXMLdata
<pre>
Some code line.
And another one.
</pre>
\stopXMLdata
\stoptext
-----
but without success.
2) It seems to me there is some catcode clash inside XML environment:
-----
\defineXMLentity[hyphen]{|_|}
\starttext
dojde|_|li
\startXMLdata
dojde‐li
\stopXMLdata
\stoptext
------
Vit Zyka
> \starttext
>
> \useMPlibrary[dum]
>
> \defineXMLentity[ctx-var-textwidth] {\textwidth}
>
> \defineXMLenvironmentsave
> [float]
> {\bgroup
> \defineXMLsave[caption]%
> \defineXMLignore[figure]}
> {\XMLflush{float}%
> \defineXMLignore
> [caption]
> \defineXMLcommand
> [figure]
> [file=dummy,context=]
> {\expanded{\externalfigure
> [\XMLflush{dir-fig}\XMLop{file}][\XMLop{context}]}%
> \kern1em
> \ignorespaces}%
> \placefigure
> {\XMLflush{caption}}
> {\hbox{\ignorespaces\XMLflush{float}\removeunwantedspaces}}%
> \egroup}
>
>
> \startXMLdata
> <float>
> <figure file="cow.pdf" context="width=.5&ctx-var-textwidth;" />
> <figure file="hacker.jpg" context="width=3cm" />
> <caption>Cow and hacker.</caption>
> </float>
> \stopXMLdata
>
> \stoptext
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-01-31 9:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-27 9:45 TeX control sequence inside XML param Vit Zyka
2005-01-27 11:53 ` Hans Hagen
2005-01-27 15:54 ` Vit Zyka
2005-01-28 17:18 ` Hans Hagen
2005-01-31 9:30 ` Vit Zyka
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).