ultraviolet 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/Manifest.txt +23 -2
- data/bin/theme2latexrender +143 -0
- data/bin/{theme2render → theme2xhtmlrender} +67 -9
- data/bin/uv +28 -51
- data/lib/uv.rb +14 -9
- data/lib/uv/html_processor.rb +23 -7
- data/render/latex/active4d.render +132 -0
- data/render/latex/all_hallows_eve.render +96 -0
- data/render/latex/amy.render +171 -0
- data/render/latex/blackboard.render +111 -0
- data/render/latex/brilliance_black.render +602 -0
- data/render/latex/brilliance_dull.render +561 -0
- data/render/latex/cobalt.render +162 -0
- data/render/latex/dawn.render +126 -0
- data/render/latex/eiffel.render +132 -0
- data/render/latex/espresso_libre.render +123 -0
- data/render/latex/idle.render +93 -0
- data/render/latex/iplastic.render +99 -0
- data/render/latex/lazy.render +96 -0
- data/render/latex/mac_classic.render +135 -0
- data/render/latex/magicwb_amiga.render +117 -0
- data/render/latex/pastels_on_dark.render +204 -0
- data/render/latex/slush_poppies.render +123 -0
- data/render/latex/spacecadet.render +81 -0
- data/render/latex/sunburst.render +186 -0
- data/render/latex/twilight.render +153 -0
- data/render/latex/zenburnesque.render +126 -0
- data/render/xhtml/active4d.render +35 -0
- data/render/xhtml/all_hallows_eve.render +35 -0
- data/render/xhtml/amy.render +35 -0
- data/render/xhtml/blackboard.render +35 -0
- data/render/xhtml/brilliance_black.render +35 -0
- data/render/xhtml/brilliance_dull.render +35 -0
- data/render/xhtml/cobalt.render +35 -0
- data/render/xhtml/dawn.render +35 -0
- data/render/xhtml/eiffel.render +35 -0
- data/render/xhtml/espresso_libre.render +35 -0
- data/render/xhtml/idle.render +35 -0
- data/render/xhtml/iplastic.render +35 -0
- data/render/xhtml/lazy.render +35 -0
- data/render/xhtml/mac_classic.render +35 -0
- data/render/xhtml/magicwb_amiga.render +35 -0
- data/render/xhtml/pastels_on_dark.render +35 -0
- data/render/xhtml/slush_poppies.render +35 -0
- data/render/xhtml/spacecadet.render +35 -0
- data/render/xhtml/sunburst.render +35 -0
- data/render/xhtml/twilight.render +35 -0
- data/render/xhtml/zenburnesque.render +35 -0
- metadata +27 -5
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.10.0 / 2007-05-15
|
2
|
+
* Added copy files commant to Uv module and to command line utility.
|
3
|
+
now the required files (ex. css) may be easily copied to a destination
|
4
|
+
directory.
|
5
|
+
* Small corrections in html_processor (should change name)
|
6
|
+
* Many modifications to latex rendering
|
7
|
+
* First latex rendering implementation (still buggy).
|
8
|
+
* All processing is defined in render files.
|
9
|
+
|
1
10
|
== 0.9.0 / 2007-04-24
|
2
11
|
|
3
12
|
* 1 major enhancement
|
data/Manifest.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
render/old/txt2tags.render
|
2
|
-
render/xhtml
|
3
2
|
render/xhtml/active4d.render
|
4
3
|
render/xhtml/all_hallows_eve.render
|
5
4
|
render/xhtml/amy.render
|
@@ -44,6 +43,27 @@ render/xhtml/files/css/spacecadet.css
|
|
44
43
|
render/xhtml/files/css/sunburst.css
|
45
44
|
render/xhtml/files/css/twilight.css
|
46
45
|
render/xhtml/files/css/zenburnesque.css
|
46
|
+
render/latex/amy.render
|
47
|
+
render/latex/espresso_libre.render
|
48
|
+
render/latex/eiffel.render
|
49
|
+
render/latex/sunburst.render
|
50
|
+
render/latex/idle.render
|
51
|
+
render/latex/lazy.render
|
52
|
+
render/latex/all_hallows_eve.render
|
53
|
+
render/latex/blackboard.render
|
54
|
+
render/latex/brilliance_dull.render
|
55
|
+
render/latex/zenburnesque.render
|
56
|
+
render/latex/magicwb_amiga.render
|
57
|
+
render/latex/dawn.render
|
58
|
+
render/latex/twilight.render
|
59
|
+
render/latex/spacecadet.render
|
60
|
+
render/latex/brilliance_black.render
|
61
|
+
render/latex/mac_classic.render
|
62
|
+
render/latex/active4d.render
|
63
|
+
render/latex/slush_poppies.render
|
64
|
+
render/latex/cobalt.render
|
65
|
+
render/latex/iplastic.render
|
66
|
+
render/latex/pastels_on_dark.render
|
47
67
|
test/test_uv.rb
|
48
68
|
lib/uv/html_processor.rb
|
49
69
|
lib/uv.rb
|
@@ -208,7 +228,8 @@ syntax/javascript_+_prototype.syntax
|
|
208
228
|
syntax/languagedefinition.syntax
|
209
229
|
syntax/regular_expressions_oniguruma.syntax
|
210
230
|
syntax/subversion_commit_message.syntax
|
211
|
-
bin/
|
231
|
+
bin/theme2xhtmlrender
|
232
|
+
bin/theme2latexrender
|
212
233
|
bin/uv
|
213
234
|
History.txt
|
214
235
|
Rakefile
|
@@ -0,0 +1,143 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
begin
|
3
|
+
require 'plist'
|
4
|
+
rescue LoadError
|
5
|
+
require 'rubygems'
|
6
|
+
require 'plist'
|
7
|
+
end
|
8
|
+
|
9
|
+
base_dir = File.join( File.dirname(__FILE__), '..', 'render' )
|
10
|
+
|
11
|
+
def settings
|
12
|
+
unless @settings
|
13
|
+
@settings = @theme["settings"].find { |s| ! s["name"] }["settings"]
|
14
|
+
end
|
15
|
+
@settings
|
16
|
+
end
|
17
|
+
|
18
|
+
def normalize_color color
|
19
|
+
if color =~ /^#/ && color.size == 9
|
20
|
+
div0 = (settings["background"] ? settings["background"][1..-1].hex : 0xFFFFFF )
|
21
|
+
div1, alpha = color[1..-1].hex.divmod( 0x100 )
|
22
|
+
result = ""
|
23
|
+
3.times {
|
24
|
+
div0, mod0 = div0.divmod( 0x100 )
|
25
|
+
div1, mod1 = div1.divmod( 0x100 )
|
26
|
+
result = ((mod1 * alpha + mod0 * ( 0x100 - alpha ) ) / 0x100).to_s(16).upcase.rjust(2, '0') + result
|
27
|
+
}
|
28
|
+
result = result
|
29
|
+
result
|
30
|
+
elsif color =~ /^#/ && color.size == 4
|
31
|
+
r = (color[0].hex * 256 / 16).to_s(16).upcase.rjust(2, '0')
|
32
|
+
g = (color[1].hex * 256 / 16).to_s(16).upcase.rjust(2, '0')
|
33
|
+
b = (color[2].hex * 256 / 16).to_s(16).upcase.rjust(2, '0')
|
34
|
+
r + g + b
|
35
|
+
elsif color =~ /^#/ && color.size == 7
|
36
|
+
return color[1..-1]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
@theme = Plist::parse_xml( ARGV[0] )
|
41
|
+
render = {"name" => @theme["name"]}
|
42
|
+
codecolumn = ""
|
43
|
+
numbercolumn = ""
|
44
|
+
standard_name = File.basename( ARGV[0] ).downcase.gsub(/\s+/, '_').gsub('.tmtheme', '').gsub(/\W/, '').gsub(/_+/, '_')
|
45
|
+
|
46
|
+
render["tags"] = []
|
47
|
+
|
48
|
+
@theme["settings"].each do |t|
|
49
|
+
if t["scope"]
|
50
|
+
class_name = t["name"].downcase.gsub(/\W/, ' ').gsub('.tmtheme', '').split(' ').collect{|s| s.capitalize}.join
|
51
|
+
if class_name == ""
|
52
|
+
class_name = "x" * t["name"].size
|
53
|
+
end
|
54
|
+
|
55
|
+
tag = {}
|
56
|
+
tag["selector"] = t["scope"]
|
57
|
+
render["tags"] << tag
|
58
|
+
|
59
|
+
begin_string = ""
|
60
|
+
pcount = 0
|
61
|
+
if s = t["settings"]
|
62
|
+
if s["background"]
|
63
|
+
begin_string << "\\colorbox[HTML]{#{normalize_color(s["background"])}}{"
|
64
|
+
else
|
65
|
+
begin_string << "{"
|
66
|
+
end
|
67
|
+
pcount += 1
|
68
|
+
if s["foreground"]
|
69
|
+
begin_string << "\\color[HTML]{#{normalize_color(s["foreground"])}}"
|
70
|
+
end
|
71
|
+
case s["fontStyle"]
|
72
|
+
when /bold/
|
73
|
+
begin_string << "\\textbf{"
|
74
|
+
pcount += 1
|
75
|
+
when /italic/
|
76
|
+
begin_string << "\\textit{"
|
77
|
+
pcount += 1
|
78
|
+
when /underline/
|
79
|
+
begin_string << "\\underline{"
|
80
|
+
pcount += 1
|
81
|
+
end
|
82
|
+
tag["begin"] = begin_string
|
83
|
+
tag["end"] = "}" * pcount
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
elsif ! t["name"]
|
88
|
+
if s = t["settings"]
|
89
|
+
codecolumn = "\\newcolumntype{C}{>{"
|
90
|
+
codecolumn << "\\color[HTML]{#{normalize_color(s["foreground"])}}" if s["foreground"]
|
91
|
+
codecolumn << "\\columncolor[HTML]{#{normalize_color(s["background"])}}" if s["background"]
|
92
|
+
codecolumn << "}l}"
|
93
|
+
|
94
|
+
numbercolumn = "\\newcolumntype{N}{>{"
|
95
|
+
numbercolumn << "\\color[HTML]{#{normalize_color(s["foreground"])}}" if s["foreground"]
|
96
|
+
numbercolumn << "\\columncolor[HTML]{#{normalize_color(s["selection"])}}" if s["selection"]
|
97
|
+
numbercolumn << "}l}"
|
98
|
+
|
99
|
+
tag = {}
|
100
|
+
tag["begin"] = "\\texttt{"
|
101
|
+
tag["end"] = "}&\\mbox{\\texttt{"
|
102
|
+
render["line-numbers"] = tag end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
render["filter"] = '@escaped.gsub(/(_|\{|\}|&|\#|\\\\)/, \'\\\\\\\\\1\').gsub(/~/, \'\\\\textasciitilde\').gsub(/ /,\'\\\\hspace{1ex}\').gsub(/\t/,\'\\\\hspace{3ex}\')'
|
107
|
+
|
108
|
+
tag = {}
|
109
|
+
tag["begin"] = ""
|
110
|
+
tag["end"] = "}}\\\\"
|
111
|
+
render["line"] = tag
|
112
|
+
|
113
|
+
tag = {}
|
114
|
+
tag["begin"] = <<END
|
115
|
+
#{codecolumn}
|
116
|
+
#{numbercolumn}
|
117
|
+
\\begin{longtable}{NC}
|
118
|
+
END
|
119
|
+
|
120
|
+
tag["end"] = <<END
|
121
|
+
\\end{longtable}
|
122
|
+
END
|
123
|
+
render["listing"] = tag
|
124
|
+
|
125
|
+
tag = {}
|
126
|
+
tag["begin"] = <<END
|
127
|
+
\\documentclass[a4paper,landscape]{article}
|
128
|
+
\\usepackage{xcolor}
|
129
|
+
\\usepackage{colortbl}
|
130
|
+
\\usepackage{longtable}
|
131
|
+
\\usepackage[left=2cm,top=1cm,right=3cm,nohead,nofoot]{geometry}
|
132
|
+
\\usepackage[T1]{fontenc}
|
133
|
+
\\usepackage[scaled]{beramono}
|
134
|
+
\\begin{document}
|
135
|
+
END
|
136
|
+
|
137
|
+
tag["end"] = <<END
|
138
|
+
\\end{document}
|
139
|
+
END
|
140
|
+
|
141
|
+
render["document"] = tag
|
142
|
+
|
143
|
+
File.open( File.join( base_dir, "latex", "#{standard_name}.render" ), "w" ) {|f| YAML.dump( render, f ) }
|
@@ -6,6 +6,8 @@ rescue LoadError
|
|
6
6
|
require 'plist'
|
7
7
|
end
|
8
8
|
|
9
|
+
base_dir = File.join( File.dirname(__FILE__), '..', 'render' )
|
10
|
+
|
9
11
|
|
10
12
|
|
11
13
|
def settings
|
@@ -26,9 +28,6 @@ def normalize_color color
|
|
26
28
|
result = ((mod1 * alpha + mod0 * ( 0x100 - alpha ) ) / 0x100).to_s(16).upcase.rjust(2, '0') + result
|
27
29
|
}
|
28
30
|
result = "#" + result
|
29
|
-
#result = "##{ big, small = ; ((big * (0xFF - small)) / 0xFF).to_s(16).upcase}"
|
30
|
-
#result = "##{ big, small = "0xFFFFFF10".hex.divmod( "0x100".hex); ((big * small) / 0xFF).to_s(16).upcase}"
|
31
|
-
#result = color[0...-2]
|
32
31
|
result
|
33
32
|
else
|
34
33
|
color
|
@@ -45,17 +44,17 @@ code_name = "pre.#{standard_name}"
|
|
45
44
|
render["tags"] = []
|
46
45
|
@theme["settings"].each do |t|
|
47
46
|
if t["scope"]
|
48
|
-
tag = {}
|
49
|
-
tag["selector"] = t["scope"]
|
50
47
|
class_name = t["name"].downcase.gsub(/\W/, ' ').gsub('.tmtheme', '').split(' ').collect{|s| s.capitalize}.join
|
51
48
|
if class_name == ""
|
52
49
|
class_name = "x" * t["name"].size
|
53
50
|
end
|
51
|
+
|
52
|
+
tag = {}
|
53
|
+
tag["selector"] = t["scope"]
|
54
54
|
tag["begin"] = "<span class=\"#{class_name}\">"
|
55
55
|
tag["end"] = "</span>"
|
56
56
|
render["tags"] << tag
|
57
57
|
|
58
|
-
|
59
58
|
if s = t["settings"]
|
60
59
|
style = {}
|
61
60
|
style["color"] = normalize_color(s["foreground"])
|
@@ -78,6 +77,7 @@ render["tags"] = []
|
|
78
77
|
style["color"] = normalize_color(s["foreground"])
|
79
78
|
style["background-color"] = normalize_color(s["selection"])
|
80
79
|
css[".line-numbers"] = style
|
80
|
+
|
81
81
|
tag = {}
|
82
82
|
tag["begin"] = "<span class=\"line-numbers\">"
|
83
83
|
tag["end"] = "</span>"
|
@@ -86,9 +86,67 @@ render["tags"] = []
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
|
89
|
+
render["filter"] = "CGI.escapeHTML( @escaped )"
|
90
|
+
|
91
|
+
tag = {}
|
92
|
+
tag["begin"] = ""
|
93
|
+
tag["end"] = ""
|
94
|
+
render["line"] = tag
|
95
|
+
|
96
|
+
|
97
|
+
tag = {}
|
98
|
+
tag["begin"] = "<pre class=\"#{standard_name}\">"
|
99
|
+
tag["end"] = "</pre>"
|
100
|
+
render["listing"] = tag
|
90
101
|
|
91
|
-
|
102
|
+
tag = {}
|
103
|
+
tag["begin"] = <<END
|
104
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
105
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
106
|
+
|
107
|
+
<head>
|
108
|
+
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
109
|
+
<meta http-equiv="cache-control" content="no-cache" />
|
110
|
+
<meta http-equiv="expires" content="3600" />
|
111
|
+
<meta name="revisit-after" content="2 days" />
|
112
|
+
<meta name="robots" content="index,follow" />
|
113
|
+
<meta name="publisher" content="Dichodaemon" />
|
114
|
+
<meta name="copyright" content="Dichodaemon" />
|
115
|
+
|
116
|
+
<meta name="author" content="Dichodaemon" />
|
117
|
+
<meta name="distribution" content="global" />
|
118
|
+
<meta name="description" content="Ocatarinetabellachithchix" />
|
119
|
+
<meta name="keywords" content="arzaversperia flexilimosos toves" />
|
120
|
+
<link rel="stylesheet" type="text/css" media="screen,projection,print" href="css/#{standard_name}.css" />
|
121
|
+
<title>#{standard_name}</title>
|
122
|
+
|
123
|
+
</head>
|
124
|
+
|
125
|
+
<body>
|
126
|
+
END
|
127
|
+
|
128
|
+
tag["end"] = <<END
|
129
|
+
<p>
|
130
|
+
<a href="http://validator.w3.org/check?uri=referer">
|
131
|
+
<img style="border:0"
|
132
|
+
src="http://www.w3.org/Icons/valid-xhtml10"
|
133
|
+
alt="Valid XHTML 1.0 Strict" height="31" width="88" />
|
134
|
+
</a>
|
135
|
+
<a href="http://jigsaw.w3.org/css-validator/check?uri=referer">
|
136
|
+
<img style="border:0;width:88px;height:31px"
|
137
|
+
src="http://jigsaw.w3.org/css-validator/images/vcss"
|
138
|
+
alt="Valid CSS!" />
|
139
|
+
</a>
|
140
|
+
</p>
|
141
|
+
</body>
|
142
|
+
</html>
|
143
|
+
END
|
144
|
+
|
145
|
+
render["document"] = tag
|
146
|
+
|
147
|
+
File.open( File.join( base_dir, "xhtml", "#{standard_name}.render" ), "w" ) {|f| YAML.dump( render, f ) }
|
148
|
+
|
149
|
+
File.open( File.join( base_dir, "xhtml", "files", "css", "#{standard_name}.css" ), "w" ) do |f|
|
92
150
|
css.each do |key, values|
|
93
151
|
if key == code_name
|
94
152
|
f.puts "#{code_name} {"
|
@@ -101,4 +159,4 @@ File.open( "#{standard_name}.css", "w" ) do |f|
|
|
101
159
|
end
|
102
160
|
f.puts "}"
|
103
161
|
end
|
104
|
-
end
|
162
|
+
end
|
data/bin/uv
CHANGED
@@ -12,16 +12,21 @@ require 'optparse'
|
|
12
12
|
require 'ostruct'
|
13
13
|
|
14
14
|
o = OpenStruct.new
|
15
|
+
o.copy_files = false
|
16
|
+
o.output = "xhtml"
|
17
|
+
o.headers = false
|
18
|
+
o.theme = "espresso_libre"
|
15
19
|
|
16
20
|
options = OptionParser.new
|
17
21
|
|
18
|
-
options.banner =<<END
|
22
|
+
options.banner =<<END
|
19
23
|
|
20
24
|
Usage: uv [options] input_file
|
21
25
|
|
22
|
-
Parses input_file
|
23
|
-
If no syntax is specified,
|
24
|
-
If no theme is specified, defaults
|
26
|
+
Parses input_file (or stdin, if no input_file is given) and
|
27
|
+
outputs the coresponding HTML to stdout. If no syntax is specified,
|
28
|
+
it tries to guess the best one. If no theme is specified, defaults
|
29
|
+
to espresso_libre.
|
25
30
|
|
26
31
|
Example:
|
27
32
|
|
@@ -36,10 +41,18 @@ Options:
|
|
36
41
|
|
37
42
|
END
|
38
43
|
|
44
|
+
options.on( "-c DIR", "--copy-files DIR", <<DESCRIPTION ) {|val| o.copy_files = val}
|
45
|
+
Copy the required files to the specified output directory (css, images, etc).
|
46
|
+
DESCRIPTION
|
47
|
+
|
39
48
|
options.on( "-s SYNTAX", "--syntax SYNTAX", <<DESCRIPTION, Uv.syntaxes) {|val| o.syntax = val}
|
40
49
|
The file's syntax (e.g. ruby, c++, etc.)
|
41
50
|
DESCRIPTION
|
42
51
|
|
52
|
+
options.on( "-o OUTPUT", "--output OUTPUT", <<DESCRIPTION) {|val| o.output = val}
|
53
|
+
The output format (xhtml, latex, etc.) default to xhtml
|
54
|
+
DESCRIPTION
|
55
|
+
|
43
56
|
options.on( "-t THEME", "--theme THEME", <<DESCRIPTION, Uv.themes) {|val| o.theme = val}
|
44
57
|
The theme to be used (e.g. amy, espresso_libre, etc.)
|
45
58
|
DESCRIPTION
|
@@ -50,7 +63,7 @@ DESCRIPTION
|
|
50
63
|
|
51
64
|
|
52
65
|
options.on( "-h", "--headers", <<DESCRIPTION ) {|val| o.headers = val}
|
53
|
-
Include headers, outputs a self-contained web page
|
66
|
+
Include headers, outputs a self-contained web page/document
|
54
67
|
DESCRIPTION
|
55
68
|
|
56
69
|
options.on( "-d", "--debug", <<DESCRIPTION ) {|val| o.debug = val}
|
@@ -85,6 +98,14 @@ elsif o.list
|
|
85
98
|
exit
|
86
99
|
end
|
87
100
|
|
101
|
+
if o.copy_files
|
102
|
+
unless File.exists?(o.copy_files)
|
103
|
+
STDERR.puts "The specified output directory: #{o.copy_files} does not exist."
|
104
|
+
exit -1
|
105
|
+
end
|
106
|
+
Uv.copy_files o.output, o.copy_files
|
107
|
+
end
|
108
|
+
|
88
109
|
o.filename = rest[0]
|
89
110
|
|
90
111
|
if o.filename && ! o.syntax
|
@@ -95,7 +116,7 @@ if o.filename && ! o.syntax
|
|
95
116
|
candidates.sort.each { |name, syntax| STDERR.puts "\t - " + name}
|
96
117
|
exit -1
|
97
118
|
end
|
98
|
-
o.syntax = candidates.first.first
|
119
|
+
o.syntax = candidates.first.first unless candidates.size == 0
|
99
120
|
end
|
100
121
|
|
101
122
|
unless o.syntax
|
@@ -114,49 +135,5 @@ if o.debug
|
|
114
135
|
exit
|
115
136
|
end
|
116
137
|
|
117
|
-
o.theme
|
118
|
-
o.stylesheet = "#{o.theme}.css"
|
138
|
+
puts Uv.parse( o.text, o.output, o.syntax, ! o.lines, o.theme, o.headers )
|
119
139
|
|
120
|
-
puts <<END
|
121
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
122
|
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
123
|
-
|
124
|
-
<head>
|
125
|
-
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
126
|
-
<meta http-equiv="cache-control" content="no-cache" />
|
127
|
-
<meta http-equiv="expires" content="3600" />
|
128
|
-
<meta name="revisit-after" content="2 days" />
|
129
|
-
<meta name="robots" content="index,follow" />
|
130
|
-
<meta name="publisher" content="Dichodaemon" />
|
131
|
-
<meta name="copyright" content="Dichodaemon" />
|
132
|
-
|
133
|
-
<meta name="author" content="Dichodaemon" />
|
134
|
-
<meta name="distribution" content="global" />
|
135
|
-
<meta name="description" content="Ocatarinetabellachithchix" />
|
136
|
-
<meta name="keywords" content="arzaversperia flexilimosos toves" />
|
137
|
-
<link rel="stylesheet" type="text/css" media="screen,projection,print" href="css/#{o.stylesheet}" />
|
138
|
-
<title>#{o.theme}</title>
|
139
|
-
|
140
|
-
</head>
|
141
|
-
|
142
|
-
<body>
|
143
|
-
END
|
144
|
-
|
145
|
-
puts Uv.parse( o.text, "xhtml", o.syntax, ! o.lines, o.theme )
|
146
|
-
|
147
|
-
puts <<END
|
148
|
-
<p>
|
149
|
-
<a href="http://validator.w3.org/check?uri=referer">
|
150
|
-
<img style="border:0"
|
151
|
-
src="http://www.w3.org/Icons/valid-xhtml10"
|
152
|
-
alt="Valid XHTML 1.0 Strict" height="31" width="88" />
|
153
|
-
</a>
|
154
|
-
<a href="http://jigsaw.w3.org/css-validator/check?uri=referer">
|
155
|
-
<img style="border:0;width:88px;height:31px"
|
156
|
-
src="http://jigsaw.w3.org/css-validator/images/vcss"
|
157
|
-
alt="Valid CSS!" />
|
158
|
-
</a>
|
159
|
-
</p>
|
160
|
-
</body>
|
161
|
-
</html>
|
162
|
-
END
|
data/lib/uv.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'textpow'
|
2
3
|
require 'uv/html_processor.rb'
|
3
4
|
|
@@ -8,6 +9,13 @@ module Uv
|
|
8
9
|
result = []
|
9
10
|
result << File.join(File.dirname(__FILE__), ".." )
|
10
11
|
end
|
12
|
+
|
13
|
+
def Uv.copy_files output, output_dir
|
14
|
+
Uv.path.each do |dir|
|
15
|
+
dir_name = File.join( dir, "render", output, "files" )
|
16
|
+
FileUtils.cp_r( Dir.glob(File.join( dir_name, "." )), output_dir ) if File.exists?( dir_name )
|
17
|
+
end
|
18
|
+
end
|
11
19
|
|
12
20
|
def Uv.init_syntaxes
|
13
21
|
@syntaxes = {}
|
@@ -15,7 +23,7 @@ module Uv
|
|
15
23
|
@syntaxes[File.basename(f, '.syntax')] = Textpow::SyntaxNode.load( f )
|
16
24
|
end
|
17
25
|
end
|
18
|
-
|
26
|
+
|
19
27
|
def Uv.syntaxes
|
20
28
|
Dir.glob( File.join(File.dirname(__FILE__), '..', 'syntax', '*.syntax') ).collect do |f|
|
21
29
|
File.basename(f, '.syntax')
|
@@ -55,18 +63,15 @@ module Uv
|
|
55
63
|
result
|
56
64
|
end
|
57
65
|
|
58
|
-
def Uv.parse text, output = "xhtml", syntax_name = nil, line_numbers = false, render_style = "classic"
|
66
|
+
def Uv.parse text, output = "xhtml", syntax_name = nil, line_numbers = false, render_style = "classic", headers = false
|
59
67
|
init_syntaxes unless @syntaxes
|
60
68
|
renderer = File.join( File.dirname(__FILE__), '..',"render", output,"#{render_style}.render")
|
69
|
+
raise( ArgumentError, "Output for #{output} is not yet implemented" ) unless File.exists?(renderer)
|
61
70
|
css_class = render_style
|
62
71
|
render_options = YAML.load( File.open( renderer ) )
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
"<pre class =\"#{css_class}\">#{render_processor.string}</pre>"
|
67
|
-
else
|
68
|
-
raise( ArgumentError, "Output for #{output} is not yet implemented" )
|
69
|
-
end
|
72
|
+
render_processor = HtmlProcessor.new( render_options, line_numbers, headers )
|
73
|
+
@syntaxes[syntax_name].parse( text, render_processor )
|
74
|
+
render_processor.string
|
70
75
|
end
|
71
76
|
|
72
77
|
def Uv.debug text, syntax_name
|