ultraviolet 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/History.txt +9 -0
  2. data/Manifest.txt +23 -2
  3. data/bin/theme2latexrender +143 -0
  4. data/bin/{theme2render → theme2xhtmlrender} +67 -9
  5. data/bin/uv +28 -51
  6. data/lib/uv.rb +14 -9
  7. data/lib/uv/html_processor.rb +23 -7
  8. data/render/latex/active4d.render +132 -0
  9. data/render/latex/all_hallows_eve.render +96 -0
  10. data/render/latex/amy.render +171 -0
  11. data/render/latex/blackboard.render +111 -0
  12. data/render/latex/brilliance_black.render +602 -0
  13. data/render/latex/brilliance_dull.render +561 -0
  14. data/render/latex/cobalt.render +162 -0
  15. data/render/latex/dawn.render +126 -0
  16. data/render/latex/eiffel.render +132 -0
  17. data/render/latex/espresso_libre.render +123 -0
  18. data/render/latex/idle.render +93 -0
  19. data/render/latex/iplastic.render +99 -0
  20. data/render/latex/lazy.render +96 -0
  21. data/render/latex/mac_classic.render +135 -0
  22. data/render/latex/magicwb_amiga.render +117 -0
  23. data/render/latex/pastels_on_dark.render +204 -0
  24. data/render/latex/slush_poppies.render +123 -0
  25. data/render/latex/spacecadet.render +81 -0
  26. data/render/latex/sunburst.render +186 -0
  27. data/render/latex/twilight.render +153 -0
  28. data/render/latex/zenburnesque.render +126 -0
  29. data/render/xhtml/active4d.render +35 -0
  30. data/render/xhtml/all_hallows_eve.render +35 -0
  31. data/render/xhtml/amy.render +35 -0
  32. data/render/xhtml/blackboard.render +35 -0
  33. data/render/xhtml/brilliance_black.render +35 -0
  34. data/render/xhtml/brilliance_dull.render +35 -0
  35. data/render/xhtml/cobalt.render +35 -0
  36. data/render/xhtml/dawn.render +35 -0
  37. data/render/xhtml/eiffel.render +35 -0
  38. data/render/xhtml/espresso_libre.render +35 -0
  39. data/render/xhtml/idle.render +35 -0
  40. data/render/xhtml/iplastic.render +35 -0
  41. data/render/xhtml/lazy.render +35 -0
  42. data/render/xhtml/mac_classic.render +35 -0
  43. data/render/xhtml/magicwb_amiga.render +35 -0
  44. data/render/xhtml/pastels_on_dark.render +35 -0
  45. data/render/xhtml/slush_poppies.render +35 -0
  46. data/render/xhtml/spacecadet.render +35 -0
  47. data/render/xhtml/sunburst.render +35 -0
  48. data/render/xhtml/twilight.render +35 -0
  49. data/render/xhtml/zenburnesque.render +35 -0
  50. metadata +27 -5
@@ -9,10 +9,11 @@ module Uv
9
9
  attr_reader :string
10
10
  attr_accessor :escapeHTML
11
11
 
12
- def initialize render_options, line_numbers = false, score_manager = nil
12
+ def initialize render_options, line_numbers = false, headers = true, score_manager = nil
13
13
  @score_manager = score_manager || @@score_manager
14
14
  @render_options = render_options
15
15
  @options = {}
16
+ @headers = headers
16
17
  @line_numbers = line_numbers
17
18
  @escapeHTML = true
18
19
  end
@@ -22,6 +23,8 @@ module Uv
22
23
  @string = ""
23
24
  @line = nil
24
25
  @line_number = 0
26
+ print @render_options["document"]["begin"] if @headers
27
+ print @render_options["listing"]["begin"]
25
28
  end
26
29
 
27
30
  def print string
@@ -29,8 +32,10 @@ module Uv
29
32
  end
30
33
 
31
34
  def escape string
