piever / Remark.jl

Create markdown presentations from Julia
Other
94 stars 14 forks source link

unexpected xml tag `<?xml version="1.0" encoding="utf-8"?>` occurs #32

Closed terasakisatoshi closed 4 years ago

terasakisatoshi commented 4 years ago

<?xml version="1.0" encoding="utf-8"?> occurs when I insert code related to gr backend Plots

using Plots
gr() # switch to GR backend
plot(sin)

image

on the other hand, when I switch to pyplot backend I get no issue. 🤔

piever commented 4 years ago

Thanks for reporting this! Somehow the svg generated by GR also includes that xml tag, which does not appear in html files, but markdown gets confused with it.

I wonder where this should be fixed exactly, maybe at GR?

piever commented 4 years ago

A better solution to this would probably be to implement something like https://github.com/piever/Remark.jl/issues/22, and during the build step saving the svg to a file rather than directly into the generated html.

terasakisatoshi commented 4 years ago
using Plots
gr()
x = -Ï€:0.01:Ï€
p1 = plot(x, cos.(x))
p2 = plot(x, sin.(x))
plot(p1, p2, layout=(2,1))
savefig("saved.png") #hide

# ![not found](saved.png)

The result should be as follow:

Screenshot from 2020-04-14 03-18-26

terasakisatoshi commented 4 years ago

I've confirmed the workaround above solves my problem:

piever commented 4 years ago

Thanks for verifying that it works! I think this should be the preferred approach anyways, I'll add it to the docs.