public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Placing SVG inline in HTML generated from Markdown
@ 2020-08-13 17:03 James Hoyland
       [not found] ` <e12cd704-7d33-4762-8728-d9c7adaff13do-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: James Hoyland @ 2020-08-13 17:03 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1274 bytes --]

Hello all,
New to pandoc and loving it. So I am using it to generate HTML snippets 
from markdown to copy and paste in a learning management system (Moodle). 
Now this works, I can produce nice HTML, I can use MathJax and get 
equations in there, I can also link images which get base64 encoded - all 
works great. I need to use the base64 encoding because it's a pain to link 
the images as separate files from within Moodle. However one thing I'd like 
to do - I make diagrams in Inkscape and link the SVG files into the the 
Markdown, Pandoc also base64 encodes the SVG - at first I thought it was 
rasterizing them but I can right click download them from the website and 
they are still SVG just embedded as a base64 encoded image tag. I would 
prefer if pandoc took the SVG and just inlined it in the resulting HTML as 
an SVG tag. Is this possible?

James

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e12cd704-7d33-4762-8728-d9c7adaff13do%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 1611 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Placing SVG inline in HTML generated from Markdown
       [not found] ` <e12cd704-7d33-4762-8728-d9c7adaff13do-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-08-13 17:48   ` Albert Krewinkel
       [not found]     ` <87eeoa309r.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  2020-08-13 17:59   ` Gwern Branwen
  2020-08-16 17:48   ` John MacFarlane
  2 siblings, 1 reply; 6+ messages in thread
From: Albert Krewinkel @ 2020-08-13 17:48 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


James Hoyland writes:

> However one thing I'd like to do - I make diagrams in Inkscape
> and link the SVG files into the the Markdown, Pandoc also base64
> encodes the SVG - at first I thought it was rasterizing them but
> I can right click download them from the website and they are
> still SVG just embedded as a base64 encoded image tag. I would
> prefer if pandoc took the SVG and just inlined it in the
> resulting HTML as an SVG tag. Is this possible?

Giving my default answer here: that'd be doable with a pandoc
(Lua) filter: traverse all Image elements and check whether it
links to a SVG file. If it does, replace it with raw SVG code.
Pseudo code:

    function Image (img)
      if img.src:match '.*^.svg$' then
        local contents = io.open(img.src):read '*a'
        return pandoc.RawInline('html', contents)
      end
    end

This may be a little too simple as the SVG file might start with a
`<?xml ...?>` line, which should be removed. But that should be
only another line or two.

--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Placing SVG inline in HTML generated from Markdown
       [not found] ` <e12cd704-7d33-4762-8728-d9c7adaff13do-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-08-13 17:48   ` Albert Krewinkel
@ 2020-08-13 17:59   ` Gwern Branwen
  2020-08-16 17:48   ` John MacFarlane
  2 siblings, 0 replies; 6+ messages in thread
From: Gwern Branwen @ 2020-08-13 17:59 UTC (permalink / raw)
  To: pandoc-discuss

If Pandoc 'just' inlines the SVG, what specifies its size,
positioning, and so on? The point of SVG is that unlike raster
graphics, it's flexible and can be any size and scale and be
manipulated in many ways. Is there default Pandoc CSS which already
covers all of that?

-- 
gwern
https://www.gwern.net


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Placing SVG inline in HTML generated from Markdown
       [not found]     ` <87eeoa309r.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2020-08-13 18:35       ` James Hoyland
  0 siblings, 0 replies; 6+ messages in thread
From: James Hoyland @ 2020-08-13 18:35 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1729 bytes --]

Thanks! I guess  I will have to look into that - I have not used filters yet

James