32
- if @escapeHTML
33
- CGI.escapeHTML( string )
35
+ if @render_options["filter"]
36
+ @escaped = string
37
+ @escaped = self.instance_eval( @render_options["filter"] )
38
+ @escaped
34
39
  else
35
40
  string
36
41
  end
@@ -38,14 +43,14 @@ module Uv
38
43
 
39
44
  def open_tag name, position
40
45
  @stack << name
41
- print escape(@line[@position...position]) if position > @position
46
+ print escape(@line[@position...position].gsub(/\n|\r/, '')) if position > @position
42
47
  @position = position
43
48
  opt = options
44
49
  print opt["begin"] if opt
45
50
  end
46
51
 
47
52
  def close_tag name, position
48
- print escape(@line[@position...position]) if position > @position
53
+ print escape(@line[@position...position].gsub(/\n|\r/, '')) if position > @position
49
54
  @position = position
50
55
  opt = options
51
56
  print opt["end"] if opt
@@ -53,10 +58,15 @@ module Uv
53
58
  end
54
59
 
55
60
  def new_line line
56
- print escape(@line[@position..-1]) if @line
61
+ if @line
62
+ print escape(@line[@position..-1].gsub(/\n|\r/, ''))
63
+ print @render_options["line"]["end"]
64
+ print "\n"
65
+ end
57
66
  @position = 0
58
67
  @line_number += 1
59
68
  @line = line
69
+ print @render_options["line"]["begin"]
60
70
  if @line_numbers
61
71
  print @render_options["line-numbers"]["begin"]
62
72
  print @line_number.to_s.rjust(4).ljust(5)
@@ -66,12 +76,18 @@ module Uv
66
76
  end
67
77
 
68
78
  def end_parsing
69
- print escape(@line[@position..-1].gsub("\n", '')) if @line
79
+ if @line
80
+ print escape(@line[@position..-1].gsub(/\n|\r/, ''))
81
+ print @render_options["line"]["end"]
82
+ print "\n"
83
+ end
70
84
  while ! @stack.empty?
71
85
  opt = options
72
86
  print opt["end"] if opt
73
87
  @stack.pop
74
88
  end
89
+ print @render_options["listing"]["end"]
90
+ print @render_options["document"]["end"] if @headers
75
91
  end
76
92
 
