smartgen_syntaxhighlighter 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Gemfile.lock +14 -10
- data/lib/smartgen_syntaxhighlighter/pre_processor.rb +9 -9
- data/lib/smartgen_syntaxhighlighter/version.rb +1 -1
- metadata +5 -5
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
smartgen_syntaxhighlighter (0.
|
4
|
+
smartgen_syntaxhighlighter (0.2.0)
|
5
5
|
smartgen
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
RedCloth (4.2.3)
|
11
|
-
activesupport (3.0.
|
11
|
+
activesupport (3.0.4)
|
12
12
|
archive-tar-minitar (0.5.2)
|
13
13
|
bluecloth (2.0.10)
|
14
14
|
columnize (0.3.2)
|
15
15
|
diff-lcs (1.1.2)
|
16
|
+
directory_watcher (1.3.2)
|
16
17
|
i18n (0.5.0)
|
17
18
|
linecache (0.43)
|
18
19
|
linecache19 (0.5.11)
|
19
20
|
ruby_core_source (>= 0.1.4)
|
20
|
-
|
21
|
-
|
22
|
-
rspec-
|
23
|
-
rspec-
|
24
|
-
|
25
|
-
rspec-
|
21
|
+
nokogiri (1.4.4)
|
22
|
+
rspec (2.5.0)
|
23
|
+
rspec-core (~> 2.5.0)
|
24
|
+
rspec-expectations (~> 2.5.0)
|
25
|
+
rspec-mocks (~> 2.5.0)
|
26
|
+
rspec-core (2.5.1)
|
27
|
+
rspec-expectations (2.5.0)
|
26
28
|
diff-lcs (~> 1.1.2)
|
27
|
-
rspec-mocks (2.
|
29
|
+
rspec-mocks (2.5.0)
|
28
30
|
ruby-debug (0.10.4)
|
29
31
|
columnize (>= 0.1)
|
30
32
|
ruby-debug-base (~> 0.10.4.0)
|
@@ -40,11 +42,13 @@ GEM
|
|
40
42
|
ruby-debug-base19 (>= 0.11.19)
|
41
43
|
ruby_core_source (0.1.4)
|
42
44
|
archive-tar-minitar (>= 0.5.2)
|
43
|
-
smartgen (0.0
|
45
|
+
smartgen (0.3.0)
|
44
46
|
RedCloth (>= 4.2.3)
|
45
47
|
activesupport (>= 2.3.5)
|
46
48
|
bluecloth (>= 2.0.9)
|
49
|
+
directory_watcher (>= 1.3.2)
|
47
50
|
i18n (>= 0.5.0)
|
51
|
+
nokogiri (>= 1.4.4)
|
48
52
|
thor (>= 0.14.6)
|
49
53
|
thor (0.14.6)
|
50
54
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class SyntaxhighlighterPreProcessor
|
2
2
|
attr_reader :options
|
3
|
-
|
3
|
+
|
4
4
|
def initialize(opts={})
|
5
5
|
@enclose_with_tag = opts.delete(:enclose_with_tag)
|
6
6
|
@options = merge_with_defaults(opts)
|
7
7
|
end
|
8
|
-
|
9
|
-
def process(body)
|
8
|
+
|
9
|
+
def process(body, metadata={})
|
10
10
|
body.gsub(%r{<(ruby|js|javascript|shell|bash|html|xml|as3|plain)>(.*?)</\1>}m) do |match|
|
11
11
|
escaped_code = ERB::Util.h($2)
|
12
12
|
|
@@ -24,25 +24,25 @@ class SyntaxhighlighterPreProcessor
|
|
24
24
|
%{#{enclose_start_tag}<pre class="#{to_class_attribute}">#{escaped_code}</pre>#{enclose_end_tag}}
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
private
|
29
29
|
def enclose_start_tag
|
30
30
|
"<#{@enclose_with_tag}>" if @enclose_with_tag
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def enclose_end_tag
|
34
34
|
"</#{@enclose_with_tag}>" if @enclose_with_tag
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def to_class_attribute
|
38
38
|
sorted_options.map { |key, value| "#{key}: #{value}" }.join('; ')
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def sorted_options
|
42
42
|
options.sort { |first_pair, second_pair| first_pair[0].to_s <=> second_pair[0].to_s }
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def merge_with_defaults(opts)
|
46
46
|
{ :gutter => false, :toolbar => false }.merge(opts)
|
47
47
|
end
|
48
|
-
end
|
48
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Vicente Mundim
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-02-10 00:00:00 -02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -102,5 +102,5 @@ rubygems_version: 1.3.7
|
|
102
102
|
signing_key:
|
103
103
|
specification_version: 3
|
104
104
|
summary: Adds Syntax Highlighter support for smartgen
|
105
|
-
test_files:
|
106
|
-
|
105
|
+
test_files: []
|
106
|
+
|