Class: Trenni::MarkupString

Inherits:
String
  • Object
show all
Includes:
Markup
Defined in:
lib/trenni/markup.rb

Overview

Initialized from text which is escaped to use HTML entities.

Constant Summary collapse

ESCAPE =

This is only casually related to HTML, it’s just enough so that it would not be mis-interpreted by ‘Trenni::Parser`.

Substitutions.new("&" => "&amp;", "<" => "&lt;", ">" => "&gt;", "\"" => "&quot;")

Constants included from Markup

Trenni::Markup::EMPTY

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Markup

escape, #escape

Constructor Details

#initialize(string = nil, escape = true) ⇒ MarkupString

Convert ESCAPE characters into their corresponding entities.



51
52
53
54
55
56
57
58
59
60
# File 'lib/trenni/markup.rb', line 51

def initialize(string = nil, escape = true)
  if string
    super(string)
    
    # self.replace CGI.escapeHTML(self)
    ESCAPE.gsub!(self) if escape
  else
    super()
  end
end

Class Method Details

.raw(string) ⇒ Object



62
63
64
# File 'lib/trenni/markup.rb', line 62

def self.raw(string)
  self.new(string, false)
end