Class: Media::HTML
- Inherits:
-
Object
show all
- Includes:
- Media
- Defined in:
- lib/media/html.rb
Constant Summary
Constants included
from Media
Symbol_to_class_string
Instance Method Summary
collapse
Methods included from Media
#b, #br, #bracket, #call_it, #format, #i, new, #par, #parenthesize, #u
Instance Method Details
#bold(string) ⇒ Object
18
19
20
|
# File 'lib/media/html.rb', line 18
def bold(string)
"<span style=\"font-weight:bold;\">" + string + "</span>"
end
|
10
11
12
|
# File 'lib/media/html.rb', line 10
def
"</body></html>"
end
|
6
7
8
|
# File 'lib/media/html.rb', line 6
def
"<html><body>"
end
|
#italics(string) ⇒ Object
14
15
16
|
# File 'lib/media/html.rb', line 14
def italics(string)
"<span style=\"font-style:italic;\">" + string + "</span>"
end
|
#list(citations_as_strings) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/media/html.rb', line 26
def list(citations_as_strings)
cts = citations_as_strings.map do |cit|
"\t<li>#{cit}</li>"
end
"<ol>\n" + cts.join("\n") + "\n</ol>\n"
end
|
#periodize(array_or_string) ⇒ Object
expects opening and closing tags. Operates on last one. trailing text (outside a tag) is operated on if existing <tag>text</tag> => <tag>text.</tag> <tag>text</tag>more_text => ‘…more_text.’ if the text already has a period, then no change method periodize (TODO: should alias, really)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/media/html.rb', line 39
def periodize(array_or_string)
if array_or_string.is_a?(Array)
array_or_string.map do |st|
periodize(st)
end
else
st = array_or_string
if st[-1,1] == '>'
st.sub(/(.*)(<\/.*?>)/) do |v|
if $1[-1,1] =~ /[\.\?\!]/
$1 + $2
else
$1 + '.' + $2
end
end
else
if st[-1,1] =~ /[\.\?\!]/
st
else
st << '.'
end
end
end
end
|
#underline(string) ⇒ Object
22
23
24
|
# File 'lib/media/html.rb', line 22
def underline(string)
"<span style=\"text-decoration:underline;\">" + string + "</span>"
end
|