JuliaDocs / Documenter.jl

A documentation generator for Julia.
https://documenter.juliadocs.org
MIT License
810 stars 478 forks source link

Suppress writing of XML declarations #1303

Open kimikage opened 4 years ago

kimikage commented 4 years ago

In case of HTML output format, SVG images can be embedded as outputs of @example blocks and so on. However, show(io::IO, ::MIME"image/svg+xml", object) may write an XML declaration. In most major web browsers, such invalid XML declarations have no effect on the rendering, but they may cause warnings.

There are roughly two possible measures:

  1. Temporarily write the output to a buffer and then strip the XML declaration
  2. Suppress show method from printing the XML declaration

The former is a straightforward method, but it is not efficient. The latter is more efficient, but currently there are no interfaces for the suppression. Therefore I suggested defining a new IOContext property. (See: https://github.com/JuliaLang/julia/issues/35586)

If the latter approach (2.) works, there are two possible strategies.

Any thoughts?

mortenpi commented 4 years ago

Two brief thoughts on the Documenter side of this:

kimikage commented 4 years ago

I believe removing XML declarations is not an urgent task. If we decide to implement it, I'm not sure which layer should do it. (So, I cannot submit the PR immediately.:sweat_smile:)