GuntherRademacher / rr

RR - Railroad Diagram Generator
Apache License 2.0
483 stars 49 forks source link

Do not generate duplicated svg styles #9

Closed mingodad closed 1 year ago

mingodad commented 3 years ago

It seems that is possible to not emit the same style in each svg and still been able to view it correctly, saving around 1/4 of the actual xhtml.

---------- src/main/resources/de/bottlecaps/railroad/xq/ast-to-svg.xq ----------
@@ -1053,7 +1054,6 @@ declare function s:convert-to-svg($p as element(g:production), $page-width as xs
     <svg xmlns="http://www.w3.org/2000/svg"
          xmlns:xlink="http://www.w3.org/1999/xlink"
          width="{$width + 1}" height="{$height + 1}">
-      <defs>{s:style($color, $spread)}</defs>
       {
         s:translate(1 - xs:integer($dimensions/@x1), 1 - xs:integer($dimensions/@y1), $rendered)
       }
manticore-projects commented 1 year ago

Greetings. I have tried that and it works. Replacing with a reference to a CSS file seems to be another option.

GuntherRademacher commented 1 year ago

Yes, that works. But it is not quite sufficient. The conversion to HTML+PNG and MD (not advertised) relies on the fact that the XHTML brings self-contained SVGs. So that has to be adapted as well.

GuntherRademacher commented 1 year ago

Now fixed in v1.65.

mingodad commented 1 year ago

Thank you ! There are any news in opensourcing of convert and https://www.bottlecaps.de/rex/ ?

GuntherRademacher commented 1 year ago

There are any news in opensourcing of convert and https://www.bottlecaps.de/rex/ ?

Not my main focus at the moment. To come one day

mingodad commented 1 year ago

Again thank you !