Class: String

Inherits:
Object show all
Includes:
MaRuKu::Strings
Defined in:
lib/amp-front/third_party/maruku/input/type_detection.rb,
lib/amp-front/third_party/maruku/attributes.rb,
lib/amp-front/third_party/maruku/output/to_ansi.rb,
lib/amp-front/third_party/maruku/output/to_ansi.rb,
lib/amp-front/third_party/maruku/output/to_html.rb,
lib/amp-front/third_party/maruku/output/to_markdown.rb,
lib/amp-front/third_party/maruku/structures_inspect.rb,
lib/amp-front/third_party/maruku/input_textile2/t2_parser.rb

Overview

Copyright (C) 2006  Andrea Censi  <andrea (at) rubyforge.org>

This file is part of Maruku.

Maruku is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Maruku is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Maruku; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

++

Constant Summary collapse

Textile2_EmptyLine =
/^\s*$/
Textile2_Signature =
/^(\S+\.?)\.\s(.*)/

Constants included from MaRuKu::Strings

MaRuKu::Strings::Abbreviation, MaRuKu::Strings::AttributeDefinitionList, MaRuKu::Strings::Definition, MaRuKu::Strings::EMailAddress, MaRuKu::Strings::FootnoteText, MaRuKu::Strings::HeaderWithAttributes, MaRuKu::Strings::HeaderWithId, MaRuKu::Strings::IncompleteLink, MaRuKu::Strings::InlineAttributeList, MaRuKu::Strings::LinkRegex, MaRuKu::Strings::MightBeTableHeader, MaRuKu::Strings::Sep, MaRuKu::Strings::TabSize, MaRuKu::Strings::TableSeparator

Instance Method Summary collapse

Methods included from MaRuKu::Strings

#add_tabs, #dbg_describe_ary, #force_linebreak?, #line_md_type, #normalize_key_and_value, #num_leading_hashes, #number_of_leading_spaces, #parse_email_headers, #sanitize_ref_id, #spaces_before_first_char, #split_lines, #strip_hashes, #strip_indent, #unquote

Instance Method Details



42
# File 'lib/amp-front/third_party/maruku/output/to_ansi.rb', line 42

def blink; colorize(5, 25); end

#boldObject

Returns the string, colored red.



40
# File 'lib/amp-front/third_party/maruku/output/to_ansi.rb', line 40

def bold; colorize(1, 22); end

#colorize(color_code, closing_tag = 39) ⇒ String

Returns the string, encoded for a tty terminal with the given color code.

Parameters:

  • color_code (String)

    a TTY color code

Returns:

  • (String)

    the string wrapped in non-printing characters to make the text appear in a given color



17
18
19
# File 'lib/amp-front/third_party/maruku/output/to_ansi.rb', line 17

def colorize(color_code, closing_tag = 39)
  "\e[#{color_code}m#{self}\e[#{closing_tag}m"
end

#inspect_more(a = nil, b = nil) ⇒ Object



24
25
26
# File 'lib/amp-front/third_party/maruku/structures_inspect.rb', line 24

def inspect_more(a=nil,b=nil)
	inspect
end

#md_typeObject



23
24
25
# File 'lib/amp-front/third_party/maruku/input/type_detection.rb', line 23

def md_type()
	@md_type ||= line_md_type(self)
end

#mysplitObject

“ andrea censi ” => [“ andrea ”, “censi ”]



29
30
31
# File 'lib/amp-front/third_party/maruku/output/to_markdown.rb', line 29

def mysplit
	split.map{|x| x+" "}
end

#quote_if_neededObject



23
24
25
26
27
28
29
# File 'lib/amp-front/third_party/maruku/attributes.rb', line 23

def quote_if_needed
	if /[\s\'\"]/.match self
		inspect
	else
		self
	end
end

#t2_contains_signature?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/amp-front/third_party/maruku/input_textile2/t2_parser.rb', line 9

def t2_contains_signature?
	self =~ Textile2_Signature
end

#t2_empty?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/amp-front/third_party/maruku/input_textile2/t2_parser.rb', line 5

def t2_empty?
	self =~ Textile2_EmptyLine
end

#t2_get_signatureObject

sig, rest = t2_get_signature



14
15
16
17
# File 'lib/amp-front/third_party/maruku/input_textile2/t2_parser.rb', line 14

def t2_get_signature
	self =~ Textile2_Signature
	return Textile2Signature.new($1), $2
end

#to_ansiObject

escapes special characters



5
6
7
# File 'lib/amp-front/third_party/maruku/output/to_ansi.rb', line 5

def to_ansi
   self
end

#to_htmlObject

A string is rendered into HTML by creating a REXML::Text node. REXML takes care of all the encoding.



34
35
36
# File 'lib/amp-front/third_party/maruku/output/to_html.rb', line 34

def to_html
	REXML::Text.new(self)
end

#to_md(c = nil) ⇒ Object

XXX: markdown escaping



24
25
26
# File 'lib/amp-front/third_party/maruku/output/to_markdown.rb', line 24

def to_md(c=nil)
	to_s
end

#underlineObject



41
# File 'lib/amp-front/third_party/maruku/output/to_ansi.rb', line 41

def underline; colorize(4, 24); end