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
40
41
|
# 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
@css = nil
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
115
116
117
118
119
|
# File 'lib/citeproc/ruby/formats/html.rb', line 115
def apply_display
output.replace(
content_tag(config[:display], output, 'class' => "csl-#{options[:display]}" )
)
end
|
#apply_font_style ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/citeproc/ruby/formats/html.rb', line 85
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
93
94
95
|
# File 'lib/citeproc/ruby/formats/html.rb', line 93
def apply_font_variant
css['font-variant'] = options[:'font-variant']
end
|
#apply_font_weight ⇒ Object
97
98
99
100
101
102
103
|
# File 'lib/citeproc/ruby/formats/html.rb', line 97
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
105
106
107
|
# File 'lib/citeproc/ruby/formats/html.rb', line 105
def apply_text_decoration
css['text-decoration'] = options[:'text-decoration']
end
|
#apply_vertical_align ⇒ Object
109
110
111
112
113
|
# File 'lib/citeproc/ruby/formats/html.rb', line 109
def apply_vertical_align
css['vertical-align'] = Html.vertical_align[
options[:'vertical-align']
]
end
|
#bibliography(bibliography) ⇒ Object
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
78
79
|
# File 'lib/citeproc/ruby/formats/html.rb', line 43
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
81
82
83
|
# File 'lib/citeproc/ruby/formats/html.rb', line 81
def css_only?
config[:css_only]
end
|
#escape_quotes? ⇒ Boolean
129
130
131
|
# File 'lib/citeproc/ruby/formats/html.rb', line 129
def escape_quotes?
true
end
|
#prefix ⇒ Object
121
122
123
|
# File 'lib/citeproc/ruby/formats/html.rb', line 121
def prefix
CSL.encode_xml_text(options[:prefix])
end
|
#strip(string) ⇒ Object
133
134
135
|
# File 'lib/citeproc/ruby/formats/html.rb', line 133
def strip(string)
string.split(/((?:^<[^>]+>)|(?:<[^>]+>))$/, 2)
end
|
#suffix ⇒ Object
125
126
127
|
# File 'lib/citeproc/ruby/formats/html.rb', line 125
def suffix
CSL.encode_xml_text(options[:suffix])
end
|