markdown link
This commit is contained in:
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
module MarkdownToHtml
|
module MarkdownToHtml
|
||||||
LINK_REGEXP = %r{\[([^\]]+)\]\((https?://[^)]+)\)}
|
LINK_REGEXP = %r{\[([^\]]+)\]\((https?://[^)]+)\)}
|
||||||
LINK_REPLACE = '<a href="\2">\1</a>'
|
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def call(text)
|
def call(text)
|
||||||
text.gsub(LINK_REGEXP, LINK_REPLACE)
|
text.gsub(LINK_REGEXP) do
|
||||||
|
ApplicationController.helpers.link_to(Regexp.last_match(1), Regexp.last_match(2))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user