Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed SVG code inside jekyll markdown (on Github)?

Tags:

svg

jekyll

Naively I thought it would be easy to just add <svg> tag with content in my post.md page, like this:

---
published: true
title: Embeded SVG
---
## title

<svg width="400" height=300>
    <circle cx="150" cy="100" r="10" fill="blue"/>
</svg>

But instead of the image being displayed, I see the SVG code displayed (in Firefox). So far did not found any solution to what looks like a simple thing. Is it possible within jekyll / liquid markdown ?

Note: I read include an SVG (hosted on github) in MarkDown, but:

  • I want to manipulate the svg code with d3.js latter, so I am assuming that I need to embed the SVG code, not reference it as an external image file.

  • I could generate the initial svg content directly with d3.js (this works), but this would prevent anything to be displayed in case javascript is disabled...

like image 624
yves Avatar asked May 20 '26 03:05

yves


1 Answers

You can disable kramdown specifically for your svg :

{::nomarkdown}
<svg width="400" height=300>
    <circle cx="150" cy="100" r="10" fill="blue"/>
</svg>
{:/}
like image 138
David Jacquel Avatar answered May 24 '26 02:05

David Jacquel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!