redclothcoderay 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ *0.1.2 (November 25th 2008)
2
+
3
+ * Fixed some issues with whitespaces before <source> tags
4
+
5
+ * Removed String#has_newlines?, doing it "by hand" instead.
6
+
1
7
  *0.1.1 (November 18th 2008)
2
8
 
3
9
  * Removed any references to Rails
data/Manifest CHANGED
@@ -4,5 +4,4 @@ Manifest
4
4
  MIT-LICENSE
5
5
  Rakefile
6
6
  README
7
- redclothcoderay.gemspec
8
7
  test/redclothcoderay_test.rb
data/README CHANGED
@@ -11,7 +11,7 @@ A short summary of what you can do:
11
11
 
12
12
  Installation as usual:
13
13
 
14
- sudo gem install redcloth
14
+ sudo gem install redclothcoderay
15
15
 
16
16
 
17
17
  == Using
@@ -21,9 +21,19 @@ You have to specify that you want to use refs_syntax_highlighter when calling Re
21
21
  require 'rubygems'
22
22
  require 'redcloth'
23
23
  require 'coderay'
24
- require 'redclothcoderay'
24
+ require 'redcloth_with_coderay'
25
25
 
26
26
  RedCloth.new('I am *bold* and <source>@hi_tech</source>').to_html(:textile, :refs_syntax_highlighter)
27
+
28
+ == In Ruby on Rails
29
+
30
+ Ruby on Rails provides you with a textilize helper. You probably want to override it. Something like this is probably sensible:
31
+
32
+ module ApplicationHelper
33
+ def textilize(text)
34
+ RedCloth.new(text).to_html(:textile, :refs_syntax_highlighter)
35
+ end
36
+ end
27
37
 
28
38
  == Example
29
39
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('redclothcoderay', '0.1.1') do |p|
5
+ Echoe.new('redclothcoderay', '0.1.2') do |p|
6
6
  p.description = "Integrates CodeRay with RedCloth by adding a <source> tag."
7
7
  p.url = "http://redclothcoderay.rubyforge.org/"
8
8
  p.author = "August Lilleaas"
@@ -1,26 +1,20 @@
1
- class String
2
- # Utility method to check if a string contains newlines.
3
- def contains_newlines?
4
- self =~ /\n/
5
- end
6
- end
7
-
8
1
  module RedclothWithCoderay
9
2
  SINGLE_LINE = '<code class="inline_code">%s</code>'
10
3
  MULTI_LINE = '<pre><code class="multiline_code">%s</code></pre>'
11
- WRAPPER = '<notextile>%s</notextile>'
12
- SOURCE_TAG_REGEXP = /([\t\n]?<source(?:\:([a-z]+))?>(.+?)<\/source>[\t\n]?)/m
4
+ SOURCE_TAG_REGEXP = /(([\t\n])?<source(?:\:([a-z]+))?>(.+?)<\/source>[\t\n]?)/m
13
5
 
14
6
  # The RedCloth extension that performs the syntax highlighting.
15
7
  def refs_syntax_highlighter(text)
16
8
  text.gsub!(SOURCE_TAG_REGEXP) do |m|
17
9
  all_of_it = $~[1]
18
- lang = ($~[2] || :ruby).to_sym
19
- code = $~[3].strip
10
+ whitespace_before = $~[2]
11
+ lang = ($~[3] || :ruby).to_sym
12
+ code = $~[4].strip
20
13
 
21
- wrap_in = all_of_it.contains_newlines? ? MULTI_LINE : SINGLE_LINE
14
+ wrap_in = all_of_it =~ /\n/ ? MULTI_LINE : SINGLE_LINE
22
15
  highlighted = wrap_in % CodeRay.scan(code, lang).div(:wrap => nil, :css => :class)
23
- WRAPPER % highlighted
16
+
17
+ "#{whitespace_before}<notextile>#{highlighted}</notextile>"
24
18
  end
25
19
  end
26
20
  end
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{redclothcoderay}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["August Lilleaas"]
9
- s.date = %q{2008-11-18}
9
+ s.date = %q{2008-11-25}
10
10
  s.description = %q{Integrates CodeRay with RedCloth by adding a <source> tag.}
11
11
  s.email = %q{augustlilleaas@gmail.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "lib/redcloth_with_coderay.rb", "README"]
13
- s.files = ["CHANGELOG", "lib/redcloth_with_coderay.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README", "redclothcoderay.gemspec", "test/redclothcoderay_test.rb"]
13
+ s.files = ["CHANGELOG", "lib/redcloth_with_coderay.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README", "test/redclothcoderay_test.rb", "redclothcoderay.gemspec"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://redclothcoderay.rubyforge.org/}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Redclothcoderay", "--main", "README"]
@@ -45,8 +45,18 @@ class PluginTest < Test::Unit::TestCase
45
45
  def test_parsing_other_languages
46
46
  text = %Q{Hello, this is *textilized* with some <source:html><p>HTML code</p></source>!}
47
47
  result = RedCloth.new(text).to_html(:textile, :refs_syntax_highlighter)
48
-
48
+
49
49
  assert result.include?(%Q{<strong>textilized</strong>})
50
50
  assert result.include?(%Q{<code class="inline_code"><span class="ta">&lt;p&gt;</span>HTML code<span class="ta">&lt;/p&gt;</span></code>})
51
51
  end
52
+
53
+ def test_after_a_header
54
+ text = %Q{h2. Hello, world.
55
+
56
+ <source>
57
+ hello_world
58
+ </source>}
59
+ result = RedCloth.new(text).to_html(:textile, :refs_syntax_highlighter)
60
+ assert result.include?(%Q{<h2>Hello, world.</h2>})
61
+ end
52
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redclothcoderay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - August Lilleaas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-18 00:00:00 +01:00
12
+ date: 2008-11-25 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -59,8 +59,8 @@ files:
59
59
  - MIT-LICENSE
60
60
  - Rakefile
61
61
  - README
62
- - redclothcoderay.gemspec
63
62
  - test/redclothcoderay_test.rb
63
+ - redclothcoderay.gemspec
64
64
  has_rdoc: true
65
65
  homepage: http://redclothcoderay.rubyforge.org/
66
66
  post_install_message: