Class: WikiChunk::Word
- Inherits:
-
WikiLink
- Object
- Chunk::Abstract
- WikiReference
- WikiLink
- WikiChunk::Word
- Defined in:
- app/models/chunks/wiki.rb
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.
Constant Summary collapse
- WIKI_WORD =
Regexp.new('(":)?(\\\\)?(' + WikiWords::WIKI_WORD_PATTERN + ')\b', 0, "utf-8")
Instance Attribute Summary collapse
-
#escaped_text ⇒ Object
readonly
Returns the value of attribute escaped_text.
Attributes inherited from WikiLink
Attributes inherited from WikiReference
Attributes inherited from Chunk::Abstract
#text, #unmask_mode, #unmask_text
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(match_data, content) ⇒ Word
constructor
A new instance of Word.
Methods inherited from WikiLink
apply_to, #refpage, #textile_url?
Methods inherited from WikiReference
Methods inherited from Chunk::Abstract
apply_to, #escaped?, #id, inherited, #mask, mask_re, mask_string, #rendered?, #revert, #unmask
Constructor Details
#initialize(match_data, content) ⇒ Word
Returns a new instance of Word.
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/models/chunks/wiki.rb', line 75 def initialize(match_data, content) super @textile_link_suffix, @escape, @page_name = match_data[1..3] if @escape @unmask_mode = :escape @escaped_text = @page_name else @escaped_text = nil end @link_text = WikiWords.separate(@page_name) @unmask_text = (@escaped_text || @content.page_link(@page_name, @link_text, @link_type)) end |
Instance Attribute Details
#escaped_text ⇒ Object (readonly)
Returns the value of attribute escaped_text.
65 66 67 |
# File 'app/models/chunks/wiki.rb', line 65 def escaped_text @escaped_text end |
Class Method Details
.pattern ⇒ Object
71 72 73 |
# File 'app/models/chunks/wiki.rb', line 71 def self.pattern WIKI_WORD end |