On Thursday, 13 August 2020 10:48:25 UTC-7, Albert Krewinkel wrote:
>
>
> James Hoyland writes: 
>
> > However one thing I'd like to do - I make diagrams in Inkscape 
> > and link the SVG files into the the Markdown, Pandoc also base64 
> > encodes the SVG - at first I thought it was rasterizing them but 
> > I can right click download them from the website and they are 
> > still SVG just embedded as a base64 encoded image tag. I would 
> > prefer if pandoc took the SVG and just inlined it in the 
> > resulting HTML as an SVG tag. Is this possible? 
>
> Giving my default answer here: that'd be doable with a pandoc 
> (Lua) filter: traverse all Image elements and check whether it 
> links to a SVG file. If it does, replace it with raw SVG code. 
> Pseudo code: 
>
>     function Image (img) 
>       if img.src:match '.*^.svg$' then 
>         local contents = io.open(img.src):read '*a' 
>         return pandoc.RawInline('html', contents) 
>       end 
>     end 
>
> This may be a little too simple as the SVG file might start with a 
> `<?xml ...?>` line, which should be removed. But that should be 
> only another line or two. 
>
> -- 
> Albert Krewinkel 
> GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124 
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ccef867e-de59-4986-9e9e-b2b27e15c3d1o%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2353 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Placing SVG inline in HTML generated from Markdown
       [not found] ` <e12cd704-7d33-4762-8728-d9c7adaff13do-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-08-13 17:48   ` Albert Krewinkel
  2020-08-13 17:59   ` Gwern Branwen
@ 2020-08-16 17:48   ` John MacFarlane
       [not found]     ` <m2sgcmeb30.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  2 siblings, 1 reply; 6+ messages in thread
From: John MacFarlane @ 2020-08-16 17:48 UTC (permalink / raw)
  To: James Hoyland, pandoc-discuss


When you say pandoc base64 encodes the SVGs -- are you using
the --self-contained option?  Normally you'd just get a link
to an external image.

James Hoyland <hoyland.jd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hello all,
> New to pandoc and loving it. So I am using it to generate HTML snippets 
> from markdown to copy and paste in a learning management system (Moodle). 
> Now this works, I can produce nice HTML, I can use MathJax and get 
> equations in there, I can also link images which get base64 encoded - all 
> works great. I need to use the base64 encoding because it's a pain to link 
> the images as separate files from within Moodle. However one thing I'd like 
> to do - I make diagrams in Inkscape and link the SVG files into the the 
> Markdown, Pandoc also base64 encodes the SVG - at first I thought it was 
> rasterizing them but I can right click download them from the website and 
> they are still SVG just embedded as a base64 encoded image tag. I would 
> prefer if pandoc took the SVG and just inlined it in the resulting HTML as 
> an SVG tag. Is this possible?
>
> James
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e12cd704-7d33-4762-8728-d9c7adaff13do%40googlegroups.com.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Placing SVG inline in HTML generated from Markdown
       [not found]     ` <m2sgcmeb30.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-08-16 18:25       ` James Hoyland
  0 siblings, 0 replies; 6+ messages in thread
From: James Hoyland @ 2020-08-16 18:25 UTC (permalink / raw)
  To: John MacFarlane; +Cc: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 2382 bytes --]

Yes I'm using self contained. I'm doing this because I want to avoid links.
The method for uploading and linking to images in Moodle is awkward to say
the least so having a single block of HTML to copy and paste into the
editor is a real time saver.

James

On Sun, Aug 16, 2020, 10:48 AM John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:

>
> When you say pandoc base64 encodes the SVGs -- are you using
> the --self-contained option?  Normally you'd just get a link
> to an external image.
>
> James Hoyland <hoyland.jd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > Hello all,
> > New to pandoc and loving it. So I am using it to generate HTML snippets
> > from markdown to copy and paste in a learning management system
> (Moodle).
> > Now this works, I can produce nice HTML, I can use MathJax and get
> > equations in there, I can also link images which get base64 encoded -
> all
> > works great. I need to use the base64 encoding because it's a pain to
> link
> > the images as separate files from within Moodle. However one thing I'd
> like
> > to do - I make diagrams in Inkscape and link the SVG files into the the
> > Markdown, Pandoc also base64 encodes the SVG - at first I thought it was
> > rasterizing them but I can right click download them from the website
> and
> > they are still SVG just embedded as a base64 encoded image tag. I would
> > prefer if pandoc took the SVG and just inlined it in the resulting HTML
> as
> > an SVG tag. Is this possible?
> >
> > James
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "pandoc-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/e12cd704-7d33-4762-8728-d9c7adaff13do%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAMcTw6Nys6Ed3%3Dd-iWUAjhuHM63VmOoX_pyoVN22%3DB3hZp_5mw%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 3523 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-16 18:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 17:03 Placing SVG inline in HTML generated from Markdown James Hoyland
     [not found] ` <e12cd704-7d33-4762-8728-d9c7adaff13do-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-08-13 17:48   ` Albert Krewinkel
     [not found]     ` <87eeoa309r.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-08-13 18:35       ` James Hoyland
2020-08-13 17:59   ` Gwern Branwen
2020-08-16 17:48   ` John MacFarlane
     [not found]     ` <m2sgcmeb30.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-08-16 18:25       ` James Hoyland

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).