Class: PseudoHiki::AutoLink::WikiName
- Inherits:
-
Object
- Object
- PseudoHiki::AutoLink::WikiName
- Defined in:
- lib/pseudohiki/autolink.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_tag(url) ⇒ Object
- #auto_link_url? ⇒ Boolean
- #escaped_wiki_name?(wiki_name) ⇒ Boolean
- #in_link_tag?(preceding_str) ⇒ Boolean
-
#initialize(options = {}) ⇒ WikiName
constructor
A new instance of WikiName.
- #link(line) ⇒ Object
- #link_wiki_name(line) ⇒ Object
Constructor Details
Class Method Details
.default_options ⇒ Object
18 19 20 |
# File 'lib/pseudohiki/autolink.rb', line 18 def self. @default_options end |
Instance Method Details
#add_tag(url) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/pseudohiki/autolink.rb', line 39 def add_tag(url) if escaped_wiki_name?(url) url[1..-1] elsif url.start_with?(ESCAPE_CHAR) "^[[#{url[1..-1]}]]" else "[[#{url}]]" end end |
#auto_link_url? ⇒ Boolean
27 28 29 |
# File 'lib/pseudohiki/autolink.rb', line 27 def auto_link_url? @options[:url] end |
#escaped_wiki_name?(wiki_name) ⇒ Boolean
31 32 33 |
# File 'lib/pseudohiki/autolink.rb', line 31 def escaped_wiki_name?(wiki_name) @options[:escape_wiki_name] and wiki_name.start_with?(ESCAPE_CHAR) end |
#in_link_tag?(preceding_str) ⇒ Boolean
35 36 37 |
# File 'lib/pseudohiki/autolink.rb', line 35 def in_link_tag?(preceding_str) URL.in_link_tag?(preceding_str) end |
#link(line) ⇒ Object
54 55 56 57 |
# File 'lib/pseudohiki/autolink.rb', line 54 def link(line) line = @auto_linker.link(line) @options[:wiki_name] ? link_wiki_name(line) : line end |
#link_wiki_name(line) ⇒ Object
49 50 51 52 |
# File 'lib/pseudohiki/autolink.rb', line 49 def link_wiki_name(line) return line if not WIKI_NAME_RE.match? line or VERBATIM_LEAF_HEAD_RE.match? line line.gsub(WIKI_NAME_RE) {|url| in_link_tag?($`) ? url : add_tag(url) } end |