1

Background

Include an external SVG image from an HTML img element, using ConTeXt LMTX.

Code

Here's main.tex:

\startbuffer[document]
<body><img src="circle.svg"/></body>
\stopbuffer

\startxmlsetups xml:xhtml
  \xmlsetsetup{\xmldocument}{body|img}{xml:*}
\stopxmlsetups

\startxmlsetups xml:body
  \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:img
  \placefigure{}{\externalfigure[circle.svg][conversion=mp]}
\stopxmlsetups

\xmlregistersetup{xml:xhtml}

\starttext
  \xmlprocessbuffer{xhtml}{document}{}
\stoptext

Here's circle.svg:

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<g><circle cx="50" cy="50" r="20"/></g>
</svg>

Problem

When compiled using context main.tex, the PDF does not show a circle:

Missing image

Question

How do you make the circle appear, rather than what appears to be unexecuted commands? (Without using Inkscape to convert the image.)

0

1 Answer 1

1

From the mailing-list, wrap the figures in texcode:

\startxmlsetups xml:img
  \starttexcode
    \placefigure{}{%
      \externalfigure[\xmlatt{#1}{src}][conversion=mp]%
    }
  \stoptexcode
\stopxmlsetups

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.