Umberto
Umberto

Reputation: 1421

github svg not rendering at all

I am trying to create a markdown file in GitHub and would like to put an SVG image in it. GitHub is not rendering the image at all. I tried with <img />, with ![](). Is simply not working!

Just modified the repository so that is public: https://github.com/michelucci/deepbook

Upvotes: 6

Views: 5485

Answers (3)

VonC
VonC

Reputation: 1329722

Update 2022: a simple drag & drop is enough.


Original answer (2017)

See issue 458 regarding any inline HTML, but since it is not your issue, you can compare your page to this one: it does display a lot of svg pictures, and its source is here.

"source": [
    "## Python Objects\n",
    "\n",
    "We begin with a look at a Python object. In Python, objects are stored in memory blocks independently allocated on the heap. A single floating point value looks something like this:\n",
    "\n",
    "![Python Float](fig/python_float.svg)\n",
    "\n",
    "This doesn’t look too bad, in a dynamically typed system we need to store some metadata about the type, and we need to store the data containing the value."
   ]
  },

So relative URL (to docs/intro-01/fig) does work.

Your code:

   "source": [
    " ![](neuron_fig1.svg) \n",
    " **Fig. 1** The structure of a neuron. $x_i$ are the input, $w_i$ are the weights."
   ]

Upvotes: 0

nteissler
nteissler

Reputation: 1581

It seems like GitHub now requires the http query parameters sanitize=true at the end of the SVG string. If you're linking to an image in your repository from a wiki, you may already have parameters at the end of the URL. So either add ?sanitize=true if there are no query parameters, or &sanitize=true otherwise

<img alt="my image" src="https://raw.githubusercontent.com/user/branch/images/myimage.svg?example=foo&sanitize=true>

Upvotes: 1

Mureinik
Mureinik

Reputation: 312289

GitHub's markdown seems to be blocking SVG files, but you can always use bare HTML tags:

<img src="neuron_fig1.svg"/>

Upvotes: 1

Related Questions