redclothcoderay 0.3.0 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -12
- data/lib/redclothcoderay.rb +1 -1
- data/redclothcoderay.gemspec +7 -6
- data/test/coderay_options_test.rb +7 -0
- data/test/redclothcoderay_test.rb +3 -3
- data/test/test_helper.rb +1 -0
- metadata +10 -7
data/README.rdoc
CHANGED
@@ -6,6 +6,7 @@ A short summary of what you can do:
|
|
6
6
|
|
7
7
|
* <source>foo</source> - Use this tag to produce CodeRay highlighted HTML for the contents within that tag. The language defaults to Ruby.
|
8
8
|
* <source:css>foo</source> - Highlight as usual, but highlight as CSS. Supports everything CodeRay supports. Refer to the CodeRay documentation for a list of supported languages.
|
9
|
+
* You can also use the <code> tag.
|
9
10
|
|
10
11
|
== Installing
|
11
12
|
|
@@ -19,28 +20,18 @@ You can also install the gem via github, to get the latest HEAD.
|
|
19
20
|
|
20
21
|
== Using
|
21
22
|
|
22
|
-
|
23
|
+
A short example.
|
23
24
|
|
24
25
|
require 'rubygems'
|
25
26
|
require 'redcloth'
|
26
27
|
require 'coderay'
|
27
28
|
require 'redclothcoderay'
|
28
29
|
|
29
|
-
RedCloth.new('I am *bold* and <source>@hi_tech</source>').to_html
|
30
|
-
|
31
|
-
You can also use the always_on method to always use the refs_syntax_highlighter parser when calling to_html
|
32
|
-
|
33
|
-
RedclothCoderay.always_on
|
30
|
+
RedCloth.new('I am *bold* and <source>@hi_tech</source>').to_html
|
34
31
|
|
35
32
|
You can specify the CodeRay options, too (defaults to RedclothCoderay::CODERAY_OPTIONS).
|
36
33
|
|
37
34
|
RedclothCoderay.coderay_options :line_numbers => :table
|
38
|
-
|
39
|
-
== In Ruby on Rails
|
40
|
-
|
41
|
-
In an initializer (config/initializers/[anything].rb) or at the bottom of environment.rb, add this line:
|
42
|
-
|
43
|
-
Redclothcoderay.always_on
|
44
35
|
|
45
36
|
== Example
|
46
37
|
|
data/lib/redclothcoderay.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module RedclothCoderay
|
2
2
|
SINGLE_LINE = '<code class="inline_code">%s</code>'
|
3
|
-
MULTI_LINE = '<
|
3
|
+
MULTI_LINE = '<div class="multiline_code">%s</div>'
|
4
4
|
SOURCE_TAG_REGEXP = /(([\t\n])?<source(?:\:([a-z]+))?>(.+?)<\/source>([\t\n])?)/m
|
5
5
|
CODERAY_OPTIONS = {:wrap => nil, :css => :class}
|
6
6
|
|
data/redclothcoderay.gemspec
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "redclothcoderay"
|
3
|
-
s.version = "0.3.
|
4
|
-
s.
|
5
|
-
s.
|
3
|
+
s.version = "0.3.5"
|
4
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
5
|
+
s.date = Time.now
|
6
|
+
s.authors = ['August Lilleaas', 'Matias Korhonen']
|
6
7
|
s.email = "augustlilleaas@gmail.com"
|
8
|
+
s.files = ["lib", "lib/redclothcoderay.rb", "MIT-LICENSE", "Rakefile", "README.rdoc", "redclothcoderay.gemspec", "test", "test/coderay_options_test.rb", "test/redclothcoderay_test.rb", "test/test_helper.rb"]
|
7
9
|
s.rubyforge_project = "redclothcoderay"
|
8
10
|
s.has_rdoc = true
|
9
11
|
s.add_dependency('RedCloth')
|
10
12
|
s.add_dependency('coderay')
|
11
13
|
s.summary = "Integrates CodeRay with RedCloth by adding a <source> tag."
|
12
14
|
s.homepage = "http://redclothcoderay.rubyforge.org"
|
13
|
-
s.
|
14
|
-
|
15
|
-
end
|
15
|
+
s.description = %q{Adds CodeRay syntax highlighting support to RedCloth, with a ‘source’ tag.}
|
16
|
+
end
|
@@ -8,4 +8,11 @@ class CoderayOptionsTest < Test::Unit::TestCase
|
|
8
8
|
assert_equal :table, RedclothCoderay::CODERAY_OPTIONS[:line_numbers]
|
9
9
|
assert RedCloth.new("<source>ugly_inline :stuff</source>").to_html(:refs_syntax_highlighter).include?(%{<table class="CodeRay"})
|
10
10
|
end
|
11
|
+
|
12
|
+
def test_it_with_code_tag
|
13
|
+
RedclothCoderay.coderay_options :line_numbers => :table
|
14
|
+
assert_equal :table, RedclothCoderay::CODERAY_OPTIONS[:line_numbers]
|
15
|
+
assert RedCloth.new("<code>ugly_inline :stuff</code>").to_html(:refs_syntax_highlighter).include?(%{<table class="CodeRay"})
|
16
|
+
end
|
17
|
+
|
11
18
|
end
|
@@ -19,7 +19,7 @@ class PluginTest < Test::Unit::TestCase
|
|
19
19
|
result = RedCloth.new(text).to_html
|
20
20
|
|
21
21
|
assert result.include?(%Q{<strong>textilized</strong>})
|
22
|
-
assert result.include?(%Q{<
|
22
|
+
assert result.include?(%Q{<div class="multiline_code">})
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_one_liner_multiline_code
|
@@ -32,7 +32,7 @@ class PluginTest < Test::Unit::TestCase
|
|
32
32
|
result = RedCloth.new(text).to_html
|
33
33
|
|
34
34
|
assert result.include?(%Q{<strong>textilized</strong>})
|
35
|
-
assert result.include?(%Q{<
|
35
|
+
assert result.include?(%Q{<div class=\"multiline_code\">hello_to_you</div>})
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_parsing_other_languages
|
@@ -71,4 +71,4 @@ end
|
|
71
71
|
assert result.include?(%{[<span class="sy">:address_street</span>, <span class="sy">:street</span>],})
|
72
72
|
assert result.include?(%{composed_of <span class="sy">:address</span>, <span class="sy">:class_name</span> => <span class="s"><span class="dl">"</span><span class="k">Address</span><span class="dl">"</span></span>,})
|
73
73
|
end
|
74
|
-
end
|
74
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redclothcoderay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- August Lilleaas
|
8
|
+
- Matias Korhonen
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-
|
13
|
+
date: 2009-10-10 00:00:00 +03:00
|
13
14
|
default_executable:
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
@@ -32,12 +33,12 @@ dependencies:
|
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: "0"
|
34
35
|
version:
|
35
|
-
description:
|
36
|
+
description: "Adds CodeRay syntax highlighting support to RedCloth, with a \xE2\x80\x98source\xE2\x80\x99 tag."
|
36
37
|
email: augustlilleaas@gmail.com
|
37
38
|
executables: []
|
38
39
|
|
39
|
-
extensions:
|
40
|
-
|
40
|
+
extensions: []
|
41
|
+
|
41
42
|
extra_rdoc_files: []
|
42
43
|
|
43
44
|
files:
|
@@ -51,6 +52,8 @@ files:
|
|
51
52
|
- test/test_helper.rb
|
52
53
|
has_rdoc: true
|
53
54
|
homepage: http://redclothcoderay.rubyforge.org
|
55
|
+
licenses: []
|
56
|
+
|
54
57
|
post_install_message:
|
55
58
|
rdoc_options: []
|
56
59
|
|
@@ -71,9 +74,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
74
|
requirements: []
|
72
75
|
|
73
76
|
rubyforge_project: redclothcoderay
|
74
|
-
rubygems_version: 1.3.
|
77
|
+
rubygems_version: 1.3.5
|
75
78
|
signing_key:
|
76
|
-
specification_version:
|
79
|
+
specification_version: 3
|
77
80
|
summary: Integrates CodeRay with RedCloth by adding a <source> tag.
|
78
81
|
test_files: []
|
79
82
|
|