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.
29
30
31
32
33
34
35
|
# File 'lib/citeproc/ruby/formats/html.rb', line 29
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.
24
25
26
|
# File 'lib/citeproc/ruby/formats/html.rb', line 24
def defaults
@defaults
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
27
28
29
|
# File 'lib/citeproc/ruby/formats/html.rb', line 27
def config
@config
end
|
Instance Method Details
#apply_display ⇒ Object
107
108
109
110
111
|
# File 'lib/citeproc/ruby/formats/html.rb', line 107
def apply_display
output.replace(
content_tag(config[:display], output, 'class' => "csl-#{options[:display]}" )
)
end
|
#apply_font_style ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/citeproc/ruby/formats/html.rb', line 79
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
87
88
89
|
# File 'lib/citeproc/ruby/formats/html.rb', line 87
def apply_font_variant
css['font-variant'] = options[:'font-variant']
end
|
#apply_font_weight ⇒ Object
91
92
93
94
95
96
97
|
# File 'lib/citeproc/ruby/formats/html.rb', line 91
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
99
100
101
|
# File 'lib/citeproc/ruby/formats/html.rb', line 99
def apply_text_decoration
css['text-decoration'] = options[:'text-decoration']
end
|
#apply_vertical_align ⇒ Object
103
104
105
|
# File 'lib/citeproc/ruby/formats/html.rb', line 103
def apply_vertical_align
css['vertical-align'] = options[:'vertical-align']
end
|
#bibliography(bibliography) ⇒ Object
37
38
39
40
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
|
# File 'lib/citeproc/ruby/formats/html.rb', line 37
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
75
76
77
|
# File 'lib/citeproc/ruby/formats/html.rb', line 75
def css_only?
config[:css_only]
end
|
#escape_quotes? ⇒ Boolean
121
122
123
|
# File 'lib/citeproc/ruby/formats/html.rb', line 121
def escape_quotes?
true
end
|
#prefix ⇒ Object
113
114
115
|
# File 'lib/citeproc/ruby/formats/html.rb', line 113
def prefix
CSL.encode_xml_text(options[:prefix])
end
|
#strip(string) ⇒ Object
125
126
127
|
# File 'lib/citeproc/ruby/formats/html.rb', line 125
def strip(string)
string.split(/((?:^<[^>]+>)|(?:<[^>]+>))$/, 2)
end
|
#suffix ⇒ Object
117
118
119
|
# File 'lib/citeproc/ruby/formats/html.rb', line 117
def suffix
CSL.encode_xml_text(options[:suffix])
end
|