[NTG-context] SVG images inside XML setups

Hans Hagen j.hagen at xs4all.nl
Tue Mar 9 09:58:26 CET 2021


On 3/9/2021 7:29 AM, Thangalin wrote:
> Here's a fairly minimal example showing an issue, using ConTeXt LMTX.
> Save the following as "main.tex":
> 
> % SOF
> \startbuffer[document]
> <body><img src="circle.svg"/></body>
> \stopbuffer
> 
> \startbuffer[csvg]
> <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
> <g><circle cx="50" cy="50" r="20"/></g>
> </svg>
> \stopbuffer
> 
> \startxmlsetups xml:xhtml
>    \xmlsetsetup{\xmldocument}{body|img}{xml:*}
> \stopxmlsetups
> 
> \startxmlsetups xml:body
>    \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:img
>    \placefigure{}{\externalfigure[\xmlatt{#1}{src}][conversion=mp]}
>    \placefigure{}{\externalfigure[circle.svg][conversion=mp]}
>    \placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
> \stopxmlsetups

\startxmlsetups xml:img
     \starttexcode
         \placefigure{}{\externalfigure[\xmlatt{#1}{src}][conversion=mp]}
         \placefigure{}{\externalfigure  [circle.svg][conversion=mp]}
         \placefigure{}{\includesvgbuffer[csvg]      [conversion=mp]}
     \stoptexcode
\stopxmlsetups


I probably need to add that wrapper in a few spots but in general if you 
can use that in case of issues. It has to do with catcodes, chicken and 
eggs.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list