Class: WikiChunk::Word
Overview
This chunk matches a WikiWord. WikiWords can be escaped by prepending a ‘'. When this is the case, the escaped_text
method will return the WikiWord instead of the usual nil
. The page_name
method returns the matched WikiWord.
Instance Attribute Summary collapse
#revision, #text
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from WikiLink
#revert, #unmask
#post_mask, #pre_mask, #revert, #unmask
Constructor Details
#initialize(match_data, revision) ⇒ Word
Returns a new instance of Word.
44
45
46
47
48
49
|
# File 'app/models/chunks/wiki.rb', line 44
def initialize(match_data, revision)
super(match_data, revision)
@escaped = match_data[1] || match_data[3]
@text.delete! '\\' if @escaped
@page_name = @link_text = match_data[2]
end
|
Instance Attribute Details
#page_name ⇒ Object
42
43
44
|
# File 'app/models/chunks/wiki.rb', line 42
def page_name
@page_name
end
|
Class Method Details
.pattern ⇒ Object
38
39
40
|
# File 'app/models/chunks/wiki.rb', line 38
def self.pattern
Regexp.new('(\\\\)?(' + WikiWords::WIKI_WORD_PATTERN + ')(</a>)?', 0, "utf-8")
end
|
Instance Method Details
#escaped_text ⇒ Object
53
|
# File 'app/models/chunks/wiki.rb', line 53
def escaped_text() (@escaped.nil? ? nil : page_name) end
|
#link_text ⇒ Object
54
|
# File 'app/models/chunks/wiki.rb', line 54
def link_text() WikiWords.separate(page_name) end
|
#mask(content) ⇒ Object
51
|
# File 'app/models/chunks/wiki.rb', line 51
def mask(content) pre_mask + post_mask; end
|
#regexp ⇒ Object
52
|
# File 'app/models/chunks/wiki.rb', line 52
def regexp() Regexp.new(pre_mask + post_mask) end
|