77
93
  def options
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: Active4D
3
+ line:
4
+ begin: ""
5
+ end: "}}\\\\"
6
+ tags:
7
+ - begin: \colorbox[HTML]{F4F6FF}{
8
+ end: "}"
9
+ selector: text.html source.active4d
10
+ - begin: "{\\color[HTML]{000000}"
11
+ end: "}"
12
+ selector: text.xml
13
+ - begin: "{\\color[HTML]{D33535}"
14
+ end: "}"
15
+ selector: comment.line
16
+ - begin: "{\\color[HTML]{D33435}"
17
+ end: "}"
18
+ selector: comment.block
19
+ - begin: "{\\color[HTML]{666666}"
20
+ end: "}"
21
+ selector: string
22
+ - begin: "{\\color[HTML]{66CCFF}\\textbf{"
23
+ end: "}}"
24
+ selector: string.interpolated variable
25
+ - begin: "{\\color[HTML]{A8017E}"
26
+ end: "}"
27
+ selector: constant.numeric
28
+ - begin: "{"
29
+ end: "}"
30
+ selector: constant.character, constant.other
31
+ - begin: "{\\color[HTML]{66CCFF}\\textbf{"
32
+ end: "}}"
33
+ selector: constant.other.date, constant.other.time
34
+ - begin: "{\\color[HTML]{A535AE}"
35
+ end: "}"
36
+ selector: constant.language
37
+ - begin: "{\\color[HTML]{6392FF}\\textbf{"
38
+ end: "}}"
39
+ selector: variable.other.local
40
+ - begin: "{\\color[HTML]{0053FF}\\textbf{"
41
+ end: "}}"
42
+ selector: variable
43
+ - begin: "{\\color[HTML]{0BB600}"
44
+ end: "}"
45
+ selector: variable.other.table-field
46
+ - begin: "{\\color[HTML]{006699}\\textbf{"
47
+ end: "}}"
48
+ selector: keyword
49
+ - begin: "{"
50
+ end: "}"
51
+ selector: keyword.operator
52
+ - begin: "{\\color[HTML]{FF5600}"
53
+ end: "}"
54
+ selector: storage
55
+ - begin: "{\\color[HTML]{21439C}"
56
+ end: "}"
57
+ selector: entity.name.type
58
+ - begin: "{"
59
+ end: "}"
60
+ selector: entity.other.inherited-class
61
+ - begin: "{\\color[HTML]{21439C}"
62
+ end: "}"
63
+ selector: entity.name.function
64
+ - begin: "{"
65
+ end: "}"
66
+ selector: variable.parameter
67
+ - begin: "{\\color[HTML]{7A7A7A}"
68
+ end: "}"
69
+ selector: meta.tag
70
+ - begin: "{\\color[HTML]{016CFF}"
71
+ end: "}"
72
+ selector: entity.name.tag
73
+ - begin: "{\\color[HTML]{963DFF}"
74
+ end: "}"
75
+ selector: entity.other.attribute-name
76
+ - begin: "{\\color[HTML]{45AE34}\\textbf{"
77
+ end: "}}"
78
+ selector: support.function
79
+ - begin: "{\\color[HTML]{B7734C}"
80
+ end: "}"
81
+ selector: support.constant
82
+ - begin: "{\\color[HTML]{A535AE}"
83
+ end: "}"
84
+ selector: support.type, support.class
85
+ - begin: "{\\color[HTML]{A535AE}"
86
+ end: "}"
87
+ selector: support.variable
88
+ - begin: \colorbox[HTML]{990000}{\color[HTML]{FFFFFF}
89
+ end: "}"
90
+ selector: invalid
91
+ - begin: \colorbox[HTML]{656565}{\color[HTML]{FFFFFF}
92
+ end: "}"
93
+ selector: meta.diff
94
+ - begin: \colorbox[HTML]{1B63FF}{\color[HTML]{FFFFFF}
95
+ end: "}"
96
+ selector: meta.diff.range
97
+ - begin: \colorbox[HTML]{FF7880}{\color[HTML]{000000}
98
+ end: "}"
99
+ selector: markup.deleted.diff
100
+ - begin: \colorbox[HTML]{98FF9A}{\color[HTML]{000000}
101
+ end: "}"
102
+ selector: markup.inserted.diff
103
+ - begin: "{\\color[HTML]{5E5E5E}"
104
+ end: "}"
105
+ selector: source.diff
106
+ listing:
107
+ begin: |
108
+ \newcolumntype{C}{>{\color[HTML]{000000}\columncolor[HTML]{FFFFFF}}l}
109
+ \newcolumntype{N}{>{\color[HTML]{000000}\columncolor[HTML]{BAD6FD}}l}
110
+ \begin{longtable}{NC}
111
+
112
+ end: |
113
+ \end{longtable}
114
+
115
+ document:
116
+ begin: |
117
+ \documentclass[a4paper,landscape]{article}
118
+ \usepackage{xcolor}
119
+ \usepackage{colortbl}
120
+ \usepackage{longtable}
121
+ \usepackage[left=2cm,top=1cm,right=3cm,nohead,nofoot]{geometry}
122
+ \usepackage[T1]{fontenc}
123
+ \usepackage[scaled]{beramono}
124
+ \begin{document}
125
+
126
+ end: |
127
+ \end{document}
128
+
129
+ filter: "@escaped.gsub(/(_|\\{|\\}|&|\\#|\\\\)/, '\\\\\\\\\\1').gsub(/~/, '\\\\textasciitilde').gsub(/ /,'\\\\hspace{1ex}').gsub(/\\t/,'\\\\hspace{3ex}')"
130
+ line-numbers:
131
+ begin: \texttt{
132
+ end: "}&\\mbox{\\texttt{"
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: All Hallow's Eve
3
+ line:
4
+ begin: ""
5
+ end: "}}\\\\"
6
+ tags:
7
+ - begin: \colorbox[HTML]{434242}{\color[HTML]{FFFFFF}
8
+ end: "}"
9
+ selector: text
10
+ - begin: \colorbox[HTML]{000000}{\color[HTML]{FFFFFF}
11
+ end: "}"
12
+ selector: source
13
+ - begin: "{\\color[HTML]{9933CC}"
14
+ end: "}"
15
+ selector: comment
16
+ - begin: "{\\color[HTML]{3387CC}"
17
+ end: "}"
18
+ selector: constant
19
+ - begin: "{\\color[HTML]{CC7833}"
20
+ end: "}"
21
+ selector: keyword
22
+ - begin: "{\\color[HTML]{D0D0FF}"
23
+ end: "}"
24
+ selector: meta.preprocessor.c
25
+ - begin: "{"
26
+ end: "}"
27
+ selector: keyword.control.import
28
+ - begin: "{"
29
+ end: "}"
30
+ selector: entity.name.function
31
+ - begin: "{\\textit{"
32
+ end: "}}"
33
+ selector: variable.parameter
34
+ - begin: \colorbox[HTML]{9B9B9B}{\color[HTML]{FFFFFF}
35
+ end: "}"
36
+ selector: source comment.block
37
+ - begin: "{\\color[HTML]{66CC33}"
38
+ end: "}"
39
+ selector: string
40
+ - begin: "{\\color[HTML]{AAAAAA}"
41
+ end: "}"
42
+ selector: string constant.character.escape
43
+ - begin: \colorbox[HTML]{CCCC33}{\color[HTML]{000000}
44
+ end: "}"
45
+ selector: string.interpolated
46
+ - begin: "{\\color[HTML]{CCCC33}"
47
+ end: "}"
48
+ selector: string.regexp
49
+ - begin: "{\\color[HTML]{CCCC33}"
50
+ end: "}"
51
+ selector: string.literal
52
+ - begin: "{\\color[HTML]{555555}"
53
+ end: "}"
54
+ selector: string.interpolated constant.character.escape
55
+ - begin: "{\\underline{"
56
+ end: "}}"
57
+ selector: entity.name.type
58
+ - begin: "{\\textit{"
59
+ end: "}}"
60
+ selector: entity.other.inherited-class
61
+ - begin: "{\\underline{"
62
+ end: "}}"
63
+ selector: entity.name.tag
64
+ - begin: "{"
65
+ end: "}"
66
+ selector: entity.other.attribute-name
67
+ - begin: "{\\color[HTML]{C83730}"
68
+ end: "}"
69
+ selector: support.function
70
+ listing:
71
+ begin: |
72
+ \newcolumntype{C}{>{\color[HTML]{FFFFFF}\columncolor[HTML]{000000}}l}
73
+ \newcolumntype{N}{>{\color[HTML]{FFFFFF}\columncolor[HTML]{644D6E}}l}
74
+ \begin{longtable}{NC}
75
+
76
+ end: |
77
+ \end{longtable}
78
+
79
+ document:
80
+ begin: |
81
+ \documentclass[a4paper,landscape]{article}
82
+ \usepackage{xcolor}
83
+ \usepackage{colortbl}
84
+ \usepackage{longtable}
85
+ \usepackage[left=2cm,top=1cm,right=3cm,nohead,nofoot]{geometry}
86
+ \usepackage[T1]{fontenc}
87
+ \usepackage[scaled]{beramono}
88
+ \begin{document}
89
+
90
+ end: |
91
+ \end{document}
92
+
93
+ filter: "@escaped.gsub(/(_|\\{|\\}|&|\\#|\\\\)/, '\\\\\\\\\\1').gsub(/~/, '\\\\textasciitilde').gsub(/ /,'\\\\hspace{1ex}').gsub(/\\t/,'\\\\hspace{3ex}')"
94
+ line-numbers:
95
+ begin: \texttt{
96
+ end: "}&\\mbox{\\texttt{"
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: Amy
3
+ line:
4
+ begin: ""
5
+ end: "}}\\\\"
6
+ tags:
7
+ - begin: \colorbox[HTML]{200020}{\color[HTML]{404080}\textit{
8
+ end: "}}"
9
+ selector: comment.block
10
+ - begin: "{\\color[HTML]{999999}"
11
+ end: "}"
12
+ selector: string
13
+ - begin: "{\\color[HTML]{707090}"
14
+ end: "}"
15
+ selector: constant.language
16
+ - begin: "{\\color[HTML]{7090B0}"
17
+ end: "}"
18
+ selector: constant.numeric
19
+ - begin: "{\\textbf{"
20
+ end: "}}"
21
+ selector: constant.numeric.integer.int32
22
+ - begin: "{\\textit{"
23
+ end: "}}"
24
+ selector: constant.numeric.integer.int64
25
+ - begin: "{\\textbf{"
26
+ end: "}}"
27
+ selector: constant.numeric.integer.nativeint
28
+ - begin: "{\\underline{"
29
+ end: "}}"
30
+ selector: constant.numeric.floating-point.ocaml
31
+ - begin: "{\\color[HTML]{666666}"
32
+ end: "}"
33
+ selector: constant.character
34
+ - begin: "{\\color[HTML]{8080A0}"
35
+ end: "}"
36
+ selector: constant.language.boolean
37
+ - begin: "{"
38
+ end: "}"
39
+ selector: constant.language
40
+ - begin: "{"
41
+ end: "}"
42
+ selector: constant.other
43
+ - begin: "{\\color[HTML]{008080}"
44
+ end: "}"
45
+ selector: variable.language, variable.other
46
+ - begin: "{\\color[HTML]{A080FF}"
47
+ end: "}"
48
+ selector: keyword
49
+ - begin: "{\\color[HTML]{A0A0FF}"
50
+ end: "}"
51
+ selector: keyword.operator
52
+ - begin: "{\\color[HTML]{D0D0FF}"
53
+ end: "}"
54
+ selector: keyword.other.decorator
55
+ - begin: "{\\underline{"
56
+ end: "}}"
57
+ selector: keyword.operator.infix.floating-point.ocaml
58
+ - begin: "{\\underline{"
59
+ end: "}}"
60
+ selector: keyword.operator.prefix.floating-point.ocaml
61
+ - begin: "{\\color[HTML]{C080C0}"
62
+ end: "}"
63
+ selector: keyword.other.directive
64
+ - begin: "{\\color[HTML]{C080C0}\\underline{"
65
+ end: "}}"
66
+ selector: keyword.other.directive.line-number
67
+ - begin: "{\\color[HTML]{80A0FF}"
68
+ end: "}"
69
+ selector: keyword.control
70
+ - begin: "{\\color[HTML]{B0FFF0}"
71
+ end: "}"
72
+ selector: storage
73
+ - begin: "{\\color[HTML]{60B0FF}"
74
+ end: "}"
75
+ selector: entity.name.type.variant
76
+ - begin: "{\\color[HTML]{60B0FF}\\textit{"
77
+ end: "}}"
78
+ selector: storage.type.variant.polymorphic, entity.name.type.variant.polymorphic
79
+ - begin: "{\\color[HTML]{B000B0}"
80
+ end: "}"
81
+ selector: entity.name.type.module
82
+ - begin: "{\\color[HTML]{B000B0}\\underline{"
83
+ end: "}}"
84
+ selector: entity.name.type.module-type.ocaml
85
+ - begin: "{\\color[HTML]{A00050}"
86
+ end: "}"
87
+ selector: support.other
88
+ - begin: "{\\color[HTML]{70E080}"
89
+ end: "}"
90
+ selector: entity.name.type.class
91
+ - begin: "{\\color[HTML]{70E0A0}"
92
+ end: "}"
93
+ selector: entity.name.type.class-type
94
+ - begin: "{"
95
+ end: "}"
96
+ selector: entity.other.inherited-class
97
+ - begin: "{\\color[HTML]{50A0A0}"
98
+ end: "}"
99
+ selector: entity.name.function
100
+ - begin: "{\\color[HTML]{80B0B0}"
101
+ end: "}"
102
+ selector: variable.parameter
103
+ - begin: "{\\color[HTML]{3080A0}"
104
+ end: "}"
105
+ selector: entity.name.type.token
106
+ - begin: "{\\color[HTML]{3CB0D0}"
107
+ end: "}"
108
+ selector: entity.name.type.token.reference
109
+ - begin: "{\\color[HTML]{90E0E0}"
110
+ end: "}"
111
+ selector: entity.name.function.non-terminal
112
+ - begin: "{\\color[HTML]{C0F0F0}"
113
+ end: "}"
114
+ selector: entity.name.function.non-terminal.reference
115
+ - begin: "{\\color[HTML]{009090}"
116
+ end: "}"
117
+ selector: entity.name.tag
118
+ - begin: "{"
119
+ end: "}"
120
+ selector: entity.other.attribute-name
121
+ - begin: \colorbox[HTML]{200020}{
122
+ end: "}"
123
+ selector: support.constant
124
+ - begin: "{"
125
+ end: "}"
126
+ selector: support.type, support.class
127
+ - begin: "{"
128
+ end: "}"
129
+ selector: support.other.variable
130
+ - begin: \colorbox[HTML]{FFFF00}{\color[HTML]{400080}\textbf{
131
+ end: "}}"
132
+ selector: invalid.illegal
133
+ - begin: \colorbox[HTML]{CC66FF}{\color[HTML]{200020}
134
+ end: "}"
135
+ selector: invalid.deprecated
136
+ - begin: \colorbox[HTML]{2A003F}{
137
+ end: "}"
138
+ selector: source.camlp4.embedded
139
+ - begin: "{"
140
+ end: "}"
141
+ selector: source.camlp4.embedded.parser.ocaml
142
+ - begin: "{\\color[HTML]{805080}"
143
+ end: "}"
144
+ selector: punctuation
145
+ listing:
146
+ begin: |
147
+ \newcolumntype{C}{>{\color[HTML]{D0D0FF}\columncolor[HTML]{200020}}l}
148
+ \newcolumntype{N}{>{\color[HTML]{D0D0FF}\columncolor[HTML]{500010}}l}
149
+ \begin{longtable}{NC}
150
+
151
+ end: |
152
+ \end{longtable}
153
+
154
+ document:
155
+ begin: |
156
+ \documentclass[a4paper,landscape]{article}
157
+ \usepackage{xcolor}
158
+ \usepackage{colortbl}
159
+ \usepackage{longtable}
160
+ \usepackage[left=2cm,top=1cm,right=3cm,nohead,nofoot]{geometry}
161
+ \usepackage[T1]{fontenc}
162
+ \usepackage[scaled]{beramono}
163
+ \begin{document}
164
+
165
+ end: |
166
+ \end{document}
167
+
168
+ filter: "@escaped.gsub(/(_|\\{|\\}|&|\\#|\\\\)/, '\\\\\\\\\\1').gsub(/~/, '\\\\textasciitilde').gsub(/ /,'\\\\hspace{1ex}').gsub(/\\t/,'\\\\hspace{3ex}')"
169
+ line-numbers:
170
+ begin: \texttt{
171
+ end: "}&\\mbox{\\texttt{"