Module: HTML
- Included in:
- Ulmul
- Defined in:
- lib/ulmul.rb
Constant Summary collapse
- CONTENTS_HERE =
"<!-- Contents -->"
Instance Method Summary collapse
- #body ⇒ Object
- #cb_env_end2code ⇒ Object
- #cb_env_end2table ⇒ Object
- #cb_equation_end2 ⇒ Object
- #cb_heading(filename = nil, lnumber = nil, line = nil) ⇒ Object
Instance Method Details
#body ⇒ Object
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/ulmul.rb', line 322 def body b = @body.dup [@equations, @figures, @tables, @codes].each do |ary| ary.each_with_index do |r,i| s = r.sub(/:.*/,'') if /Eq|Fig/ =~ s then s << '.' end if /Eq/ =~ s then no = "(#{i+1})" else no = "#{i+1}" end b.gsub!(Regexp.new('(?![A-Za-z0-9_"\'#%\\\\])(.)'+r+'(?![A-Za-z0-9_"\'#%])(.)'),"\\1<a href=\"##{r}\">#{s} #{no}</a>\\2") end end if $MAX_TABLE_OF_CONTENTS>=2 b.sub(CONTENTS_HERE, "<br />\n<div class=\"table of contents\">\nTable of Contents:" + @toc.body + "</div>\n") else b end end |
#cb_env_end2code ⇒ Object
350 351 352 353 354 355 356 357 358 |
# File 'lib/ulmul.rb', line 350 def cb_env_end2code() @body << "<p id=\"#{@env_label}\" class=\"code caption\">\n" @body << " Code #{@codes.length}: " << @subs_rules.call(@env_caption) << "(download: <a href=\"#{@env_file}\">#{File.basename(@env_file)}</a>)" << "</p>\n" @body << "<pre class=\"prettyprint\">\n" f = open(@env_file) @body << f.read.gsub(/&/,'&').gsub(/</,'<').gsub(/>/,'>') f.close @body << "</pre>\n" end |
#cb_env_end2table ⇒ Object
340 341 342 343 344 345 346 347 348 |
# File 'lib/ulmul.rb', line 340 def cb_env_end2table() @body << "<table id=\"#{@env_label}\">\n" @body << " <caption>\n" @body << " Table #{@tables.length}: " << @subs_rules.call(@env_caption) @body << " </caption>\n" @body << " <thead><tr><th> TABLE </th></tr></thead>\n" @body << " <tbody><tr><td>Not yet implemented</td></tr></tbody>\n" @body << '</table>' << "\n" end |
#cb_equation_end2 ⇒ Object
360 361 362 363 364 365 366 |
# File 'lib/ulmul.rb', line 360 def cb_equation_end2() if $0 == __FILE__ || /ulmul2(html5|xhtml)$/ =~ $0 @body << @equation_contents.to_mathml('block').to_s.sub(/<math /,"<math id=\"#{@equation_label}\" ") << "\n" elsif /ulmul2mathjax$/ =~ $0 @body << "<div id=\"#{@equation_label}\">\n\\begin{equation}\n" << @equation_contents << " \\tag{#{@equations.length}}\n" << "\\end{equation}\n</div>\n" end end |
#cb_heading(filename = nil, lnumber = nil, line = nil) ⇒ Object
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/ulmul.rb', line 298 def cb_heading(filename=nil, lnumber=nil, line=nil) if /^(=+) (.*)$/ =~ line new_level=Regexp.last_match[1].length str=Regexp.last_match[2] elsif /^=end/ =~ line @level_of_heading=0 @body << '</div>' @toc.cb_itemize_end() return end raise 'Illegal jump of heading level' if new_level>@level_of_heading+1 @i_th_heading += 1 @body << CONTENTS_HERE << "\n" if @i_th_heading==2 @body << "</div>\n\n\n" if @i_th_heading!=1 and new_level<=2 @title=str if @i_th_heading==1 cls = if new_level==1 then "slide cover" else "slide" end @body << "<div class=\"#{cls}\">\n" if new_level<=2 @body << "<h#{new_level} id=\"LABEL-#{@i_th_heading}\">" << str << "</h#{new_level}>\n" if 2 <= new_level && new_level <= $MAX_TABLE_OF_CONTENTS @toc.cb_itemize_add_item('HTML Table of Contents', @i_th_heading, " "*(new_level-2) + " * <a href=\"#LABEL-#{@i_th_heading}\">" + str + "</a>") end @level_of_heading=new_level end |