lib/trac-wiki/parser.rb in trac-wiki-0.1.5 vs lib/trac-wiki/parser.rb in trac-wiki-0.1.6

- old
+ new

@@ -41,10 +41,11 @@ # Allowed url schemes # Examples: http https ftp ftps attr_accessor :allowed_schemes + # Disable url escaping for local links # Escaping: [[/Test]] --> %2FTest # No escaping: [[/Test]] --> Test attr_writer :no_escape def no_escape?; @no_escape; end @@ -63,10 +64,13 @@ @text = text @no_escape = nil options.each_pair {|k,v| send("#{k}=", v) } end + @was_math = false + def was_math?; @was_math; end + # Convert CCreole text to HTML and return # the result. The resulting HTML does not contain <html> and # <body> tags. # # Example: @@ -77,10 +81,11 @@ def to_html @out = '' @p = false @stack = [] @stacki = [] + @was_math = false parse_block(@text) @out end protected @@ -327,10 +332,12 @@ when str =~ /\A`(.*?)`/ # inline pre (tt) @out << '<tt>' << escape_html($1) << '</tt>' when math? && str =~ /\A\$(.+?)\$/ # inline math (tt) @out << '\( ' << escape_html($1) << ' \)' + @was_math = true + # when /\A\[\[Image\(([^|].*?)(\|(.*?))?\)\]\]/ # image # @out << make_image($1, $3) # when /\A\{\{\s*(.*?)\s*(\|\s*(.*?)\s*)?\}\}/ # if uri = make_image_link($1) @@ -473,13 +480,14 @@ def parse_block(str) until str.empty? case # pre {{{ ... }}} - when math? && str =~ /\A\$\$(.*?)\$\$/ + when math? && str =~ /\A\$\$(.*?)\$\$/m end_paragraph nowikiblock = make_nowikiblock($1) @out << "$$" << escape_html(nowikiblock) << "$$\n" + @was_math = true when str =~ /\A\{\{\{\r?\n(.*?)\r?\n\}\}\}/m end_paragraph nowikiblock = make_nowikiblock($1) @out << '<pre>' << escape_html(nowikiblock) << '</pre>'