Class: SiSU_XML_Docbook_Book::Source::Scroll
- Inherits:
-
SiSU_XML_Docbook_Book::Source
- Object
- SiSU_XML_Docbook_Book::Source
- SiSU_XML_Docbook_Book::Source::Scroll
- Defined in:
- lib/sisu/xml_docbook5.rb
Instance Method Summary collapse
- #adjust_output(o, ocn, filename_docbook, splv) ⇒ Object
- #code_output(o, ocn, filename_docbook) ⇒ Object
-
#collapsed ⇒ Object
collapsed –>.
- #docbook_tag(lc, chlv = '') ⇒ Object
-
#document_images ⇒ Object
tail.
- #head ⇒ Object
-
#initialize(data = '', md = '') ⇒ Scroll
constructor
A new instance of Scroll.
- #markup_text(data) ⇒ Object
- #output(o, comment = '') ⇒ Object
- #put(line) ⇒ Object
- #songsheet ⇒ Object
- #spaces ⇒ Object
- #structure_build_collapsed(data) ⇒ Object
- #structure_build_tag_close(lc, h) ⇒ Object
- #structure_collapsed(data) ⇒ Object
- #tags ⇒ Object
- #tail ⇒ Object
-
#xml_head ⇒ Object
def chapterlevel end.
Methods inherited from SiSU_XML_Docbook_Book::Source
Constructor Details
#initialize(data = '', md = '') ⇒ Scroll
Returns a new instance of Scroll.
121 122 123 124 125 126 127 |
# File 'lib/sisu/xml_docbook5.rb', line 121 def initialize(data='',md='') @data,@md=data,md @trans=SiSU_XML_Munge::Trans.new(md) @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(md.opt) @env=@particulars.env @make ||=SiSU_Env::ProcessingSettings.new(md) end |
Instance Method Details
#adjust_output(o, ocn, filename_docbook, splv) ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/sisu/xml_docbook5.rb', line 241 def adjust_output(o,ocn,filename_docbook,splv) if o.obj =~/#{Xx[:split]}/ outs=o.obj.split(/#{Xx[:split]}/) outs.each do |out| if out =~/<figure id=/m out=out.gsub(/:spaces0:/m, %{#{spaces*(splv)}#{spaces}}). gsub(/:spaces1:/m, %{#{spaces*(splv)}#{spaces*2}}) filename_docbook.puts out filename_docbook.puts "#{spaces*3}#{ocn}" else unless out.empty? filename_docbook.puts SiSU_TextUtils::Wrap.new(out,80,(splv*2+2),nil).line_wrap filename_docbook.puts "#{spaces*3}#{ocn}" end end end else filename_docbook.puts SiSU_TextUtils::Wrap.new(o.obj,80,(splv*2+2),nil,ocn).line_wrap end end |
#code_output(o, ocn, filename_docbook) ⇒ Object
238 239 240 |
# File 'lib/sisu/xml_docbook5.rb', line 238 def code_output(o,ocn,filename_docbook) filename_docbook.puts o.obj.gsub(/\n?(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\n?/m,"\n") end |
#collapsed ⇒ Object
collapsed –>
167 168 169 |
# File 'lib/sisu/xml_docbook5.rb', line 167 def collapsed %w[ 0 1 2 3 4 5 ] end |
#docbook_tag(lc, chlv = '') ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/sisu/xml_docbook5.rb', line 170 def docbook_tag(lc,chlv='') case lc when 0 then 'book' when 1 then lc==chlv ? 'chapter' : 'section' when 2 then lc==chlv ? 'chapter' : 'section' when 3 then lc==chlv ? 'chapter' : 'section' when 4 then 'section' when 5 then 'section' when 6 then 'section' end end |
#document_images ⇒ Object
tail
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/sisu/xml_docbook5.rb', line 141 def document_images img_pth={ src: @md.opt.image_src_path, dest: @md.env.path.webserv + '/_sisu/image', } unless FileTest.directory?(img_pth[:dest]) #mkdir? end if FileTest.directory?(img_pth[:dest]) @md.ec[:image].each do |x| img={ src: "#{img_pth[:src]}/#{x}", dest: "#{img_pth[:dest]}/#{x}", } if FileTest.file?(img[:src]) FileUtils::cp(img[:src],img[:dest]) else p "Not Found: #{img[:src]}/#{x}" end end end end |
#head ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/sisu/xml_docbook5.rb', line 187 def head rdf=SiSU_XML_Tags::RDF.new(@md) stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_docbook').stylesheet <<-WOK <?xml version="1.0" encoding="utf-8"?> #{stylesheet.css_head_xml} #{rdf.comment_xml} <book xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0"> WOK end |
#markup_text(data) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/sisu/xml_docbook5.rb', line 199 def markup_text(data) data.each_with_index do |o,i| if o.is ==:heading \ || o.is ==:para \ || o.of ==:block \ || o.is ==:open_close_tags o=@trans.markup_docbook(o) #unless o.obj==nil end end data end |
#output(o, comment = '') ⇒ Object
216 217 218 219 220 |
# File 'lib/sisu/xml_docbook5.rb', line 216 def output(o,comment='') puts o.lc == (0..6) \ ? "#{spaces*o.lc}<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" : "<#{o.lc}>[#{o.ocn}] #{o.ln} #{o.obj}</#{o.lc}>#{comment}" end |
#put(line) ⇒ Object
183 184 185 186 |
# File 'lib/sisu/xml_docbook5.rb', line 183 def put(line) #@file_docbook.puts line #look into and use perhaps puts line if @md.opt.act[:verbose_plus][:set]==:on end |
#songsheet ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/sisu/xml_docbook5.rb', line 128 def songsheet @t='sisu' data=@data if @md.opt.act[:verbose_plus][:set]==:on structure_collapsed(data) end #head #extract_endnotes data=markup_text(data) structure_build_collapsed(data) document_images if @md.ec[:image] and @md.ec[:image].length > 0 #tail end |
#spaces ⇒ Object
162 163 164 |
# File 'lib/sisu/xml_docbook5.rb', line 162 def spaces Ax[:spaces] end |
#structure_build_collapsed(data) ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/sisu/xml_docbook5.rb', line 263 def structure_build_collapsed(data) #[email protected]_path.xml_docbook_book.dir + '/' + @md.file.base_filename.xml_docbook_book file=SiSU_Env::FileOp.new(@md) filename_docbook=file.write_file.xml_docbook_book h=0 @chlv=chlv=0 doc_position=:head filename_docbook.puts head filename_docbook.puts xml_head data.each_with_index do |o,i| if (defined? o.ocn and not o.ocn.nil?) ocn=(@make.build.ocn?) \ ? "<!-- o#{o.ocn} -->" : '' id=%{ id="o#{o.ocn}" } else ocn,id='','' end if (o.is ==:heading || o.is ==:heading_insert) chlv=(o.lv.to_i == 1) \ ? @chlv=o.lc.to_i : 0 @splv=o.lc tag_id=o.[0] ? %{ id="#{o.[0]}" } : '' if doc_position ==:head filename_docbook.puts %{#{spaces*o.lc}<title#{id}>} doc_position=:body_and_tail else filename_docbook.puts structure_build_tag_close(o.lc,h) filename_docbook.puts %{#{spaces*(o.lc)}<#{.docbook_tag(o.lc,chlv)}#{tag_id}> #{spaces*o.lc}<title#{id}> } end adjust_output(o,ocn,filename_docbook,@splv) filename_docbook.puts %{#{spaces*o.lc}</title>} h=o.lc elsif o.of ==:layout \ and o.is ==:open_close_tags xml_tag=case o.sym when :quote_open then '<blockquote>' when :quote_close then '</blockquote>' else '' end unless xml_tag.empty? filename_docbook.puts "#{spaces*(@splv)}#{xml_tag}" end elsif o.of ==:block if o.is ==:table filename_docbook.puts SiSU_Tables::TableXMLdocbook.new(o,id).table.obj elsif o.is ==:code filename_docbook.puts "#{spaces*(@splv)}<para#{id}>" filename_docbook.puts "#{spaces*(@splv+1)}<programlisting>" code_output(o,ocn,filename_docbook) filename_docbook.puts "#{spaces*(@splv+1)}</programlisting>" filename_docbook.puts "#{spaces*(@splv)}</para>" else filename_docbook.puts "#{spaces*(@splv)}<para#{id}>" adjust_output(o,ocn,filename_docbook,@splv) filename_docbook.puts "#{spaces*(@splv)}</para>" end elsif o.of ==:para filename_docbook.puts "#{spaces*(@splv)}<para#{id}>" adjust_output(o,ocn,filename_docbook,@splv) filename_docbook.puts "#{spaces*(@splv)}</para>" end end filename_docbook.puts structure_build_tag_close(0,h) filename_docbook.close end |
#structure_build_tag_close(lc, h) ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/sisu/xml_docbook5.rb', line 332 def structure_build_tag_close(lc,h) x=[] case h when 0 x << "#{spaces*0}</#{.docbook_tag(0)}>" if (lc <= 0) when 1 x << "#{spaces*1}</#{.docbook_tag(1,@chlv)}>" if (lc <= 1) x << "#{spaces*0}</#{.docbook_tag(0)}>" if (lc <= 0) when 2 x << "#{spaces*2}</#{.docbook_tag(2,@chlv)}>" if (lc <= 2) x << "#{spaces*1}</#{.docbook_tag(1,@chlv)}>" if (lc <= 1) x << "#{spaces*0}</#{.docbook_tag(0)}>" if (lc <= 0) when 3 x << "#{spaces*3}</#{.docbook_tag(3,@chlv)}>" if (lc <= 3) x << "#{spaces*2}</#{.docbook_tag(2,@chlv)}>" if (lc <= 2) x << "#{spaces*1}</#{.docbook_tag(1,@chlv)}>" if (lc <= 1) x << "#{spaces*0}</#{.docbook_tag(0)}>" if (lc <= 0) when 4 x << "#{spaces*4}</#{.docbook_tag(4,@chlv)}>" if (lc <= 4) x << "#{spaces*3}</#{.docbook_tag(3,@chlv)}>" if (lc <= 3) x << "#{spaces*2}</#{.docbook_tag(2,@chlv)}>" if (lc <= 2) x << "#{spaces*1}</#{.docbook_tag(1,@chlv)}>" if (lc <= 1) x << "#{spaces*0}</#{.docbook_tag(0)}>" if (lc <= 0) when 5 x << "#{spaces*5}</#{.docbook_tag(5)}>" if (lc <= 5) x << "#{spaces*4}</#{.docbook_tag(4,@chlv)}>" if (lc <= 4) x << "#{spaces*5}</#{.docbook_tag(3,@chlv)}>" if (lc <= 3) x << "#{spaces*2}</#{.docbook_tag(2,@chlv)}>" if (lc <= 2) x << "#{spaces*1}</#{.docbook_tag(1,@chlv)}>" if (lc <= 1) x << "#{spaces*0}</#{.docbook_tag(0)}>" if (lc <= 0) when 6 x << "#{spaces*6}</#{.docbook_tag(6)}>" if (lc <= 6) x << "#{spaces*5}</#{.docbook_tag(5)}>" if (lc <= 5) x << "#{spaces*4}</#{.docbook_tag(4,@chlv)}>" if (lc <= 4) x << "#{spaces*3}</#{.docbook_tag(3,@chlv)}>" if (lc <= 3) x << "#{spaces*2}</#{.docbook_tag(2,@chlv)}>" if (lc <= 2) x << "#{spaces*1}</#{.docbook_tag(1,@chlv)}>" if (lc <= 1) x << "#{spaces*0}</#{.docbook_tag(0)}>" if (lc <= 0) end x.join("\n") end |
#structure_collapsed(data) ⇒ Object
221 222 223 224 225 226 227 228 |
# File 'lib/sisu/xml_docbook5.rb', line 221 def structure_collapsed(data) puts "\ncollapsed structure, heading outline --->\n\n" data.each_with_index do |o,i| if (o.is ==:heading || o.is ==:heading_insert) output(o) end end end |
#tags ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/sisu/xml_docbook5.rb', line 165 def # collapsed --> def collapsed %w[ 0 1 2 3 4 5 ] end def docbook_tag(lc,chlv='') case lc when 0 then 'book' when 1 then lc==chlv ? 'chapter' : 'section' when 2 then lc==chlv ? 'chapter' : 'section' when 3 then lc==chlv ? 'chapter' : 'section' when 4 then 'section' when 5 then 'section' when 6 then 'section' end end self end |
#tail ⇒ Object
210 211 212 213 214 215 |
# File 'lib/sisu/xml_docbook5.rb', line 210 def tail tail=<<-WOK </book> WOK put(tail) end |
#xml_head ⇒ Object
def chapterlevel end
231 232 233 234 235 236 237 |
# File 'lib/sisu/xml_docbook5.rb', line 231 def xml_head [ '<docinfo>', SiSU_Metadata::Summary.new(@md).xml_docbook., '</docinfo>' ].flatten end |