File: css.rb

package info (click to toggle)
ruby-hamlit 2.15.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,996 kB
  • sloc: ruby: 10,548; ansic: 536; sh: 23; makefile: 8
file content (33 lines) | stat: -rw-r--r-- 736 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true
module Hamlit
  class Filters
    class Css < TextBase
      def compile(node)
        case @format
        when :xhtml
          compile_xhtml(node)
        else
          compile_html(node)
        end
      end

      private

      def compile_html(node)
        temple = [:multi]
        temple << [:static, "<style>\n"]
        compile_text!(temple, node, '  ')
        temple << [:static, "\n</style>"]
        temple
      end

      def compile_xhtml(node)
        temple = [:multi]
        temple << [:static, "<style type='text/css'>\n  /*<![CDATA[*/\n"]
        compile_text!(temple, node, '    ')
        temple << [:static, "\n  /*]]>*/\n</style>"]
        temple
      end
    end
  end
end