./pimki.rb in Pimki-1.3.092 vs ./pimki.rb in Pimki-1.4.092
- old
+ new
@@ -7,30 +7,71 @@
# Handle rubygems support & loading libraries: {{{
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "libraries")
begin
require 'rubygems'
- require_gem 'madeleine'
- require_gem 'RedCloth'
+ require 'madeleine'
+ require 'redcloth'
+ require 'bluecloth'
require_gem 'rubyzip'
+ require 'zip/zip'
rescue LoadError => detail
# no rubygems, so load from the libraries directory
p detail
require 'redcloth'
require 'bluecloth'
+ require 'zip/zip'
end
### RedCloth Modifications:
# Remove the "caps" spanning:
RedCloth::GLYPHS.delete_if { |glyph| glyph[1] =~ /class=\"caps\"/ }
# Fix missing hard_break
if RedCloth::VERSION == '3.0.0'
class RedCloth #{{{
- alias_method :old_clean_white_space, :clean_white_space
- def clean_white_space text
- old_clean_white_space text
- hard_break text
+ def to_html( *rules )
+ rules = @rules if rules.empty?
+ # make our working copy
+ text = self.dup
+
+ @urlrefs = {}
+ @shelf = []
+ textile_rules = [:refs_textile, :block_textile_table, :block_textile_lists,
+ :block_textile_prefix, :inline_textile_image, :inline_textile_link,
+ :inline_textile_code, :inline_textile_span, :inline_textile_glyphs]
+ markdown_rules = [:refs_markdown, :block_markdown_setext, :block_markdown_atx, :block_markdown_rule,
+ :block_markdown_bq, :block_markdown_lists,
+ :inline_markdown_reflink, :inline_markdown_link]
+ @rules = rules.collect do |rule|
+ case rule
+ when :markdown
+ markdown_rules
+ when :textile
+ textile_rules
+ else
+ rule
+ end
+ end.flatten
+
+ # standard clean up
+ incoming_entities text
+ clean_white_space text
+
+ # start processor
+ pre_list = rip_offtags text
+ refs text
+ blocks text
+ inline text
+ smooth_offtags text, pre_list
+
+ retrieve text
+ hard_break text # PIMKI: this is the missing bit!
+
+ text.gsub!( /<\/?notextile>/, '' )
+ text.gsub!( /x%x%/, '&' )
+ text.strip!
+ text
end
end #}}}
else
# Redcloth v3.0.0 can handle markdown, so BlueCloth is only required if we
# have an earlier redcloth version.
\ No newline at end of file