SVG :: CoreSVG vs Webkit (and fenced SVG source ?)

Viewed 8

Rendering SVG text and span elements

I notice that path elements of SVG source are rendering well, but text and span elements are lost. Might this suggest that SVG rendering is being handled by CoreSVG rather than the full WebKit renderer ?

Option to render fenced SVG (like fenced Mermaid) ?

I'm finding it helpful, in WriteRoom 4.0 (412+) to enable rendering both fenced Mermaid source, and fenced SVG source, as images.

I think WriteRoom may be using the full Webkit renderer for this, as text and tspan elements are displaying correctly.

( see attached .textpack which renders fully in WriteRoom 4 (412) )

Might it look feasible, in Marked 3 to:

  1. Render text and span elements in SVG
  2. Allow an option to render fenced, as well as raw, SVG source ?

fencedSVGandMermaid.textpack.zip

As rendered in WriteRoom 4 (412+)
writeroom.png

1 Answers

Fenced SVGs yes, for next update.

But you have the SVG rendering backwards, I think. WriteRoom renders its SVGs. As best I can figure out:

Those objects are painted by resvg 0.48.1 (and its parser, usvg). resvg lays out and itself, with its own font stack (fontdb, skrifa), and draws into a Core Graphics context. It never goes through CoreSVG. A mermaid fence is compiled first by the Rust crate bezel-mermaid 0.2.20, which emits SVG, and that SVG takes the same resvg path. A fence that fails to render stays as source.

I can look into doing some custom rendering like that, and also into why my (older) version of WebKit is stripping text/rspan tags. Will keep you posted.

(I also like the Mermaid mind map style from WriteRoom way better than what's in Marked, so if I figure out how to generate my own SVGs, I might try to borrow that.)