Skip to content

Commit

Permalink
added macro support (by dondoco)
Browse files Browse the repository at this point in the history
  • Loading branch information
Junya Ogura committed Sep 30, 2009
1 parent e4354b3 commit eeaca48
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions lib/redmine_markdown_extra_formatter/wiki_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,21 @@

module RedmineMarkdownExtraFormatter
class WikiFormatter


def initialize(text)
@text = text
end

def to_html(&block)

@macros_runner = block

parsedText = BlueFeather.parse(@text.gsub(/\[(.+)\]\((https?:\/\/.+)\)/, '[\1](/redirect/\2)'))

inline_macros(parsedText)

rescue => e
return("<pre>problem parsing wiki text: #{e.message}\n"+
"original text: \n"+
@text+
"</pre>")
end

MACROS_RE = /
(!)? # escaping
(
Expand All @@ -32,10 +26,9 @@ def to_html(&block)
(\(([^\}]*)\))? # optional arguments
\}\} # closing tag
)
/x
/x

def inline_macros(text)

text.gsub!(MACROS_RE) do
esc, all, macro = $1, $2, $3.downcase
args = ($5 || '').split(',').each(&:strip)
Expand All @@ -49,9 +42,7 @@ def inline_macros(text)
all
end
end

text
end

end
end

0 comments on commit eeaca48

Please sign in to comment.