[RESTORES BUILD] Wiki link (in double square brackets) has precedence over autolinking URLs;
contents of wiki links are not passed to markup engines; got rid of bracketing mask method in the chunks parser (it was a feature that caused a lot of parsing grief for no good reason)
This commit is contained in:
parent
301464c4e4
commit
8263e4bfcd
6 changed files with 32 additions and 37 deletions
|
@ -24,22 +24,6 @@ module Chunk
|
|||
end
|
||||
end
|
||||
|
||||
def pre_mask
|
||||
"chunk#{self.object_id}#{self.class.to_s.delete(':').downcase}start"
|
||||
end
|
||||
|
||||
def post_mask
|
||||
"chunk#{self.object_id}end"
|
||||
end
|
||||
|
||||
def bracketing_mask(content)
|
||||
"#{pre_mask} #{content} #{post_mask}"
|
||||
end
|
||||
|
||||
def bracketing_mask_regexp
|
||||
Regexp.new("#{pre_mask} (.*)[ \n]#{post_mask}")
|
||||
end
|
||||
|
||||
def mask(content)
|
||||
"chunk#{self.object_id}#{self.class.to_s.delete(':').downcase}chunk"
|
||||
end
|
||||
|
|
|
@ -38,23 +38,28 @@ module WikiChunk
|
|||
# By default, no escaped text
|
||||
def escaped_text() nil end
|
||||
|
||||
# FIXME: do not use the bracketing mask - URI chunk thinks that 'index.jpg'
|
||||
# contains URL http://index.jp
|
||||
|
||||
# Replace link with a mask, but if the word is escaped, then don't replace it
|
||||
def mask(content) escaped_text || bracketing_mask(link_text) end
|
||||
def mask(content)
|
||||
escaped_text || super(content)
|
||||
end
|
||||
|
||||
def regexp() bracketing_mask_regexp end
|
||||
|
||||
def revert(content) content.sub!(regexp, text) end
|
||||
def revert(content) content.sub!(mask(content), text) end
|
||||
|
||||
# Do not keep this chunk if it is escaped.
|
||||
# Otherwise, pass the link procedure a page_name and link_text and
|
||||
# get back a string of HTML to replace the mask with.
|
||||
def unmask(content)
|
||||
return nil if escaped_text
|
||||
return self if content.sub!(regexp) do |match|
|
||||
content.page_link(page_name, $1, link_type)
|
||||
if escaped_text
|
||||
return self
|
||||
else
|
||||
chunk_found = content.sub!(mask(content)) do |match|
|
||||
content.page_link(page_name, link_text, link_type)
|
||||
end
|
||||
if chunk_found
|
||||
return self
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,7 +83,9 @@ module WikiChunk
|
|||
@textile_link_suffix, @escape, @page_name = match_data[1..3]
|
||||
end
|
||||
|
||||
def escaped_text() (@escape.nil? ? nil : page_name) end
|
||||
def escaped_text
|
||||
page_name unless @escape.nil?
|
||||
end
|
||||
def link_text() WikiWords.separate(page_name) end
|
||||
end
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class Web
|
|||
# on the render mode in options and whether the page exists
|
||||
# in the this web.
|
||||
def make_link(name, text = nil, options = {})
|
||||
text = text || WikiWords.separate(name)
|
||||
text = CGI.escapeHTML(text || WikiWords.separate(name))
|
||||
mode = options[:mode]
|
||||
link_type = options[:link_type] || 'show'
|
||||
case link_type
|
||||
|
|
|
@ -39,7 +39,7 @@ require 'chunks/nowiki'
|
|||
# UPDATED: 22nd May 2004
|
||||
class WikiContent < String
|
||||
|
||||
PRE_ENGINE_ACTIONS = [ NoWiki, Category, Include, URIChunk, LocalURIChunk, WikiChunk::Link,
|
||||
PRE_ENGINE_ACTIONS = [ NoWiki, Category, Include, WikiChunk::Link, URIChunk, LocalURIChunk,
|
||||
WikiChunk::Word ]
|
||||
POST_ENGINE_ACTIONS = [ Literal::Pre, Literal::Tags ]
|
||||
DEFAULT_OPTS = {
|
||||
|
@ -90,7 +90,6 @@ class WikiContent < String
|
|||
def render!(chunk_types)
|
||||
@chunks = []
|
||||
chunk_types.each { |chunk_type| chunk_type.apply_to(self) }
|
||||
|
||||
@rendered = @chunks.map { |chunk| chunk.unmask(self) }.compact
|
||||
(@chunks - @rendered).each { |chunk| chunk.revert(self) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue