Yet more dangerously greedy Regexps in Maruku,
and one of my own.
This commit is contained in:
Jacques Distler 2009-03-27 09:25:08 -05:00
parent 7403ea6a6b
commit d425a70fad
5 changed files with 8 additions and 8 deletions

View file

@ -32,7 +32,7 @@ module Literal
class Math < AbstractLiteral class Math < AbstractLiteral
MATH_START = '(\${1,2}|' + Regexp.escape('\[') + '|\\begin\{equation\})' MATH_START = '(\${1,2}|' + Regexp.escape('\[') + '|\\begin\{equation\})'
MATH_END = '(\${1,2}|' + Regexp.escape('\]') + '|\\end\{equation\})' MATH_END = '(\${1,2}|' + Regexp.escape('\]') + '|\\end\{equation\})'
MATH_PATTERN = Regexp.new(MATH_START + '([^$]|\\\$)+' + MATH_END, Regexp::MULTILINE) MATH_PATTERN = Regexp.new(MATH_START + '([^$]|\\\$)+?' + MATH_END, Regexp::MULTILINE)
def self.pattern() MATH_PATTERN end def self.pattern() MATH_PATTERN end
end end

View file

@ -28,12 +28,12 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
class HTMLHelper class HTMLHelper
include MaRuKu::Strings include MaRuKu::Strings
Tag = %r{^<(/)?(\w+)\s*([^>]*)>}m Tag = %r{^<(/)?(\w+)\s*([^>]*?)>}m
PartialTag = %r{^<.*}m PartialTag = %r{^<.*}m
EverythingElse = %r{^[^<]+}m EverythingElse = %r{^[^<]+}m
CommentStart = %r{^<!--}x CommentStart = %r{^<!--}x
CommentEnd = %r{^.*-->} CommentEnd = %r{^.*?-->}
TO_SANITIZE = ['img','hr','br'] TO_SANITIZE = ['img','hr','br']
attr_reader :rest attr_reader :rest

View file

@ -177,7 +177,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
line = src.shift_line.strip line = src.shift_line.strip
al = nil al = nil
# Check if there is an IAL # Check if there is an IAL
if new_meta_data? and line =~ /^(.*)\{(.*)\}\s*$/ if new_meta_data? and line =~ /^(.*?)\{(.*?)\}\s*$/
line = $1.strip line = $1.strip
ial = $2 ial = $2
al = read_attribute_list(CharSource.new(ial,src), context=nil, break_on=[nil]) al = read_attribute_list(CharSource.new(ial,src), context=nil, break_on=[nil])
@ -193,7 +193,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
line = src.shift_line.strip line = src.shift_line.strip
al = nil al = nil
# Check if there is an IAL # Check if there is an IAL
if new_meta_data? and line =~ /^(.*)\{(.*)\}\s*$/ if new_meta_data? and line =~ /^(.*?)\{(.*?)\}\s*$/
line = $1.strip line = $1.strip
ial = $2 ial = $2
al = read_attribute_list(CharSource.new(ial,src), context=nil, break_on=[nil]) al = read_attribute_list(CharSource.new(ial,src), context=nil, break_on=[nil])

View file

@ -299,7 +299,7 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
end end
def extension_meta(src, con, break_on_chars) def extension_meta(src, con, break_on_chars)
if m = src.read_regexp(/([^\s\:\"\']+):/) if m = src.read_regexp(/([^\s\:\"\']+?):/)
name = m[1] name = m[1]
al = read_attribute_list(src, con, break_on_chars) al = read_attribute_list(src, con, break_on_chars)
# puts "#{name}=#{al.inspect}" # puts "#{name}=#{al.inspect}"
@ -443,7 +443,7 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
# R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/) # R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/)
# R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/) # R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/)
R_REF_ID = Regexp.compile(/([^\]]*)\]/) R_REF_ID = Regexp.compile(/([^\]]*?)\]/)
# Reads a bracketed id "[refid]". Consumes also both brackets. # Reads a bracketed id "[refid]". Consumes also both brackets.
def read_ref_id(src, con) def read_ref_id(src, con)

View file

@ -143,5 +143,5 @@ module MaRuKu; module Strings
TableSeparator = %r{^(\|?#{Sep}\|?)+?\s*$} TableSeparator = %r{^(\|?#{Sep}\|?)+?\s*$}
EMailAddress = /<([^:]+@[^:]+)>/ EMailAddress = /<([^:]+?@[^:]+?)>/
end end end end