From f7a6194ca54ce58a1f8162627513442da3e84bea Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 4 Sep 2007 14:57:41 +0100 Subject: code-block exceptions --- lib/sisu/v0/dal_syntax.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/sisu/v0/dal_syntax.rb') diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 292f7343..14bed691 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -191,7 +191,7 @@ module Syntax # # #numbered (list) level 1 # _# #numbered (list) level 2 line=line.dup - unless line =~/^0~|<:codeline>|<:code-end>/ + if line !~/^0~|<:codeline>|<:code-end>/ #special characters: ~ { } < > - _ / also used : ^ ! # line_array=[] line.gsub!(/^%{1,4} .+/mi,'') #remove comments @@ -285,10 +285,13 @@ module Syntax if line =~/(<:(?:verse|group)>)/; line.gsub!(/(<:(?:verse|group)>)/i,"\\1\n") #cosmetic else line.gsub!(/(
)/i,"\\1\n") end - else #code blocks - line.gsub!(/(^|\s)(https?:\/\/\S+)/,'\1_\2') #line.gsub!(/(^|\s)(http:\/\/\S+)/,"\\1\\\\\\2") #escape urls - line.gsub!(/(^|\s)<(https?:\/\/\S+)>([\s,.]|$)/,'\1\2\3') #clean/unescape urls with decoration, re-apply decoration later + elsif line =~/^<:code(?:-end)?>|<:codeline>/ # /^<:code>/ #should be enough # underscore used as escape for angle brackets + line.gsub!(/([<>])/,'_\1') + line.gsub!(/_<:(\S+?)_>/,'<:\1>') #convert <:\S+> back, clumsy + line.gsub!(/_<(br(?: \/)?)_>/,'<\1>') #convert

back, clumsy + line.gsub!(/(^|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert

back, clumsy line.gsub!(/<:codeline>/,"\n  ") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") + else # 0~ end line end -- cgit v1.2.3