Class: CiteProc::Ruby::Formats::Html
Class Attribute Summary collapse
Instance Attribute Summary collapse
#locale
Instance Method Summary
collapse
#apply, #apply_prefix, #apply_quotes, #apply_suffix, #apply_text_case, #close_inner_quote, #close_quote, #join, #keys, load, #punctuation_in_quotes?, #split_closing_quotes, squeezable, #squeezable?, squeezable?, #squeeze_prefix, #squeeze_suffix, stopword?
Constructor Details
#initialize(config = nil) ⇒ Html
Returns a new instance of Html.
33
34
35
36
37
38
39
|
# File 'lib/citeproc/ruby/formats/html.rb', line 33
def initialize(config = nil)
if config.nil?
@config = Html.defaults.dup
else
@config = Html.defaults.merge(config)
end
end
|
Class Attribute Details
.defaults ⇒ Object
Returns the value of attribute defaults.
27
28
29
|
# File 'lib/citeproc/ruby/formats/html.rb', line 27
def defaults
@defaults
end
|
.vertical_align ⇒ Object
Returns the value of attribute vertical_align.
28
29
30
|
# File 'lib/citeproc/ruby/formats/html.rb', line 28
def vertical_align
@vertical_align
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
31
32
33
|
# File 'lib/citeproc/ruby/formats/html.rb', line 31
def config
@config
end
|
Instance Method Details
#apply_display ⇒ Object
113
114
115
116
117
|
# File 'lib/citeproc/ruby/formats/html.rb', line 113
def apply_display
output.replace(
content_tag(config[:display], output, 'class' => "csl-#{options[:display]}" )
)
end
|
#apply_font_style ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/citeproc/ruby/formats/html.rb', line 83
def apply_font_style
if options[:'font-style'] == 'italic' && !css_only?
output.replace content_tag(config[:italic], output)
else
css['font-style'] = options[:'font-style']
end
end
|
#apply_font_variant ⇒ Object
91
92
93
|
# File 'lib/citeproc/ruby/formats/html.rb', line 91
def apply_font_variant
css['font-variant'] = options[:'font-variant']
end
|
#apply_font_weight ⇒ Object
95
96
97
98
99
100
101
|
# File 'lib/citeproc/ruby/formats/html.rb', line 95
def apply_font_weight
if options[:'font-weight'] == 'bold' && !css_only?
output.replace content_tag(config[:bold], output)
else
css['font-weight'] = options[:'font-weight']
end
end
|
#apply_text_decoration ⇒ Object
103
104
105
|
# File 'lib/citeproc/ruby/formats/html.rb', line 103
def apply_text_decoration
css['text-decoration'] = options[:'text-decoration']
end
|
#apply_vertical_align ⇒ Object
107
108
109
110
111
|
# File 'lib/citeproc/ruby/formats/html.rb', line 107
def apply_vertical_align
css['vertical-align'] = Html.vertical_align[
options[:'vertical-align']
]
end
|
#bibliography(bibliography) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/citeproc/ruby/formats/html.rb', line 41
def bibliography(bibliography)
ol, li, indent, unit =
config.values_at(:bib_container, :bib_entry, :bib_indent, :bib_unit)
container_options = {}
container_options['class'] = config[:bib_container_class]
entry_options = {}
entry_options['class'] = config[:bib_entry_class]
entry_options['style'] = {}
container_options['style'] = {}
if bibliography.line_spacing != 1.0
container_options['style']['line-height'] = bibliography.line_spacing
end
if bibliography.hanging_indent?
hanging_indent = "#{config[:bib_hanging_indent]}#{bib_unit}"
container_options['style']['padding-left'] = hanging_indent
entry_options['style']['text-indent'] = "-#{hanging_indent}"
end
if bibliography.entry_spacing != 1.0
entry_options['style']['margin-bottom'] = "#{bibliography.entry_spacing}#{unit}"
end
bibliography. = opening_tag(ol, container_options)
bibliography. = closing_tag(ol)
bibliography.prefix = [indent, opening_tag(li, entry_options)].join('')
bibliography.suffix = closing_tag(li)
bibliography.connector = indent ? "\n" : ''
bibliography
end
|
#css_only? ⇒ Boolean
79
80
81
|
# File 'lib/citeproc/ruby/formats/html.rb', line 79
def css_only?
config[:css_only]
end
|
#escape_quotes? ⇒ Boolean
127
128
129
|
# File 'lib/citeproc/ruby/formats/html.rb', line 127
def escape_quotes?
true
end
|
#prefix ⇒ Object
119
120
121
|
# File 'lib/citeproc/ruby/formats/html.rb', line 119
def prefix
CSL.encode_xml_text(options[:prefix])
end
|
#strip(string) ⇒ Object
131
132
133
|
# File 'lib/citeproc/ruby/formats/html.rb', line 131
def strip(string)
string.split(/((?:^<[^>]+>)|(?:<[^>]+>))$/, 2)
end
|
#suffix ⇒ Object
123
124
125
|
# File 'lib/citeproc/ruby/formats/html.rb', line 123
def suffix
CSL.encode_xml_text(options[:suffix])
end
|