BBRedCloth 0.8.4 → 0.9.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/BBRedCloth.gemspec +12 -15
  2. data/CHANGELOG +160 -3
  3. data/Manifest +0 -18
  4. data/README.textile +17 -2
  5. data/Rakefile +14 -12
  6. data/ext/redcloth_scan/redcloth.h +65 -23
  7. data/ext/redcloth_scan/redcloth_attributes.c +381 -387
  8. data/ext/redcloth_scan/redcloth_bbcode.c +141 -140
  9. data/ext/redcloth_scan/redcloth_bbcode_inline.c +72 -71
  10. data/ext/redcloth_scan/redcloth_inline.c +7468 -9976
  11. data/ext/redcloth_scan/redcloth_scan.c +22883 -8946
  12. data/lib/redcloth.rb +7 -0
  13. data/lib/redcloth/formatters/base.rb +26 -20
  14. data/lib/redcloth/formatters/html.rb +39 -96
  15. data/lib/redcloth/formatters/latex.rb +11 -11
  16. data/lib/redcloth/formatters/latex_entities.yml +8 -8
  17. data/lib/redcloth/textile_doc.rb +0 -5
  18. data/lib/redcloth/version.rb +4 -4
  19. data/test/basic.yml +131 -13
  20. data/test/code.yml +15 -7
  21. data/test/helper.rb +17 -13
  22. data/test/html.yml +38 -1
  23. data/test/images.yml +51 -0
  24. data/test/links.yml +35 -1
  25. data/test/lists.yml +180 -1
  26. data/test/table.yml +86 -0
  27. data/test/test_custom_tags.rb +1 -1
  28. data/test/test_erb.rb +1 -1
  29. data/test/test_extensions.rb +1 -1
  30. data/test/test_formatters.rb +1 -1
  31. data/test/test_parser.rb +1 -1
  32. data/test/test_restrictions.rb +1 -5
  33. data/test/textism.yml +2 -16
  34. data/test/threshold.yml +4 -19
  35. metadata +34 -71
  36. data/ext/mingw-rbconfig.rb +0 -176
  37. data/ext/redcloth_scan/redcloth_attributes.c.rl +0 -56
  38. data/ext/redcloth_scan/redcloth_attributes.java.rl +0 -96
  39. data/ext/redcloth_scan/redcloth_attributes.rl +0 -33
  40. data/ext/redcloth_scan/redcloth_bbcode.c.rl +0 -60
  41. data/ext/redcloth_scan/redcloth_bbcode.rl +0 -127
  42. data/ext/redcloth_scan/redcloth_bbcode_inline.c.rl +0 -72
  43. data/ext/redcloth_scan/redcloth_bbcode_inline.rl +0 -85
  44. data/ext/redcloth_scan/redcloth_common.c.rl +0 -19
  45. data/ext/redcloth_scan/redcloth_common.java.rl +0 -18
  46. data/ext/redcloth_scan/redcloth_common.rl +0 -111
  47. data/ext/redcloth_scan/redcloth_inline.c.rl +0 -205
  48. data/ext/redcloth_scan/redcloth_inline.java.rl +0 -108
  49. data/ext/redcloth_scan/redcloth_inline.rl +0 -176
  50. data/ext/redcloth_scan/redcloth_scan.c.rl +0 -236
  51. data/ext/redcloth_scan/redcloth_scan.java.rl +0 -555
  52. data/ext/redcloth_scan/redcloth_scan.rl +0 -426
  53. data/extras/ragel_profiler.rb +0 -73
