Class: String
- Inherits:
-
Object
- Object
- String
- Includes:
- MaRuKu::Strings
- Defined in:
- lib/maruku/input/type_detection.rb,
lib/maruku/attributes.rb,
lib/maruku/output/to_html.rb,
lib/maruku/ext/math/latex_fix.rb,
lib/maruku/structures_inspect.rb,
lib/maruku/output/to_markdown.rb,
lib/maruku/output/to_latex_strings.rb,
lib/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
++
Constant Summary
- LATEX_ADD_SLASH =
These are TeX's special characters
[ ?{, ?}, ?$, ?&, ?#, ?_, ?%]
- LATEX_TO_CHARCODE =
These, we transform to char<ascii code>
[ ?^, ?~, ?>,?<]
- OtherGoodies =
other things that are good on the eyes
{ /(\s)LaTeX/ => '\1\\LaTeX\\xspace ', # XXX not if already \LaTeX # 'HTML' => '\\textsc{html}\\xspace ', # 'PDF' => '\\textsc{pdf}\\xspace ' }
- 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)
- - (Object) escape_to_latex(s)
-
- (Object) fix_latex
fix some LaTeX command-name clashes.
- - (Object) inspect_more(a = nil, b = nil)
- - (Object) md_type
-
- (Object) mysplit
" andrea censi " => [" andrea ", "censi "].
- - (Object) quote_if_needed
- - (Boolean) t2_contains_signature?
- - (Boolean) t2_empty?
-
- (Object) t2_get_signature
sig, rest = t2_get_signature.
-
- (Object) to_html
A string is rendered into HTML by creating a REXML::Text node.
-
- (Object) to_latex
escapes special characters.
-
- (Object) to_md(c = nil)
XXX: markdown escaping.
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
- (Object) escape_to_latex(s)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/maruku/output/to_latex_strings.rb', line 31 def escape_to_latex(s) s2 = "" s.each_byte do |b| if LATEX_TO_CHARCODE.include? b s2 += "{\\tt \\char#{b}}" elsif LATEX_ADD_SLASH.include? b s2 << ?\\ << b elsif b == ?\\ # there is no backslash in cmr10 fonts s2 += "$\\backslash$" else s2 << b end end s2 end |
- (Object) fix_latex
fix some LaTeX command-name clashes
3 4 5 6 7 8 9 10 11 |
# File 'lib/maruku/ext/math/latex_fix.rb', line 3 def fix_latex if #{html_math_engine} == 'itex2mml' s = self.gsub("\\mathop{", "\\operatorname{") s.gsub!(/\\begin\{svg\}.*?\\end\{svg\}/m, " ") s.gsub("\\space{", "\\itexspace{") else self end end |
- (Object) inspect_more(a = nil, b = nil)
24 25 26 |
# File 'lib/maruku/structures_inspect.rb', line 24 def inspect_more(a=nil,b=nil) inspect end |
- (Object) md_type
23 24 25 |
# File 'lib/maruku/input/type_detection.rb', line 23 def md_type() @md_type ||= line_md_type(self) end |
- (Object) mysplit
" andrea censi " => [" andrea ", "censi "]
29 30 31 |
# File 'lib/maruku/output/to_markdown.rb', line 29 def mysplit split.map{|x| x+" "} end |
- (Object) quote_if_needed
23 24 25 26 27 28 29 |
# File 'lib/maruku/attributes.rb', line 23 def quote_if_needed if /[\s\'\"]/.match self inspect else self end end |
- (Boolean) t2_contains_signature?
9 10 11 |
# File 'lib/maruku/input_textile2/t2_parser.rb', line 9 def t2_contains_signature? self =~ Textile2_Signature end |
- (Boolean) t2_empty?
5 6 7 |
# File 'lib/maruku/input_textile2/t2_parser.rb', line 5 def t2_empty? self =~ Textile2_EmptyLine end |
- (Object) t2_get_signature
sig, rest = t2_get_signature
14 15 16 17 |
# File 'lib/maruku/input_textile2/t2_parser.rb', line 14 def t2_get_signature self =~ Textile2_Signature return Textile2Signature.new($1), $2 end |
- (Object) to_html
A string is rendered into HTML by creating a REXML::Text node. REXML takes care of all the encoding.
34 35 36 |
# File 'lib/maruku/output/to_html.rb', line 34 def to_html REXML::Text.new(self) end |
- (Object) to_latex
escapes special characters
49 50 51 52 53 54 55 |
# File 'lib/maruku/output/to_latex_strings.rb', line 49 def to_latex s = escape_to_latex(self) OtherGoodies.each do |k, v| s.gsub!(k, v) end s end |
- (Object) to_md(c = nil)
XXX: markdown escaping
24 25 26 |
# File 'lib/maruku/output/to_markdown.rb', line 24 def to_md(c=nil) to_s end |