Class: Jekyll::Pseudo::HtmlBrush
- Defined in:
- lib/jekyll-pseudo/html_brush.rb
Instance Method Summary collapse
- #comment(txt) ⇒ Object
- #fn(txt) ⇒ Object
- #indent(txt) ⇒ Object
- #op(txt) ⇒ Object
- #plain(txt) ⇒ Object
- #string(txt) ⇒ Object
- #sym(txt) ⇒ Object
- #var(txt, sub) ⇒ Object
Instance Method Details
#comment(txt) ⇒ Object
22 23 24 |
# File 'lib/jekyll-pseudo/html_brush.rb', line 22 def comment(txt) "<span class='comment'>/* #{txt.strip} */</span>" end |
#fn(txt) ⇒ Object
10 11 12 |
# File 'lib/jekyll-pseudo/html_brush.rb', line 10 def fn(txt) "<span class='function'>#{txt}</span>" end |
#indent(txt) ⇒ Object
30 31 32 33 |
# File 'lib/jekyll-pseudo/html_brush.rb', line 30 def indent(txt) txt.gsub! "\t", ' ' "<span class='indent'>#{txt}</span>" end |
#op(txt) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jekyll-pseudo/html_brush.rb', line 35 def op(txt) symbol = case txt 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='op'>#{symbol}</span>" end |
#plain(txt) ⇒ Object
52 53 54 |
# File 'lib/jekyll-pseudo/html_brush.rb', line 52 def plain(txt) txt end |
#string(txt) ⇒ Object
26 27 28 |
# File 'lib/jekyll-pseudo/html_brush.rb', line 26 def string(txt) "<span class='string'>#{txt}</span>" end |
#sym(txt) ⇒ Object
6 7 8 |
# File 'lib/jekyll-pseudo/html_brush.rb', line 6 def sym(txt) "<span class='symbol'>#{txt}</span>" end |
#var(txt, sub) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/jekyll-pseudo/html_brush.rb', line 14 def var(txt, sub) if sub "#{txt}<sub>#{sub.slice(1,sub.size)}</sub>" else "#{txt}" end end |