@@ -7,13 +7,14 @@ def call
77 css ( '.rightsidebar' , 'hr' , '.sh_mark' , '.fancy_toc > a' , '.fancy_toc_mark' , 'h[style*="none"]' ,
88 'a[href$="intro.html"] > h2' , 'a[href$="intro"] > h2' , '#document_title + #toc_header' ,
99 '#document_title ~ #toc' ) . remove
10+ css ( 'a[href$="intro.html"]:empty' , 'a[href$="intro"]:empty' ) . remove
1011
1112 css ( '.fancy_title' , '> h2[align=center]' , '#document_title' ) . each do |node |
1213 node . name = 'h1'
1314 end
1415
1516 unless at_css ( 'h1' )
16- if at_css ( 'h2' ) . content == context [ :html_title ]
17+ if at_css ( 'h2' ) && at_css ( 'h2' ) . content == context [ :html_title ]
1718 at_css ( 'h2' ) . name = 'h1'
1819 else
1920 doc . child . before ( "<h1>#{ context [ :html_title ] } </h1>" )
@@ -81,8 +82,26 @@ def call
8182 node . remove_attribute ( 'onclick' )
8283 end
8384
84- css ( '*[align]' ) . remove_attr ( 'align' )
85+ css ( 'svg *[style], svg *[fill]' ) . each do |node |
86+ # transform style in SVG diagrams, e.g. on https://sqlite.org/lang_insert.html
87+ if node [ 'style' ] == 'fill:rgb(0,0,0)' or node [ 'fill' ] == 'rgb(0,0,0)'
88+ node . add_class ( 'fill' )
89+ node . remove_attribute ( 'fill' )
90+ elsif node [ 'style' ] == 'fill:none;stroke-width:2.16;stroke:rgb(0,0,0);'
91+ node . add_class ( 'stroke' )
92+ elsif node [ 'style' ] == 'fill:none;stroke-width:3.24;stroke:rgb(211,211,211);'
93+ node . add_class ( 'stroke' )
94+ elsif node [ 'style' ]
95+ raise NotImplementedError , "SVG style #{ node [ 'style' ] } "
96+ end
97+ node . remove_attribute ( 'style' )
98+ end
99+
100+ css ( '.imgcontainer > div[style]' ) . add_class ( 'imgcontainer' )
85101 css ( '*[style]:not(.imgcontainer)' ) . remove_attr ( 'style' )
102+ css ( '.imgcontainer' ) . remove_class ( 'imgcontainer' )
103+
104+ css ( '*[align]' ) . remove_attr ( 'align' )
86105 css ( 'table[border]' ) . remove_attr ( 'border' )
87106
88107 doc
0 commit comments