Class: WikiChunk::Link

Inherits:
WikiLink show all
Defined in:
app/models/chunks/wiki.rb

Overview

This chunk handles [[bracketted wiki words]] and [[AliasedWords|aliased wiki words]]. The first part of an aliased wiki word must be a WikiWord. If the WikiWord is aliased, the link_text field will contain the alias, otherwise link_text will contain the entire contents within the double brackets.

NOTE: This chunk must be tested before WikiWord since

a WikiWords can be a substring of a WikiLink.

Constant Summary collapse

/(":)?\[\[\s*([^\]\s][^\]]+?)\s*\]\]/
Regexp.new('^(.+):((file)|(pic))$', 0, 'utf-8')
ALIAS_SEPARATION =
Regexp.new('^(.+)\|(.+)$', 0, 'utf-8')

Instance Attribute Summary

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) ⇒ Link

Returns a new instance of Link.



109
110
111
112
113
114
115
116
# File 'app/models/chunks/wiki.rb', line 109

def initialize(match_data, content)
  super
  @textile_link_suffix, @page_name = match_data[1..2]
  @link_text = @page_name
  separate_link_type
  separate_alias
  @unmask_text = @content.page_link(@page_name, @link_text, @link_type)
end

Class Method Details

.patternObject



107
# File 'app/models/chunks/wiki.rb', line 107

def self.pattern() WIKI_LINK end