TeX control sequence inside XML param
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...
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 -----------------------------------------------------------------
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
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 -----------------------------------------------------------------
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
participants (2)
-
Hans Hagen
-
Vit Zyka