Module: Org::ToHtml
- Defined in:
- lib/org/to/html.rb
Instance Method Summary collapse
-
#html_header ⇒ Object
unify toc_id somwhere?.
-
#html_highlight ⇒ Object
TODO: find a simple way of caching highlighted code from Uv, gives us much more possibilities in highlighting compared to coderay, but is also really slow.
- #html_space ⇒ Object
- #html_text ⇒ Object
- #tag(*args) ⇒ Object
- #to_html ⇒ Object
Instance Method Details
#html_header ⇒ Object
unify toc_id somwhere?
27 28 29 30 31 |
# File 'lib/org/to/html.rb', line 27 def html_header level, text = values[0].size, values[1] id = respond_to?(:toc_id) ? toc_id : text.gsub(/\W/, '-').squeeze('-').downcase Tag.new("h#{level}", text, :id => id) end |
#html_highlight ⇒ Object
TODO: find a simple way of caching highlighted code from Uv,
gives us much more possibilities in highlighting compared
to coderay, but is also _really_ slow.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/org/to/html.rb', line 40 def html_highlight language, code = *values require 'coderay' language = 'nitro_xhtml' if language == 'ezamar' case language when *%w[ruby c delphi html nitro_xhtml plaintext rhtml xml] tokens = CodeRay.scan(code, language) html = tokens.html(:wrap => :div) when *%w[diff] require 'uv' Uv.parse(code, output = 'xhtml', syntax_name = language, line_numbers = false, render_style = 'amy', headers = false) else code = language if not code or code.strip.empty? html = tag(:pre, code) end end |
#html_space ⇒ Object
33 34 35 |
# File 'lib/org/to/html.rb', line 33 def html_space ' ' end |
#html_text ⇒ Object
22 23 24 |
# File 'lib/org/to/html.rb', line 22 def html_text Org.escape_html(values.join) end |