@@ -1,31 +1,28 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = %q{BBRedCloth}
5
- s.version = "0.8.4"
4
+ s.name = "BBRedCloth"
5
+ s.version = "0.9.0.alpha1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ryan Alyea"]
9
- s.date = %q{2011-06-12}
10
- s.default_executable = %q{redcloth}
11
- s.description = %q{BBRedCloth-0.8.4 - Textile parser for Ruby. Includes BBCode additions.
12
- http://redcloth.org/}
13
- s.email = %q{ryan@fangamer.com}
9
+ s.date = "2021-01-02"
10
+ s.description = "BBRedCloth-0.9.0.alpha1 - Textile parser for Ruby. Includes BBCode additions.\nhttp://redcloth.org/"
11
+ s.email = "ryan@fangamer.com"
14
12
  s.executables = ["redcloth"]
15
13
  s.extensions = ["ext/redcloth_scan/extconf.rb"]
16
14
  s.extra_rdoc_files = ["CHANGELOG", "lib/case_sensitive_require/RedCloth.rb", "lib/redcloth/erb_extension.rb", "lib/redcloth/formatters/base.rb", "lib/redcloth/formatters/html.rb", "lib/redcloth/formatters/latex.rb", "lib/redcloth/textile_doc.rb", "lib/redcloth/version.rb", "lib/redcloth.rb", "README.textile"]
17
- s.files = ["bin/redcloth", "CHANGELOG", "COPYING", "ext/mingw-rbconfig.rb", "ext/redcloth_scan/extconf.rb", "ext/redcloth_scan/redcloth.h", "ext/redcloth_scan/redcloth_attributes.c.rl", "ext/redcloth_scan/redcloth_attributes.java.rl", "ext/redcloth_scan/redcloth_attributes.rl", "ext/redcloth_scan/redcloth_bbcode.c.rl", "ext/redcloth_scan/redcloth_bbcode.rl", "ext/redcloth_scan/redcloth_bbcode_inline.rl", "ext/redcloth_scan/redcloth_bbcode_inline.c.rl", "ext/redcloth_scan/redcloth_common.c.rl", "ext/redcloth_scan/redcloth_common.java.rl", "ext/redcloth_scan/redcloth_common.rl", "ext/redcloth_scan/redcloth_inline.c.rl", "ext/redcloth_scan/redcloth_inline.java.rl", "ext/redcloth_scan/redcloth_inline.rl", "ext/redcloth_scan/redcloth_scan.c.rl", "ext/redcloth_scan/redcloth_scan.java.rl", "ext/redcloth_scan/redcloth_scan.rl", "extras/ragel_profiler.rb", "lib/case_sensitive_require/RedCloth.rb", "lib/redcloth/erb_extension.rb", "lib/redcloth/formatters/base.rb", "lib/redcloth/formatters/html.rb", "lib/redcloth/formatters/latex.rb", "lib/redcloth/formatters/latex_entities.yml", "lib/redcloth/textile_doc.rb", "lib/redcloth/version.rb", "lib/redcloth.rb", "Manifest", "Rakefile", "README.textile", "setup.rb", "test/basic.yml", "test/code.yml", "test/definitions.yml", "test/extra_whitespace.yml", "test/filter_html.yml", "test/filter_pba.yml", "test/helper.rb", "test/html.yml", "test/images.yml", "test/instiki.yml", "test/links.yml", "test/lists.yml", "test/poignant.yml", "test/sanitize_html.yml", "test/table.yml", "test/test_custom_tags.rb", "test/test_erb.rb", "test/test_extensions.rb", "test/test_formatters.rb", "test/test_parser.rb", "test/test_restrictions.rb", "test/textism.yml", "test/threshold.yml", "test/validate_fixtures.rb", "BBRedCloth.gemspec", "ext/redcloth_scan/redcloth_attributes.c", "ext/redcloth_scan/redcloth_inline.c", "ext/redcloth_scan/redcloth_scan.c", "ext/redcloth_scan/redcloth_bbcode.c", "ext/redcloth_scan/redcloth_bbcode_inline.c"]
18
- s.homepage = %q{http://redcloth.org}
19
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "BBRedCloth", "--main", "README.textile"]
15
+ s.files = ["bin/redcloth", "CHANGELOG", "COPYING", "ext/redcloth_scan/extconf.rb", "ext/redcloth_scan/redcloth.h", "lib/case_sensitive_require/RedCloth.rb", "lib/redcloth/erb_extension.rb", "lib/redcloth/formatters/base.rb", "lib/redcloth/formatters/html.rb", "lib/redcloth/formatters/latex.rb", "lib/redcloth/formatters/latex_entities.yml", "lib/redcloth/textile_doc.rb", "lib/redcloth/version.rb", "lib/redcloth.rb", "Manifest", "Rakefile", "README.textile", "setup.rb", "test/basic.yml", "test/code.yml", "test/definitions.yml", "test/extra_whitespace.yml", "test/filter_html.yml", "test/filter_pba.yml", "test/helper.rb", "test/html.yml", "test/images.yml", "test/instiki.yml", "test/links.yml", "test/lists.yml", "test/poignant.yml", "test/sanitize_html.yml", "test/table.yml", "test/test_custom_tags.rb", "test/test_erb.rb", "test/test_extensions.rb", "test/test_formatters.rb", "test/test_parser.rb", "test/test_restrictions.rb", "test/textism.yml", "test/threshold.yml", "test/validate_fixtures.rb", "BBRedCloth.gemspec", "ext/redcloth_scan/redcloth_attributes.c", "ext/redcloth_scan/redcloth_inline.c", "ext/redcloth_scan/redcloth_scan.c", "ext/redcloth_scan/redcloth_bbcode.c", "ext/redcloth_scan/redcloth_bbcode_inline.c"]
16
+ s.homepage = "http://redcloth.org"
17
+ s.rdoc_options = ["--line-numbers", "--title", "BBRedCloth", "--main", "README.textile"]
20
18
  s.require_paths = ["lib", "ext", "lib/case_sensitive_require"]
21
19
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.4")
22
- s.rubyforge_project = %q{bbredcloth}
23
- s.rubygems_version = %q{1.3.7}
24
- s.summary = %q{BBRedCloth-0.8.4 - Textile parser for Ruby. Includes BBCode additions. http://redcloth.org/}
25
- s.test_files = ["test/test_custom_tags.rb", "test/test_erb.rb", "test/test_extensions.rb", "test/test_formatters.rb", "test/test_parser.rb", "test/test_restrictions.rb"]
20
+ s.rubyforge_project = "bbredcloth"
21
+ s.rubygems_version = "1.8.23.2"
22
+ s.summary = "BBRedCloth-0.9.0.alpha1 - Textile parser for Ruby. Includes BBCode additions. http://redcloth.org/"
23
+ s.test_files = ["test/test_formatters.rb", "test/test_custom_tags.rb", "test/test_extensions.rb", "test/test_restrictions.rb", "test/test_erb.rb", "test/test_parser.rb"]
26
24
 
27
25
  if s.respond_to? :specification_version then
28
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
29
26
  s.specification_version = 3
30
27
 
31
28
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
data/CHANGELOG CHANGED
@@ -1,4 +1,161 @@
1
- === Edge
1
+ == 4.3.1 / May 17th, 2016
2
+
3
+ * Fix additional case for CVE-2012-6684 [Joshua Siler]
4
+
5
+ == 4.3.0 / April 29th, 2016
6
+
7
+ * Remove JRuby and Windows cross compilation and support
8
+ * Add Ruby 2.2.3 testing and support
9
+
10
+ * include CVE-2012-6684 fix [Tomas Pospisek]
11
+ * fix by [Antonio Terceiro]
12
+ * see http://sources.debian.net/src/ruby-redcloth/4.2.9-4/debian/patches/0001-Filter-out-javascript-links-when-using-filter_html-o.patch/
13
+ * vulnerability reported by [Kousuke Ebihara]
14
+ * see http://co3k.org/blog/redcloth-unfixed-xss-en
15
+
16
+ == 4.2.9.1 / February 24, 2015
17
+
18
+ * Lazy-load latex_entities.yml [Charlie Somerville]
19
+
20
+ == 4.2.9 / November 25, 2011
21
+
22
+ * Fix RbConfig / Config warning in Ruby 1.9.3. [Steve Purcell, Robert Gleeson, and unclaimedbaggage]
23
+ * Use RSTRING_NOT_MODIFIED header for Rubinius [Dirkjan Bussink]
24
+
25
+ == 4.2.8 / August 17, 2011
26
+
27
+ * Do not treat warnings as errors so it compiles cleanly. [Tomasz Wałkuski]
28
+
29
+ == 4.2.7 / February 10, 2011
30
+
31
+ * Fixed typo in gemspec to make case-sensitive require work. [Gabe da Silveira]
32
+ * Tested installing the gem and requiring it with both cases on Ubuntu 8.04, 10.10 and OS X Version 10.6.6.
33
+ * Have spaces around the en-dash in LaTeX [Benjamin Quorning]
34
+ * Turned double-quote close to smart quotes in LaTeX [Jonathan D. Blake]
35
+
36
+ === 4.2.6 / February 9, 2011
37
+
38
+ * Add case-sensitive require back into the gemspec.
39
+ * Fix rdoc options in gemspec.
40
+
41
+ === 4.2.5 / February 7, 2011
42
+
43
+ * Fix bundler and rubygems-test incompatibilities. Working around bug:
44
+ https://github.com/carlhuda/bundler/issues/issue/1021
45
+
46
+ === 4.2.4 / February 7, 2011
47
+
48
+ * Add .gemtest to opt-in to rubygems-test program (gem install rubygems-test to participate)
49
+ * Allow attributes to be set on hr and br tags [Jesse Stormier]
50
+ * Fix dangling <li> [Stephen Bannasch]
51
+ * Switch to bundler and rake-compiler for gem management/compilation
52
+ * Fix invalid YAML for Ruby 1.9.2 [Aaron Patterson]
53
+
54
+ === 4.2.3 / March 1, 2010
55
+
56
+ * Allow quotes in styles so you can do things like listing font-families. [Jason Garber]
57
+ * Fix uninitialized constant Gem::Specification::PLATFORM_CROSS_TARGETS in Rails [Jason Garber]
58
+ * Allow uppercase letters in class and ID attributes [Jason Garber]
59
+ * Fix compatibility with newer Echoe, by using full-name for Platform [Flameeyes]
60
+ * Fixes for PPC/PPC64 [Flameeyes]
61
+ * Added a modified copy of 'Textile Reference' to a doc folder [codesponge]
62
+ * Add footnote return links [Jonathan Rudenberg]
63
+ * Add bug report link to the README
64
+
65
+ === 4.2.2 / June 30, 2009
66
+
67
+ * Fix regression where percent wasn't accepted in style attribute. [Jason Garber]
68
+
69
+ === 4.2.1 / June 16, 2009
70
+
71
+ * Fix regression where period wasn't accepted in style attribute. [Jason Garber]
72
+
73
+ === 4.2.0 / June 10, 2009
74
+
75
+ * Fixed image with title, href, and text afterward not being made a link. [Jason Garber]
76
+
77
+ * Pass string encoding through in Ruby 1.9. [Jason Garber]
78
+
79
+ * Allow two-letter acronyms. [Jason Garber]
80
+
81
+ * Removed vertical alignment in lists. It doesn't make sense and it conflicts with other things. [Jason Garber]
82
+
83
+ * Allow table cells to be empty. [Jason Garber]
84
+
85
+ * Resolve conflict between table signature and blocks beginning with t. [Jason Garber]
86
+
87
+ * Enable code signature to capture trailing space when in square brackets. [Jason Garber]
88
+
89
+ * Allow emphasized phrases to include underscores. [Jason Garber]
90
+
91
+ * Include an ending question mark in a citation. [Jason Garber]
92
+
93
+ * Fix <notextile> blocks being included in following paragraph. [Jason Garber]
94
+
95
+ * Preserve leading whitespace in pre and bc blocks. [Jason Garber]
96
+
97
+ * Don't add hard break after preexisting <br />. [Jason Garber]
98
+
99
+ * Switched tests from Test::Unit to Rspec. [Jason Garber]
100
+
101
+ * Accept multiline content in table cells. [Jason Garber]
102
+
103
+ * Change to list attributes so you can give style/class to list items (taken from PyTextile). Breaks backwards compatibility.
104
+
105
+ Before, the style applied to the first list item applied to the entire list. Now, class/id/style placed
106
+ before the list applies to the list element and after the hash or asterisk applies to the list item. For
107
+ example:
108
+ <ul id="groceries">
109
+ (#groceries)# Milk <li>milk</li>
110
+ # Eggs <li>eggs</li>
111
+ #(optional) granola <li class="optional">granola</li>
112
+ </ul>
113
+
114
+ * Separated attributes out to have their own mark/store variable and regs. This way, they won't conflict with captured text or backtracked text. [Jason Garber]
115
+
116
+ * Added a RedCloth::EXTENSION_LANGUAGE constant so you can tell what version of the parser you are using. [Jason Garber]
117
+
118
+ * Added a NotCompiledError to give a friendlier message when people just unpack RedCloth into their projects. [Jason Garber]
119
+
120
+ * Added a pure-ruby version of the parser for times when you can't compile the C or Java extensions. You should avoid using it if at all possible because it is 32 times slower (and has some other problems, too)! [Jason Garber]
121
+
122
+ * Ignore spaces and tabs on blank lines between blocks. #120 [Jason Garber]
123
+
124
+ * Allow HTML tags with quoted attributes to be inside link text. To do this, I had to remove the possibility that attributes in HTML tags could have spaces around the equals sign or unquoted attributes. This change also greatly expands the complexity of the state machine, so compilation takes a long time. Sorry. [Jason Garber]
125
+
126
+ * Many improvements to the LaTeX formatter by Bil Kleb, a NASA scientist who's been working with LaTeX for 20 years. Thanks, Bil!
127
+
128
+ === 4.1.9 / February 20, 2009
129
+
130
+ * Make compatible with Ruby 1.9.
131
+
132
+ * Image URLs and image titles can now contain parentheses. #71
133
+
134
+ * Handle caps properly in link titles. #77
135
+
136
+ * Remove extra preformatted line breaks after extended block code. #79
137
+
138
+ * Fix inline <notextile> being recognized as block <notextile>. #81
139
+
140
+ * Allow leading spaces on lists for backward compatibility with RedCloth 3.x. #89
141
+
142
+ * Recognize deleted phrases when they start at the beginning of a line. #83
143
+
144
+ * Fix escaped <code> tag when it has the class attribute and is in a <pre> tag. #95
145
+
146
+ * Fix dimensions and primes for LaTeX. #103
147
+
148
+ * Don't allow square brackets inside lang attribute so double square brackets are interpreted like Textile 2 and RedCloth 3. #101
149
+
150
+ * Improve LaTeX output for tables. #96
151
+
152
+ * Fix bad parsing of bracketed image links (which would hang the interpreter in some cases). #97
153
+
154
+ * Handle links containing parentheses. Brackets are no longer required. #82 [Ryan Alyea]
155
+
156
+ * Made italics use the correct LaTeX tag: textit rather than emph. #98
157
+
158
+ * Fixed custom block signatures calling built-in Ruby String methods. #92
2
159
 
3
160
  * Mentioned the three supported platforms and what's necessary to build RedCloth in the README file.
4
161
 
@@ -25,7 +182,7 @@
25
182
  To compile the jruby version of the gem: jruby -S rake compile
26
183
 
27
184
  * Added textilize ERB utility method. [edraut]
28
- Use it in an ERB template like this: <%=t my_textile_string %> or
185
+ Use it in an ERB template like this: <%=t my_textile_string %> or
29
186
  <%=r %{Some *textile* if you please!} %>
30
187
 
31
188
  * Fix extended blockcode stripping whitespace following blank line. #78
@@ -120,4 +277,4 @@
120
277
 
121
278
  * Over 500 tests prevent regression
122
279
 
123
- * It's 40 times faster than the previous version.
280
+ * It's 40 times faster than the previous version.
data/Manifest CHANGED
@@ -1,26 +1,8 @@
1
1
  bin/redcloth
2
2
  CHANGELOG
3
3
  COPYING
4
- ext/mingw-rbconfig.rb
5
4
  ext/redcloth_scan/extconf.rb
6
5
  ext/redcloth_scan/redcloth.h
7
- ext/redcloth_scan/redcloth_attributes.c.rl
8
- ext/redcloth_scan/redcloth_attributes.java.rl
9
- ext/redcloth_scan/redcloth_attributes.rl
10
- ext/redcloth_scan/redcloth_bbcode.c.rl
11
- ext/redcloth_scan/redcloth_bbcode.rl
12
- ext/redcloth_scan/redcloth_bbcode_inline.rl
13
- ext/redcloth_scan/redcloth_bbcode_inline.c.rl
14
- ext/redcloth_scan/redcloth_common.c.rl
15
- ext/redcloth_scan/redcloth_common.java.rl
16
- ext/redcloth_scan/redcloth_common.rl
17
- ext/redcloth_scan/redcloth_inline.c.rl
18
- ext/redcloth_scan/redcloth_inline.java.rl
19
- ext/redcloth_scan/redcloth_inline.rl
20
- ext/redcloth_scan/redcloth_scan.c.rl
21
- ext/redcloth_scan/redcloth_scan.java.rl
22
- ext/redcloth_scan/redcloth_scan.rl
23
- extras/ragel_profiler.rb
24
6
  lib/case_sensitive_require/RedCloth.rb
25
7
  lib/redcloth/erb_extension.rb
26
8
  lib/redcloth/formatters/base.rb
@@ -9,9 +9,24 @@ License:: MIT
9
9
 
10
10
  (See http://redcloth.org/textile/ for a Textile reference.)
11
11
 
12
+ h2. Latest Updates
13
+
14
+ Holy crap, it's 2021?
15
+
16
+ * Updated version to 0.9.0.alpha1. The minor version bump is due to minor breaking changes listed below.
17
+ * Cherry-picked every major update from RedCloth until this post, which RedCloth has not been updated since 2018. (Nothing wrong with that. Don't fix what ain't broke.) I did not port the RSpec, gem-building, or other new meta elements. But the base engine is still the same so there's no need because the gem-building at least originally was for building on Windows and Java which BBRedCloth does not support.
18
+ * Includes CVE-2012-6684. Although I highly, *highly* recommend using an html sanitizer on top of this because Textile lets you some EVIL things in CSS.
19
+ * YouTube and Vimeo support was removed. It used the super old flash version anyway.
20
+ * Removed the swear filter, it wasn't perfect.
21
+ * All tests pass. NOTE: Malformed BBCode currently produces non-ideal but valid and secure HTML code. Don't mess up your BBCode and it's all fine.
22
+ * Confirmed working on Ruby 3.0.0
23
+ * If you are using BBRedCloth, simply including the pre-packaged gem file is fine. Due to the reliance on Ragel, you cannot just include a Github project.
24
+ ** Since I have not yet ported the build system, you need the last version of echoe gem and Ruby 1.9.3 to actually build the gem using @rake package@. Sorry, not sorry. You can still build Ruby 1.9.3 on macOS Big Sur if you remove or use the super insecure old OpenSSL 1.0.2t, so it's not like super-hard.
25
+ ** Once you have the .gem file, later version of Ruby such as 3.0.0 can then build the native extension normally like any gem.
26
+
12
27
  h2. BBRedCloth
13
28
 
14
- BBRedCloth is a Ruby library for converting Textile into HTML. While fundamentally based on RedCloth, it also contains the ability to convert
29
+ BBRedCloth is a Ruby library for converting Textile into HTML. While fundamentally based on RedCloth, it also contains the ability to convert standard "BBCode" also, which is useful for forums which use this style of markup since, well... forever. As a drop-in replacement for RedCloth, it plays well such that Textile and BBCode can work side-by-side without much effort for the implementer.
15
30
 
16
31
  h2. Installing
17
32
 
@@ -26,7 +41,7 @@ It will install the appropriate Ruby gem. JRuby is not supported, nor is the pur
26
41
  If you wish to use BBRedCloth in your Rails 3 project, just add the following to your Gemfile:
27
42
 
28
43
  <pre>
29
- gem 'BBRedCloth', :require=>"RedCloth"
44
+ gem 'BBRedCloth', require:'redcloth'
30
45
  </pre>
31
46
 
32
47
  == Compiling
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require './lib/redcloth/version'
2
2
  require 'rubygems'
3
- gem 'echoe', '>= 3.0.1'
3
+ gem 'echoe', '>= 4.1'
4
4
  require 'echoe'
5
5
 
6
6
  # Platform missing from Echoe >= 3.2?
@@ -51,9 +51,9 @@ e = Echoe.new('BBRedCloth', RedCloth::VERSION.to_s) do |p|
51
51
  p.ruby_version = '>=1.8.4'
52
52
  p.extension_pattern = nil
53
53
 
54
- if Platform.gcc?
54
+ if Echoe::Platform.gcc?
55
55
  p.platform = 'x86-mswin32-60'
56
- elsif Platform.java?
56
+ elsif Echoe::Platform.java?
57
57
  p.platform = 'universal-java'
58
58
  end
59
59
 
@@ -86,16 +86,18 @@ def move_extensions
86
86
  Dir["ext/**/*.{bundle,so,jar}"].each { |file| mv file, "lib/" }
87
87
  end
88
88
 
89
- def java_classpath_arg
90
- # A myriad of ways to discover the JRuby classpath
91
- classpath = begin
92
- require 'java'
93
- # Already running in a JRuby JVM
94
- Java::java.lang.System.getProperty('java.class.path')
95
- rescue LoadError
96
- ENV['JRUBY_PARENT_CLASSPATH'] || ENV['JRUBY_HOME'] && FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
89
+ def java_classpath_arg # myriad of ways to discover JRuby classpath
90
+ begin
91
+ cpath = Java::java.lang.System.getProperty('java.class.path').split(File::PATH_SEPARATOR)
92
+ cpath += Java::java.lang.System.getProperty('sun.boot.class.path').split(File::PATH_SEPARATOR)
93
+ jruby_cpath = cpath.compact.join(File::PATH_SEPARATOR)
94
+ rescue => e
97
95
  end
98
- classpath ? "-cp #{classpath}" : ""
96
+ unless jruby_cpath
97
+ jruby_cpath = ENV['JRUBY_PARENT_CLASSPATH'] || ENV['JRUBY_HOME'] &&
98
+ FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
99
+ end
100
+ jruby_cpath ? "-cp \"#{jruby_cpath}\"" : ""
99
101
  end
100
102
 
101
103
  ext = "ext/redcloth_scan"
@@ -15,6 +15,22 @@
15
15
  #define RARRAY_PTR(x) (RARRAY(x)->ptr)
16
16
  #endif
17
17
 
18
+ // Different string conversions for ruby 1.8 and ruby 1.9. For 1.9,
19
+ // we need to set the encoding of the string.
20
+
21
+ // For Ruby 1.9
22
+ #ifdef HAVE_RUBY_ENCODING_H
23
+ #include "ruby/encoding.h"
24
+ #define STR_NEW(p,n) rb_enc_str_new((p),(n),rb_enc_from_index(ENCODING_GET(self)))
25
+ #define STR_NEW2(p) rb_enc_str_new((p),strlen(p),rb_enc_from_index(ENCODING_GET(self)))
26
+
27
+ // For Ruby 1.8
28
+ #else
29
+ #define STR_NEW(p,n) rb_str_new((p),(n))
30
+ #define STR_NEW2(p) rb_str_new2((p))
31
+
32
+ #endif
33
+
18
34
  /* variable defs */
19
35
  #ifndef redcloth_scan_c
20
36
  extern VALUE super_ParseError, mRedCloth, super_RedCloth;
@@ -30,6 +46,7 @@ VALUE redcloth_inline2(VALUE, VALUE, VALUE);
30
46
  VALUE redcloth_attribute_parser(int, VALUE, char *, char *);
31
47
  VALUE redcloth_attributes(VALUE, VALUE);
32
48
  VALUE redcloth_link_attributes(VALUE, VALUE);
49
+ VALUE red_parse_title(VALUE, VALUE, VALUE);
33
50
  VALUE redcloth_transform(VALUE, char *, char *, VALUE);
34
51
  VALUE redcloth_transform2(VALUE, VALUE);
35
52
  void red_inc(VALUE, VALUE);
@@ -49,43 +66,49 @@ VALUE redcloth_bbcode_inline2(VALUE, VALUE, VALUE);
49
66
  if (rb_funcall(rb_funcall(self, rb_intern("disable_inline"), 0),rb_intern("include?"), 1,ID2SYM(rb_intern(#T))) != Qtrue) { F }
50
67
  #define UNLESS_DISABLED_INLINE(H, T, F) \
51
68
  if (rb_funcall(rb_funcall(self, rb_intern("disable_inline"), 0),rb_intern("include?"), 1,ID2SYM(rb_intern(#T))) == Qtrue) { rb_str_append(H,red_passthrough(self, ts, te, refs)); } \
52
- else { /*VALUE test = rb_str_new(ts,te-ts); printf("\nred_passthrough_else() '%s'\n", RSTRING(test)->ptr);*/ F }
69
+ else { /*VALUE test = STR_NEW(ts,te-ts); printf("\nred_passthrough_else() '%s'\n", RSTRING(test)->ptr);*/ F }
53
70
  #define UNLESS_DISABLED_ATTRIBUTE(T, F) \
54
71
  if (!(rb_funcall(rb_funcall(self, rb_intern("disable_inline"), 0),rb_intern("include?"), 1,ID2SYM(rb_intern(#T))) == Qtrue)) { F } //if !(rb_funcall(rb_funcall(self, rb_intern("disable_inline"), 0),rb_intern("include?"), 1,ID2SYM(rb_intern(#T))) == Qtrue) { F }
55
- #define CLEAR_REGS() regs = rb_hash_new();
72
+ #define CLEAR_REGS() regs = rb_hash_new(); attr_regs = rb_hash_new();
56
73
  #define RESET_REG() reg = NULL
74
+ #define MARK() reg = p;
75
+ #define MARK_B() bck = p;
76
+ #define MARK_ATTR() attr_reg = p;
57
77
  #define CAT(H) rb_str_cat(H, ts, te-ts)
58
- #define CLEAR(H) H = rb_str_new2("")
59
- #define SET_PLAIN_BLOCK(T) plain_block = rb_str_new2(T)
78
+ #define CLEAR(H) H = STR_NEW2("")
79
+ #define RSTRIP_BANG(H) rb_funcall(H, rb_intern("rstrip!"), 0)
80
+ #define SET_PLAIN_BLOCK(T) plain_block = STR_NEW2(T)
60
81
  #define RESET_TYPE(T) rb_hash_aset(regs, ID2SYM(rb_intern("type")), plain_block)
61
82
  #define INLINE(H, T) rb_str_append(H, rb_funcall(self, rb_intern(T), 1, regs))
62
83
  #define DONE(H) rb_str_append(html, H); CLEAR(H); CLEAR_REGS()
63
- #define BBDONE() failed_start = rb_str_new2(""); html = rb_str_new2(""); CLEAR_REGS(); RESET_REG();
84
+ #define BBDONE() failed_start = STR_NEW2(""); html = STR_NEW2(""); CLEAR_REGS(); RESET_REG();
64
85
  #define PASS(H, A, T) rb_str_append(H, red_pass(self, regs, ID2SYM(rb_intern(A)), rb_intern(T), refs))
65
86
  #define PARSE_ATTR(A) red_parse_attr(self, regs, ID2SYM(rb_intern(A)))
66
87
  #define PARSE_LINK_ATTR(A) red_parse_link_attr(self, regs, ID2SYM(rb_intern(A)))
67
- #define PASS_CODE(H, A, T, O) rb_str_append(H, red_pass_code(self, regs, ID2SYM(rb_intern(A)), rb_intern(T)))
88
+ #define PARSE_IMAGE_ATTR(A) red_parse_image_attr(self, regs, ID2SYM(rb_intern(A)))
89
+ #define PASS_CODE(H, A, T) rb_str_append(H, red_pass_code(self, regs, ID2SYM(rb_intern(A)), rb_intern(T)))
68
90
  #define ADD_BLOCK() \
69
91
  rb_str_append(html, red_block(self, regs, block, refs)); \
70
92
  extend = Qnil; \
71
93
  CLEAR(block); \
72
94
  CLEAR_REGS()
73
- #define ADD_EXTENDED_BLOCK() rb_str_append(html, red_block(self, regs, block, refs)); CLEAR(block);
95
+ #define ADD_EXTENDED_BLOCK() rb_str_append(html, red_block(self, regs, block, refs)); CLEAR(block); rb_hash_aset(regs,ID2SYM(rb_intern("fallback")),Qnil);
74
96
  #define END_EXTENDED() extend = Qnil; CLEAR_REGS();
75
- #define IS_NOT_EXTENDED() NIL_P(extend)
76
97
  #define ADD_BLOCKCODE() rb_str_append(html, red_blockcode(self, regs, block)); CLEAR(block); CLEAR_REGS()
77
98
  #define ADD_EXTENDED_BLOCKCODE() rb_str_append(html, red_blockcode(self, regs, block)); CLEAR(block);
78
- #define ASET(T, V) rb_hash_aset(regs, ID2SYM(rb_intern(T)), rb_str_new2(V));
79
- #define AINC(T) red_inc(regs, ID2SYM(rb_intern(T)));
99
+ #define ASET(T, V) rb_hash_aset(regs, ID2SYM(rb_intern(T)), STR_NEW2(V));
100
+ #define ATTR_SET(T, V) rb_hash_aset(attr_regs, ID2SYM(rb_intern(T)), STR_NEW2(V));
101
+ #define ATTR_INC(T) red_inc(attr_regs, ID2SYM(rb_intern(T)));
102
+ #define INC(N) N++;
80
103
  #define SET_ATTRIBUTES() \
81
- VALUE buf = Qnil; \
82
104
  SET_ATTRIBUTE("class_buf", "class"); \
83
105
  SET_ATTRIBUTE("id_buf", "id"); \
84
106
  SET_ATTRIBUTE("lang_buf", "lang"); \
85
- SET_ATTRIBUTE("style_buf", "style");
107
+ SET_ATTRIBUTE("style_buf", "style"); \
108
+ rb_funcall(regs, rb_intern("merge!"), 1, attr_regs); \
109
+ attr_regs = rb_hash_new();
86
110
  #define SET_ATTRIBUTE(B, A) \
87
- buf = rb_hash_aref(regs, ID2SYM(rb_intern(B))); \
88
- if (buf != Qnil) rb_hash_aset(regs, ID2SYM(rb_intern(A)), buf);
111
+ if (rb_hash_aref(regs, ID2SYM(rb_intern(B))) != Qnil) rb_hash_aset(regs, ID2SYM(rb_intern(A)), rb_hash_aref(regs, ID2SYM(rb_intern(B))));
89
112
  #define TRANSFORM(T) \
90
113
  if (p > reg && reg >= ts) { \
91
114
  VALUE str = redcloth_transform(self, reg, p, refs); \
@@ -96,7 +119,7 @@ VALUE redcloth_bbcode_inline2(VALUE, VALUE, VALUE);
96
119
  }
97
120
  #define STORE(T) \
98
121
  if (p > reg && reg >= ts) { \
99
- VALUE str = rb_str_new(reg, p-reg); \
122
+ VALUE str = STR_NEW(reg, p-reg); \
100
123
  rb_hash_aset(regs, ID2SYM(rb_intern(T)), str); \
101
124
  /* printf("STORE(" T ") '%s' (p:'%d' reg:'%d')\n", RSTRING(str)->ptr, p, reg);*/ \
102
125
  } else { \
@@ -104,13 +127,22 @@ VALUE redcloth_bbcode_inline2(VALUE, VALUE, VALUE);
104
127
  }
105
128
  #define STORE_B(T) \
106
129
  if (p > bck && bck >= ts) { \
107
- VALUE str = rb_str_new(bck, p-bck); \
130
+ VALUE str = STR_NEW(bck, p-bck); \
108
131
  rb_hash_aset(regs, ID2SYM(rb_intern(T)), str); \
109
132
  /* printf("STORE_B(" T ") '%s' (p:'%d' reg:'%d')\n", RSTRING(str)->ptr, p, reg);*/ \
110
133
  } else { \
111
134
  rb_hash_aset(regs, ID2SYM(rb_intern(T)), Qnil); \
112
135
  }
113
136
  #define BBCODE_ENABLED() rb_funcall(self, rb_intern("bbcode"), 0) == Qtrue
137
+ #define STORE_ATTR(T) \
138
+ if (p > attr_reg && attr_reg >= ts) { \
139
+ VALUE str = STR_NEW(attr_reg, p-attr_reg); \
140
+ rb_hash_aset(attr_regs, ID2SYM(rb_intern(T)), str); \
141
+ /*printf("STORE_B(" T ") '%s' (p:'%s' reg:'%s')\n", RSTRING_PTR(str), p, reg);*/ \
142
+ } else { \
143
+ rb_hash_aset(attr_regs, ID2SYM(rb_intern(T)), Qnil); \
144
+ }
145
+
114
146
  #define STORE_URL(T) \
115
147
  if (p > reg && reg >= ts) { \
116
148
  char punct = 1; \
@@ -119,7 +151,7 @@ VALUE redcloth_bbcode_inline2(VALUE, VALUE, VALUE);
119
151
  case ')': \
120
152
  { /*needed to keep inside chars scoped for less memory usage*/\
121
153
  char *temp_p = p - 1; \
122
- char level = -1; \
154
+ signed char level = -1; \
123
155
  while (temp_p > reg) { \
124
156
  switch(*(temp_p - 1)) { \
125
157
  case '(': ++level; break; \
@@ -146,20 +178,24 @@ VALUE redcloth_bbcode_inline2(VALUE, VALUE, VALUE);
146
178
  #define STORE_LINK_ALIAS() \
147
179
  rb_hash_aset(refs_found, rb_hash_aref(regs, ID2SYM(rb_intern("text"))), rb_hash_aref(regs, ID2SYM(rb_intern("href"))))
148
180
  #define CLEAR_LIST() list_layout = rb_ary_new()
149
- #define LIST_ITEM() \
181
+ #define SET_LIST_TYPE(T) list_type = T;
182
+ #define NEST() nest ++;
183
+ #define RESET_NEST() nest = 0;
184
+ #define LIST_LAYOUT() \
150
185
  int aint = 0; \
151
186
  VALUE aval = rb_ary_entry(list_index, nest-1); \
152
187
  if (aval != Qnil) aint = NUM2INT(aval); \
153
- if (strcmp(list_type, "ol") == 0) \
188
+ if (strcmp(list_type, "ol") == 0 && nest > 0) \
154
189
  { \
155
190
  rb_ary_store(list_index, nest-1, INT2NUM(aint + 1)); \
156
191
  } \
157
192
  if (nest > RARRAY_LEN(list_layout)) \
158
193
  { \
194
+ SET_ATTRIBUTES(); \
159
195
  sprintf(listm, "%s_open", list_type); \
160
- if (list_continue == 1) \
196
+ if (!NIL_P(rb_hash_aref(regs, ID2SYM(rb_intern("list_continue"))))) \
161
197
  { \
162
- list_continue = 0; \
198
+ rb_hash_aset(regs, ID2SYM(rb_intern("list_continue")), Qnil); \
163
199
  rb_hash_aset(regs, ID2SYM(rb_intern("start")), rb_ary_entry(list_index, nest-1)); \
164
200
  } \
165
201
  else \
@@ -177,13 +213,18 @@ VALUE redcloth_bbcode_inline2(VALUE, VALUE, VALUE);
177
213
  } \
178
214
  rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(nest)); \
179
215
  rb_str_append(html, rb_funcall(self, rb_intern(listm), 1, regs)); \
180
- rb_ary_store(list_layout, nest-1, rb_str_new2(list_type)); \
216
+ rb_ary_store(list_layout, nest-1, STR_NEW2(list_type)); \
181
217
  CLEAR_REGS(); \
182
218
  ASET("first", "true"); \
183
219
  } \
184
220
  LIST_CLOSE(); \
221
+ if (nest != 0) LIST_ITEM_CLOSE(); \
222
+ CLEAR_REGS(); \
185
223
  rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(RARRAY_LEN(list_layout))); \
186
- ASET("type", "li_open")
224
+ ASET("type", "li_open");
225
+ #define LIST_ITEM_CLOSE() \
226
+ if ( rb_hash_aref(regs, ID2SYM(rb_intern("first"))) == Qnil ) \
227
+ rb_str_append(html, rb_funcall(self, rb_intern("li_close"), 1, regs));
187
228
  #define LIST_CLOSE() \
188
229
  while (nest < RARRAY_LEN(list_layout)) \
189
230
  { \
@@ -193,6 +234,7 @@ VALUE redcloth_bbcode_inline2(VALUE, VALUE, VALUE);
193
234
  { \
194
235
  StringValue(end_list); \
195
236
  sprintf(listm, "%s_close", RSTRING_PTR(end_list)); \
237
+ LIST_ITEM_CLOSE(); \
196
238
  rb_str_append(html, rb_funcall(self, rb_intern(listm), 1, regs)); \
197
239
  } \
198
240
  }