* SVG images inside XML setups
@ 2021-03-09 6:29 Thangalin
2021-03-09 8:58 ` Hans Hagen
0 siblings, 1 reply; 3+ messages in thread
From: Thangalin @ 2021-03-09 6:29 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
\xmlregistersetup{xml:xhtml}
\starttext
\xmlprocessbuffer{xhtml}{document}{}
\placefigure{}{\externalfigure[circle.svg][conversion=mp]}
\placefigure{}{\externalfigure[diagram.svg][conversion=mp]}
\stoptext
% EOF
Save the contents of "\startbuffer[csvg]" to a file named
"circle.svg", to create a valid, external SVG file.
Copy "circle.svg" to a file named "diagram.svg" to create a second
valid, external SVG file.
Run: context main.tex
Expected
All the SVG images appear.
Actual
Figures 1, 2, and 4 show only the following text:
\includesvgfile[circle.svg]\resetbuffer[svg-circle-inclusion]
In contrast, consider the following document:
% SOF
\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
\starttext
\placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
\placefigure{}{\externalfigure[circle.svg][conversion=mp]}
\placefigure{}{\externalfigure[diagram.svg][conversion=mp]}
\stoptext
% EOF
All the images appear as expected.
Any idea why using XML setups appears to affect the behaviour of
rendering SVG documents using MetaPost?
Thank you!
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: SVG images inside XML setups
2021-03-09 6:29 SVG images inside XML setups Thangalin
@ 2021-03-09 8:58 ` Hans Hagen
2021-03-09 16:15 ` Thangalin
0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2021-03-09 8:58 UTC (permalink / raw)
To: mailing list for ConTeXt users, Thangalin
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-09 16:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 6:29 SVG images inside XML setups Thangalin
2021-03-09 8:58 ` Hans Hagen
2021-03-09 16:15 ` Thangalin
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).