lib/trac-wiki/parser.rb in trac-wiki-0.2.21 vs lib/trac-wiki/parser.rb in trac-wiki-0.2.23

- old
+ new

@@ -280,13 +280,18 @@ # Example custom behaviour: # # make_local_link("LocalLink") #=> "/LocalLink" # make_local_link("Wikipedia:Bread") #=> "http://en.wikipedia.org/wiki/Bread" def make_local_link(link) #:doc: - return "#{@base}#{link}" if no_escape? link, anch = link.split(/#/, 2) + if no_escape? + return "#{@base}#{link}" if ! anch + return "##{anch}" if link == '' + return "#{@base}#{link}##{anch}" + end return "#{@base}#{escape_url(link)}" if ! anch + return "##{escape_url(anch)}" if link == '' "#{@base}#{escape_url(link)}##{escape_url(anch)}" end # Sanatize a direct url (e.g. http://wikipedia.org/). The default # behaviour returns the original link as-is. @@ -415,9 +420,10 @@ # [ link1 | text2 ] when /\A \[ \s* ([^\[|]*?) \s* (\|\s*(.*?))? \s* \] /mx str = $' link, content, whole= $1, $3, $& make_link(link, content, "[#{whole}]") + # [[ link1 | text2 ]] when /\A \[\[ \s* ([^|]*?) \s* (\|\s*(.*?))? \s* \]\] /mx str = $' link, content, whole= $1, $3, $& make_link(link, content, whole) else