lib/yard/templates/helpers/text_helper.rb in yard-0.9.0 vs lib/yard/templates/helpers/text_helper.rb in yard-0.9.1

- old
+ new

@@ -4,10 +4,11 @@ # Helper methods for text template formats. module TextHelper # @return [String] escapes text def h(text) out = "" + text = resolve_links(text) text = text.split(/\n/) text.each_with_index do |line, i| out << case line when /^\s*$/; "\n\n" @@ -86,9 +87,20 @@ end extras << meth.visibility if meth.visibility != :public extras_text = '(' + extras.join(", ") + ')' unless extras.empty? title = "%s%s%s %s%s%s" % [scope, name, args, blk, type, extras_text] title.gsub(/\s+/, ' ') + end + + private + + def resolve_links(text) + text.gsub(/(\\|!)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=[\W]|$)/m) do |str| + escape, name, title, match = $1, $2, $3, $& + next(match[1..-1]) if escape + next(match) if name[0,1] == '|' + linkify(name, title) + end end end end end end \ No newline at end of file