Class: WikiChunk::Word

Inherits:
WikiLink show all
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

Attributes inherited from WikiLink

#link_text, #link_type

Attributes inherited from WikiReference

#page_name

Attributes inherited from Chunk::Abstract

#text, #unmask_mode, #unmask_text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WikiLink

apply_to, #refpage, #textile_url?

Methods inherited from WikiReference

#refpage

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_textObject (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

.patternObject



71
72
73
# File 'app/models/chunks/wiki.rb', line 71

def self.pattern
  WIKI_WORD
end