class Jekyll::PseudoCodeB::HtmlBrush
Public Instance Methods
comment(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 54 def comment(txt) "<span class='comment'>/* #{txt.strip} */</span>" end
fn(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 22 def fn(txt) "<span class='function'>#{txt}</span>" end
indent(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 62 def indent(txt) txt.gsub! "\t", ' ' "<span class='indent'>#{txt}</span>" end
is_numeric?(s)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 7 def is_numeric?(s) begin Float(s) rescue false # not numeric else true # numeric end end
math(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 96 def math(txt) symbol = case txt when 'pi' then 'π' when 'tau' then '𝛕' when 'infinity' then '∞' else txt end # FIXME: html conversion for some operators "<span class='math-symbol'>#{symbol}</span>" end
number(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 30 def number(txt) "<span class='numeric'>#{txt}</span>" end
objfn(obj, fnc)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 26 def objfn(obj, fnc) "<span class='variable'>#{obj}</span><span class='operator'>.</span><span class='function'>#{fnc}</span>" end
op(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 67 def op(txt) symbol = case txt when '<' then '<' when '>' then '>' when '<=' then '≤' when '>=' then '≥' when '<-' then '←' when '->' then '→' when '<--' then '⟵' when '-->' then '⟶' when '<->' then '↔' when '<-->' then '⟷' when '*' then '×' when '[' then '[' when ']' then ']' when '!=' then '≠' when '<>' then '≠' when '=' then '=' when ':=' then '≔' when '+' then '+' when '-' then '-' when '/' then '/' when '==' then '=' else txt end # FIXME: html conversion for some operators "<span class='operator'>#{symbol}</span>" end
plain(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 107 def plain(txt) "#{txt}" end
special(txt, sub)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 34 def special(txt, sub) if sub "<span class='special'>#{txt}<sub>#{sub.slice(1,sub.size)}</sub></span>" else "<span class='special'>#{txt}</span>" end end
string(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 58 def string(txt) "<span class='string'>#{txt}</span>" end
sym(txt)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 17 def sym(txt) "<span class='symbol'>#{txt}</span>" end
var(txt, sub)
click to toggle source
# File lib/jekyll-pseudocode-b/html_brush.rb, line 42 def var(txt, sub) if sub "<span class='variable'>#{txt}<sub>#{sub.slice(1,sub.size)}</sub></span>" else if (is_numeric?(txt)) "<span class='numeric'>#{txt}</span>" else "<span class='variable'>#{txt}</span>" end end end