Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
fc8be60634
1105 changed files with 14278 additions and 4667 deletions
|
@ -48,11 +48,14 @@ module Chunk
|
|||
# chunk for it, and replace the occurance of the chunk
|
||||
# in this content with its mask.
|
||||
def self.apply_to(content)
|
||||
content.gsub!( self.pattern ) do |match|
|
||||
text = content.to_str
|
||||
text.gsub!( self.pattern ) do |match|
|
||||
# content.replace text
|
||||
new_chunk = self.new($~, content)
|
||||
content.add_chunk(new_chunk)
|
||||
new_chunk.mask
|
||||
end
|
||||
end
|
||||
content.replace text
|
||||
end
|
||||
|
||||
# should contain only [a-z0-9]
|
||||
|
@ -61,7 +64,7 @@ module Chunk
|
|||
end
|
||||
|
||||
def unmask
|
||||
@content.sub!(mask){|s| s.replace @unmask_text}
|
||||
@content.replace @content.sub(mask){|s| s.replace @unmask_text}
|
||||
end
|
||||
|
||||
def rendered?
|
||||
|
@ -73,7 +76,7 @@ module Chunk
|
|||
end
|
||||
|
||||
def revert
|
||||
@content.sub!(mask){|s| s.replace @text}
|
||||
@content.replace @content.sub(mask){|s| s.replace @text}
|
||||
# unregister
|
||||
@content.delete_chunk(self)
|
||||
end
|
||||
|
|
|
@ -114,7 +114,7 @@ module Engines
|
|||
class Mixed < AbstractEngine
|
||||
def mask
|
||||
@content.as_utf8
|
||||
redcloth = OldRedCloth.new(@content, @content.options[:engine_opts])
|
||||
redcloth = OldRedCloth.new(@content.to_str, @content.options[:engine_opts])
|
||||
redcloth.filter_html = false
|
||||
redcloth.no_span_caps = false
|
||||
html = redcloth.to_html
|
||||
|
@ -123,8 +123,7 @@ module Engines
|
|||
|
||||
class RDoc < AbstractEngine
|
||||
def mask
|
||||
@content.as_utf8
|
||||
html = RDocSupport::RDocFormatter.new(@content).to_html
|
||||
html = RDocSupport::RDocFormatter.new(@content.as_utf8.to_str).to_html
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ module Literal
|
|||
|
||||
# A literal chunk that protects equations from wiki rendering.
|
||||
class Math < AbstractLiteral
|
||||
MATH_START = '(\${1,2}|' + Regexp.escape('\[') + '|\\begin\{equation\})'
|
||||
MATH_END = '(\${1,2}|' + Regexp.escape('\]') + '|\\end\{equation\})'
|
||||
MATH_PATTERN = Regexp.new(MATH_START + '([^$]|\\\$)+?' + MATH_END, Regexp::MULTILINE)
|
||||
MATH_START = "(?:\\\\\\[|\\${1,2}|\\\\begin\\{equation\\})"
|
||||
MATH_END = "(?:\\\\\\]|\\${1,2}|\\\\end\\{equation\\})"
|
||||
MATH_PATTERN = Regexp.new( '(' + MATH_START + "(?:\\\\\\$|(?!\\$|\\\\\\]|\\\\end\\{equation\\}).)+?" + MATH_END + ')', Regexp::MULTILINE)
|
||||
def self.pattern() MATH_PATTERN end
|
||||
end
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ module WikiChunk
|
|||
end
|
||||
|
||||
def self.apply_to(content)
|
||||
content.as_utf8.gsub!( self.pattern ) do |matched_text|
|
||||
text = content.as_utf8.to_str
|
||||
text.gsub!( self.pattern ) do |matched_text|
|
||||
chunk = self.new($~, content)
|
||||
if chunk.textile_url?
|
||||
# do not substitute
|
||||
|
@ -44,6 +45,7 @@ module WikiChunk
|
|||
chunk.mask
|
||||
end
|
||||
end
|
||||
content.replace text
|
||||
end
|
||||
|
||||
def textile_url?
|
||||
|
|
|
@ -39,7 +39,7 @@ class RDocMarkup < SM::SimpleMarkup
|
|||
end
|
||||
|
||||
def convert(text, handler)
|
||||
super.sub(/^<p>\n/, '').sub(/<\/p>$/, '')
|
||||
super.sub(/^\n{0,1}<p>\n{0,1}/, '').sub(/\n{0,1}<\/p>\n{0,1}$/, '')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -31,4 +31,4 @@ class InstikiUpgrade
|
|||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -208,7 +208,8 @@ class WikiContent < ActiveSupport::SafeBuffer
|
|||
@options[:engine].apply_to(self)
|
||||
as_utf8
|
||||
# unmask in one go. $~[1] is the chunk id
|
||||
gsub!(MASK_RE[ACTIVE_CHUNKS]) do
|
||||
text = self.to_str
|
||||
text.gsub!(MASK_RE[ACTIVE_CHUNKS]) do
|
||||
chunk = @chunks_by_id[$~[1].to_i]
|
||||
if chunk.nil?
|
||||
# if we match a chunkmask that existed in the original content string
|
||||
|
@ -218,7 +219,7 @@ class WikiContent < ActiveSupport::SafeBuffer
|
|||
chunk.unmask_text
|
||||
end
|
||||
end
|
||||
self.replace xhtml_sanitize(self)
|
||||
self.replace xhtml_sanitize(text)
|
||||
self.html_safe
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue