relaton-render 3.0.0.pre.alpha.7 → 3.0.0.pre.alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/relaton/render/general.rb +18 -2
- data/lib/relaton/render/iso690/element.rb +19 -6
- data/lib/relaton/render/iso690/elements/citeid.rb +39 -0
- data/lib/relaton/render/iso690/elements/creator.rb +31 -5
- data/lib/relaton/render/iso690/elements/identifier.rb +8 -3
- data/lib/relaton/render/iso690/elements/location.rb +25 -4
- data/lib/relaton/render/iso690/elements/production.rb +25 -1
- data/lib/relaton/render/iso690/elements/pub_date.rb +6 -1
- data/lib/relaton/render/iso690/elements/status.rb +30 -0
- data/lib/relaton/render/iso690/elements/title.rb +2 -1
- data/lib/relaton/render/iso690/elements.rb +7 -2
- data/lib/relaton/render/iso690/fields.rb +6 -3
- data/lib/relaton/render/iso690/i18n.rb +1 -0
- data/lib/relaton/render/iso690/renderer.rb +13 -0
- data/lib/relaton/render/iso690/style/locale.rb +4 -0
- data/lib/relaton/render/iso690/style/name_form.rb +10 -0
- data/lib/relaton/render/iso690/style/template_map.rb +4 -0
- data/lib/relaton/render/iso690/style/type_template.rb +4 -0
- data/lib/relaton/render/iso690/template.rb +32 -2
- data/lib/relaton/render/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b2cc7ff33eb9f42dda9093ce14cfe39a2495d4499d93150e50783da711e8087
|
|
4
|
+
data.tar.gz: 8be8a9bea072cd0e69307b5ea8fe3674429e302dd8751f1f399b81a5a154c08f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1101c3d3781e1c51f78728e74a5ea7c3897e2d52407d896057952d6eb0461f7f6dab1344ef7141e0d37bf77348cc203019420e6e4ea9753986746e2261ef344b
|
|
7
|
+
data.tar.gz: 4be1e8b804b46e08494db403d5bb9100760415af858dc0a96e2d0db30f82cd00d8d53cdd8447a06d434847d6316389b6b3346e7307a5f5630717105b6a3dab06
|
|
@@ -62,7 +62,8 @@ module Relaton
|
|
|
62
62
|
next
|
|
63
63
|
end
|
|
64
64
|
m[item.id] = {
|
|
65
|
-
id: item.id, ord: i,
|
|
65
|
+
id: item.id, ord: i,
|
|
66
|
+
formattedref: terminate_reference(ref),
|
|
66
67
|
citation: citation_renderings(item, ref),
|
|
67
68
|
}
|
|
68
69
|
end
|
|
@@ -71,9 +72,24 @@ module Relaton
|
|
|
71
72
|
# isodoc's styled citations consume these keys: the default is the
|
|
72
73
|
# authoritative identifier; the short cite is the style's citation,
|
|
73
74
|
# falling back to the reference rendering (the 1.x short-cite)
|
|
75
|
+
FIRST_DELIM = "<span class='fmt-first-biblio-delim'/>"
|
|
76
|
+
|
|
77
|
+
# render_all feeds the bibliography list: a reference not ending
|
|
78
|
+
# in the biblio terminator takes one (the 1.x render1 behaviour;
|
|
79
|
+
# single-item render stays verbatim)
|
|
80
|
+
def terminate_reference(ref)
|
|
81
|
+
return ref if ref.empty? || ref.rstrip.end_with?(".")
|
|
82
|
+
|
|
83
|
+
"#{ref}."
|
|
84
|
+
end
|
|
85
|
+
|
|
74
86
|
def citation_renderings(item, ref)
|
|
75
87
|
short = @renderer.citation(item)
|
|
76
|
-
short =
|
|
88
|
+
short = if short.empty?
|
|
89
|
+
@renderer.render_short(item, FIRST_DELIM)
|
|
90
|
+
else
|
|
91
|
+
short
|
|
92
|
+
end
|
|
77
93
|
|
|
78
94
|
{
|
|
79
95
|
full: ref,
|
|
@@ -8,11 +8,12 @@ module Relaton
|
|
|
8
8
|
# predicate, #render the element's formatting method. Punctuation
|
|
9
9
|
# between elements belongs to the kind/style, not the element.
|
|
10
10
|
class Element
|
|
11
|
-
def initialize(model, style:, i18n:, kind: nil)
|
|
11
|
+
def initialize(model, style:, i18n:, kind: nil, short: false)
|
|
12
12
|
@model = model
|
|
13
13
|
@style = style
|
|
14
14
|
@i18n = i18n
|
|
15
15
|
@kind = kind
|
|
16
|
+
@short = short
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def present?
|
|
@@ -81,17 +82,24 @@ module Relaton
|
|
|
81
82
|
""
|
|
82
83
|
end.reject(&:empty?)
|
|
83
84
|
sep = @style.scheme.name_form.initials_separator.to_s
|
|
84
|
-
return reinitials(localized(person.name&.formatted_initials)
|
|
85
|
-
|
|
86
|
-
return parts.map
|
|
85
|
+
return reinitials(localized(person.name&.formatted_initials)) if
|
|
86
|
+
parts.empty?
|
|
87
|
+
return parts.map(&method(:initial)).join(sep) if initials?
|
|
87
88
|
|
|
88
89
|
parts.join(" ")
|
|
89
90
|
end
|
|
90
91
|
|
|
91
92
|
# Declared initials are a list in string form; rejoin them with
|
|
92
93
|
# the style's separator
|
|
93
|
-
def reinitials(raw
|
|
94
|
-
|
|
94
|
+
def reinitials(raw)
|
|
95
|
+
sep = @style.scheme.name_form.initials_separator.to_s
|
|
96
|
+
dots = @style.scheme.name_form.initials_period
|
|
97
|
+
raw.split(/\s+/).reject(&:empty?).map { |i| dots ? i : i.delete(".") }
|
|
98
|
+
.join(sep)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def initial(name)
|
|
102
|
+
@style.scheme.name_form.initials_period ? "#{name[0]}." : name[0]
|
|
95
103
|
end
|
|
96
104
|
|
|
97
105
|
def initials?
|
|
@@ -99,6 +107,11 @@ module Relaton
|
|
|
99
107
|
end
|
|
100
108
|
|
|
101
109
|
def join_names(names)
|
|
110
|
+
# A style with no join word renders a plain serial list
|
|
111
|
+
if @i18n.label("and").empty? && names.size > 1
|
|
112
|
+
return names.join(", ")
|
|
113
|
+
end
|
|
114
|
+
|
|
102
115
|
oxford = @i18n.label("oxford_comma")
|
|
103
116
|
if serial_list? && names.size > 1 && !oxford.empty?
|
|
104
117
|
return "#{names[0..-2].join(', ')}#{oxford} " \
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Render
|
|
5
|
+
module Iso690
|
|
6
|
+
module Elements
|
|
7
|
+
# The cited identifier with the item's status beside it and the
|
|
8
|
+
# list comma ("OGC 05-020r27 (Draft)," / "ISO 712,"): the comma
|
|
9
|
+
# stays with the identifier whichever side of the status it
|
|
10
|
+
# follows
|
|
11
|
+
class Citeid < Element
|
|
12
|
+
def present?
|
|
13
|
+
identifier_element.present?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def render
|
|
17
|
+
text = identifier_element.render
|
|
18
|
+
stage = status_element.present? ? status_element.render : ""
|
|
19
|
+
stage.empty? ? "#{text}," : "#{text}#{stage},"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def identifier_element
|
|
25
|
+
@identifier_element ||=
|
|
26
|
+
Identifier.new(@model, style: @style, i18n: @i18n, kind: @kind,
|
|
27
|
+
short: @short)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def status_element
|
|
31
|
+
@status_element ||=
|
|
32
|
+
Status.new(@model, style: @style, i18n: @i18n, kind: @kind,
|
|
33
|
+
short: @short)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -11,11 +11,15 @@ module Relaton
|
|
|
11
11
|
# rendered string.
|
|
12
12
|
class Creator < Element
|
|
13
13
|
def present?
|
|
14
|
-
!creators.empty?
|
|
14
|
+
!creators.empty? || !fallback_name.empty?
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def render
|
|
18
|
-
|
|
18
|
+
return plain_render if @short
|
|
19
|
+
|
|
20
|
+
joined = if creators.empty?
|
|
21
|
+
fallback_name
|
|
22
|
+
elsif (form = @style.templates.creators) && !form.empty?
|
|
19
23
|
::Relaton::Render::Iso690::Template.new(form).evaluate(
|
|
20
24
|
"names" => Template::Field[true, join(names)],
|
|
21
25
|
)
|
|
@@ -26,18 +30,26 @@ module Relaton
|
|
|
26
30
|
when "afterPeriod"
|
|
27
31
|
# the in-slot trailing space separates the (eds.) marker
|
|
28
32
|
# from the next element, which follows directly in the
|
|
29
|
-
# template; a lone editor is unmarked
|
|
30
|
-
if editors? &&
|
|
33
|
+
# template; a lone editor is unmarked unless declared
|
|
34
|
+
if editors? && marked?
|
|
31
35
|
"#{period(joined)} (#{role_word}) "
|
|
32
36
|
else
|
|
33
37
|
"#{period(joined)} "
|
|
34
38
|
end
|
|
35
39
|
else
|
|
36
|
-
marker = editors? &&
|
|
40
|
+
marker = editors? && marked? ? " (#{role_word})" : ''
|
|
37
41
|
"#{joined}#{marker}"
|
|
38
42
|
end
|
|
39
43
|
end
|
|
40
44
|
|
|
45
|
+
# The short cite splits after the creators: they render as a
|
|
46
|
+
# plain join, without the wrap and sentence period (1.x
|
|
47
|
+
# short-cite templates carried no wrap)
|
|
48
|
+
def plain_render
|
|
49
|
+
marker = editors? && creators.size > 1 ? " (#{role_word})" : ''
|
|
50
|
+
"#{join(names)}#{marker}"
|
|
51
|
+
end
|
|
52
|
+
|
|
41
53
|
def role_placement
|
|
42
54
|
@style.scheme.name_form.role_placement || "glue"
|
|
43
55
|
end
|
|
@@ -46,6 +58,10 @@ module Relaton
|
|
|
46
58
|
text.end_with?(".") ? text : "#{text}."
|
|
47
59
|
end
|
|
48
60
|
|
|
61
|
+
def marked?
|
|
62
|
+
creators.size > 1 || name_form.lone_editor_marked
|
|
63
|
+
end
|
|
64
|
+
|
|
49
65
|
def role_word
|
|
50
66
|
@i18n.label(creators.one? ? "ed" : "eds")
|
|
51
67
|
end
|
|
@@ -77,6 +93,16 @@ module Relaton
|
|
|
77
93
|
end
|
|
78
94
|
end
|
|
79
95
|
|
|
96
|
+
# The declared creator fallback (e.g. the publisher's
|
|
97
|
+
# abbreviation for standards with no personal creators)
|
|
98
|
+
def fallback_name
|
|
99
|
+
return "" unless name_form.creator_fallback == "publisher_abbrev"
|
|
100
|
+
|
|
101
|
+
contributors("publisher").map do |c|
|
|
102
|
+
localized(c.organization&.abbreviation)
|
|
103
|
+
end.reject(&:empty?).first.to_s
|
|
104
|
+
end
|
|
105
|
+
|
|
80
106
|
def names
|
|
81
107
|
creators.each_with_index
|
|
82
108
|
.map do |contributor, index|
|
|
@@ -13,16 +13,21 @@ module Relaton
|
|
|
13
13
|
!identifiers.empty?
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
|
|
16
17
|
def render
|
|
17
|
-
identifiers.
|
|
18
|
-
|
|
18
|
+
d = identifiers.first or return ""
|
|
19
|
+
|
|
20
|
+
IdentifierKinds.render(d)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
private
|
|
22
24
|
|
|
25
|
+
# Scoped identifiers (anchor, biblio-tag) are pipeline
|
|
26
|
+
# artefacts, not cited identifiers
|
|
23
27
|
def identifiers
|
|
24
28
|
Array(@model.docidentifier).reject do |d|
|
|
25
|
-
INTERNAL_TYPES.include?(d.type) ||
|
|
29
|
+
INTERNAL_TYPES.include?(d.type) ||
|
|
30
|
+
!d.scope.to_s.empty? || d.content.to_s.strip.empty?
|
|
26
31
|
end
|
|
27
32
|
end
|
|
28
33
|
end
|
|
@@ -12,7 +12,8 @@ module Relaton
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def render
|
|
15
|
-
|
|
15
|
+
form = uri_form
|
|
16
|
+
text = if form && !form.empty?
|
|
16
17
|
::Relaton::Render::Iso690::Template.new(form).evaluate(
|
|
17
18
|
"uri" => Template::Field[!uri.empty?, uri],
|
|
18
19
|
)
|
|
@@ -20,11 +21,25 @@ module Relaton
|
|
|
20
21
|
uri
|
|
21
22
|
end
|
|
22
23
|
|
|
23
|
-
"#{@i18n.label('available_from')}
|
|
24
|
+
label = @short ? "" : "#{@i18n.label('available_from')} "
|
|
25
|
+
"#{label}#{text}".strip
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
private
|
|
27
29
|
|
|
30
|
+
# The short cite renders the bare uri (1.x short templates),
|
|
31
|
+
# the reference the declared form
|
|
32
|
+
def uri_form
|
|
33
|
+
if @short
|
|
34
|
+
short_form = @style.templates.uri_short
|
|
35
|
+
return :bare if short_form.empty?
|
|
36
|
+
|
|
37
|
+
return short_form
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
@style.templates.uri
|
|
41
|
+
end
|
|
42
|
+
|
|
28
43
|
def uri
|
|
29
44
|
from_accesslocation =
|
|
30
45
|
Array(@model.accesslocation).map(&:to_s).reject(&:empty?)
|
|
@@ -32,8 +47,14 @@ module Relaton
|
|
|
32
47
|
return from_accesslocation.first.to_s
|
|
33
48
|
end
|
|
34
49
|
|
|
35
|
-
Array(@model.source).
|
|
36
|
-
.
|
|
50
|
+
uris = Array(@model.source).reject do |u|
|
|
51
|
+
u.content.to_s.strip.empty?
|
|
52
|
+
end
|
|
53
|
+
# the citation uri outranks the rest (1.x uri extraction)
|
|
54
|
+
preferred = uris.find { |u| u.type == "citation" } ||
|
|
55
|
+
uris.find { |u| u.type == "attachment" } ||
|
|
56
|
+
uris.find { |u| u.type == "src" } || uris.first
|
|
57
|
+
preferred&.content.to_s
|
|
37
58
|
end
|
|
38
59
|
end
|
|
39
60
|
end
|
|
@@ -13,10 +13,34 @@ module Relaton
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def render
|
|
16
|
+
if publisher_first?
|
|
17
|
+
return no_place_production_publisher_first if places.empty? &&
|
|
18
|
+
no_place_declared?
|
|
19
|
+
|
|
20
|
+
return [publishers.join("; "), places.join("; ")]
|
|
21
|
+
.reject(&:empty?).join(production_sep)
|
|
22
|
+
end
|
|
23
|
+
|
|
16
24
|
return no_place_production if places.empty? && no_place_declared?
|
|
17
25
|
|
|
18
26
|
[places.join("; "), publishers.join("; ")]
|
|
19
|
-
.reject(&:empty?).join(
|
|
27
|
+
.reject(&:empty?).join(production_sep)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def publisher_first?
|
|
31
|
+
@i18n.punct_fetch("production_order", "") == "publisher_first"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def production_sep
|
|
35
|
+
@i18n.punct_fetch("production_sep", ": ")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def no_place_production_publisher_first
|
|
39
|
+
label = @i18n.label("no_place")
|
|
40
|
+
return "" if label.empty? || label == "no_place"
|
|
41
|
+
|
|
42
|
+
pubs = publishers.join("; ")
|
|
43
|
+
pubs.empty? ? label : "#{pubs}, #{label}"
|
|
20
44
|
end
|
|
21
45
|
|
|
22
46
|
# The no-place placeholder keeps the production separator even
|
|
@@ -14,7 +14,12 @@ module Relaton
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def render
|
|
17
|
-
range || year&.to_s
|
|
17
|
+
text = range || year&.to_s
|
|
18
|
+
return text if (form = @style.templates.date_form).empty?
|
|
19
|
+
|
|
20
|
+
::Relaton::Render::Iso690::Template.new(form).evaluate(
|
|
21
|
+
"date" => Template::Field[!text.to_s.empty?, text.to_s],
|
|
22
|
+
)
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
private
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Render
|
|
5
|
+
module Iso690
|
|
6
|
+
module Elements
|
|
7
|
+
# The item's status stage, capitalized, parenthesized beside
|
|
8
|
+
# the identifier ("OGC 05-020r27 (Draft)"); published statuses
|
|
9
|
+
# are not cited
|
|
10
|
+
class Status < Element
|
|
11
|
+
def present?
|
|
12
|
+
!stage.empty? &&
|
|
13
|
+
!%w[published retired].include?(stage.downcase)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def render
|
|
17
|
+
" (#{stage})"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def stage
|
|
23
|
+
raw = @model.status&.stage&.content.to_s
|
|
24
|
+
raw.empty? ? "" : raw.sub(/^\w/) { |c| c.upcase }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -14,7 +14,8 @@ module Relaton
|
|
|
14
14
|
def render
|
|
15
15
|
text = main_title
|
|
16
16
|
return text if analytic?
|
|
17
|
-
if
|
|
17
|
+
if !@short &&
|
|
18
|
+
(form = @style.title_form_for(Kinds.kind_for(@model.type)))
|
|
18
19
|
text = ::Relaton::Render::Iso690::Template.new(form).evaluate(
|
|
19
20
|
"title" => Template::Field[!text.empty?, text],
|
|
20
21
|
)
|
|
@@ -20,6 +20,8 @@ module Relaton
|
|
|
20
20
|
autoload :Extent, "relaton/render/iso690/elements/extent"
|
|
21
21
|
autoload :Access, "relaton/render/iso690/elements/access"
|
|
22
22
|
autoload :Stddoc, "relaton/render/iso690/elements/stddoc"
|
|
23
|
+
autoload :Status, "relaton/render/iso690/elements/status"
|
|
24
|
+
autoload :Citeid, "relaton/render/iso690/elements/citeid"
|
|
23
25
|
|
|
24
26
|
CLASSES = {
|
|
25
27
|
creator: Creator,
|
|
@@ -37,10 +39,13 @@ module Relaton
|
|
|
37
39
|
extent: Extent,
|
|
38
40
|
access: Access,
|
|
39
41
|
stddoc: Stddoc,
|
|
42
|
+
status: Status,
|
|
43
|
+
citeid: Citeid,
|
|
40
44
|
}.freeze
|
|
41
45
|
|
|
42
|
-
def self.build(name, model, style:, i18n:)
|
|
43
|
-
CLASSES.fetch(name).new(model, style: style, i18n: i18n
|
|
46
|
+
def self.build(name, model, style:, i18n:, short: false)
|
|
47
|
+
CLASSES.fetch(name).new(model, style: style, i18n: i18n,
|
|
48
|
+
short: short)
|
|
44
49
|
end
|
|
45
50
|
end
|
|
46
51
|
end
|
|
@@ -11,14 +11,16 @@ module Relaton
|
|
|
11
11
|
ELEMENT_SLOTS = %i[
|
|
12
12
|
creator title edition medium series production
|
|
13
13
|
date numeration component_part identifier location size
|
|
14
|
-
extent access stddoc
|
|
14
|
+
extent access stddoc status citeid
|
|
15
15
|
].freeze
|
|
16
16
|
|
|
17
|
-
def initialize(model, style:, i18n:, disambiguator: nil
|
|
17
|
+
def initialize(model, style:, i18n:, disambiguator: nil,
|
|
18
|
+
short: false)
|
|
18
19
|
@model = model
|
|
19
20
|
@style = style
|
|
20
21
|
@i18n = i18n
|
|
21
22
|
@disambiguator = disambiguator.to_s
|
|
23
|
+
@short = short
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
def to_h
|
|
@@ -33,7 +35,8 @@ module Relaton
|
|
|
33
35
|
private
|
|
34
36
|
|
|
35
37
|
def element_field(slot)
|
|
36
|
-
element = Elements.build(slot, @model, style: @style,
|
|
38
|
+
element = Elements.build(slot, @model, style: @style,
|
|
39
|
+
i18n: @i18n, short: @short)
|
|
37
40
|
text = element.render.to_s
|
|
38
41
|
if element.present? && !text.empty?
|
|
39
42
|
return Template::Field[true, text]
|
|
@@ -52,6 +52,19 @@ module Relaton
|
|
|
52
52
|
Array(model.docidentifier).any? { |d| types.include?(d.type) }
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# The short cite: the reference with the first-biblio marker
|
|
56
|
+
def render_short(model, delim)
|
|
57
|
+
kind = Kinds.kind_for(model.type)
|
|
58
|
+
template = @style.type_template_for(kind)&.short ||
|
|
59
|
+
@style.template_for(kind, home: home_docid?(model))
|
|
60
|
+
Template.new(template).evaluate_short(
|
|
61
|
+
Fields.new(model, style: @style, i18n: @i18n, short: true).to_h,
|
|
62
|
+
delim,
|
|
63
|
+
)
|
|
64
|
+
rescue ::Relaton::Render::Unrenderable
|
|
65
|
+
""
|
|
66
|
+
end
|
|
67
|
+
|
|
55
68
|
# In-text form: SURNAME, year + disambiguator (name-and-date)
|
|
56
69
|
def citation(model, disambiguator: nil)
|
|
57
70
|
Template.new(@style.templates.citation).evaluate(
|
|
@@ -17,6 +17,9 @@ module Relaton
|
|
|
17
17
|
# Arbitrary label overrides (edition words, join punctuation,
|
|
18
18
|
# size units): merged over the language pack verbatim.
|
|
19
19
|
attribute :labels, :hash, default: -> { {} }
|
|
20
|
+
# Typographic punctuation overrides (production order and
|
|
21
|
+
# separator), declared as in the language packs
|
|
22
|
+
attribute :punct, :hash, default: -> { {} }
|
|
20
23
|
|
|
21
24
|
key_value do
|
|
22
25
|
map "and", to: :conj
|
|
@@ -27,6 +30,7 @@ module Relaton
|
|
|
27
30
|
map "at", to: :at
|
|
28
31
|
map "availableAt", to: :available_at
|
|
29
32
|
map "labels", to: :labels
|
|
33
|
+
map "punct", to: :punct
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
LABEL_FOR = {
|
|
@@ -26,6 +26,13 @@ module Relaton
|
|
|
26
26
|
# Organization names take the inverted form's casing; small-cap
|
|
27
27
|
# styles keep the declared case
|
|
28
28
|
attribute :org_upcase, :boolean, default: -> { true }
|
|
29
|
+
# When no personal creator exists, the creator slot falls back
|
|
30
|
+
# to the publisher's abbreviation ("ISO: ISO 712, ...")
|
|
31
|
+
attribute :creator_fallback, :string
|
|
32
|
+
# A lone editor still carries the role marker ("(ed.)")
|
|
33
|
+
attribute :lone_editor_marked, :boolean, default: -> { false }
|
|
34
|
+
# Initials without their trailing periods ("Nixon RM")
|
|
35
|
+
attribute :initials_period, :boolean, default: -> { true }
|
|
29
36
|
# The inverted form's surname casing: the name-date convention
|
|
30
37
|
# upcases; small-cap styles keep the declared case
|
|
31
38
|
attribute :surname_upcase, :boolean, default: -> { true }
|
|
@@ -40,6 +47,9 @@ module Relaton
|
|
|
40
47
|
map "invertedAll", to: :inverted_all
|
|
41
48
|
map "listStyle", to: :list_style
|
|
42
49
|
map "orgUpcase", to: :org_upcase
|
|
50
|
+
map "creatorFallback", to: :creator_fallback
|
|
51
|
+
map "loneEditorMarked", to: :lone_editor_marked
|
|
52
|
+
map "initialsPeriod", to: :initials_period
|
|
43
53
|
map "surnameUpcase", to: :surname_upcase
|
|
44
54
|
map "initialsSeparator", to: :initials_separator
|
|
45
55
|
end
|
|
@@ -16,6 +16,8 @@ module Relaton
|
|
|
16
16
|
attribute :series, :string, default: ""
|
|
17
17
|
attribute :uri, :string, default: ""
|
|
18
18
|
attribute :creators, :string, default: ""
|
|
19
|
+
attribute :uri_short, :string, default: ""
|
|
20
|
+
attribute :date_form, :string, default: ""
|
|
19
21
|
|
|
20
22
|
key_value do
|
|
21
23
|
map "titleOpen", to: :title_open
|
|
@@ -26,6 +28,8 @@ module Relaton
|
|
|
26
28
|
map "series", to: :series
|
|
27
29
|
map "uri", to: :uri
|
|
28
30
|
map "creators", to: :creators
|
|
31
|
+
map "uriShort", to: :uri_short
|
|
32
|
+
map "dateForm", to: :date_form
|
|
29
33
|
end
|
|
30
34
|
end
|
|
31
35
|
end
|
|
@@ -13,6 +13,9 @@ module Relaton
|
|
|
13
13
|
attribute :title, :string
|
|
14
14
|
attribute :home, :boolean
|
|
15
15
|
attribute :fallbacks, :hash, default: -> { {} }
|
|
16
|
+
# The short-cite template for this kind; absent falls back to
|
|
17
|
+
# the reference template in short mode
|
|
18
|
+
attribute :short, :string
|
|
16
19
|
# Render the style's no_place label when the publisher has no
|
|
17
20
|
# place (the book-family templates of some flavors)
|
|
18
21
|
attribute :no_place, :boolean
|
|
@@ -24,6 +27,7 @@ module Relaton
|
|
|
24
27
|
map "title", to: :title
|
|
25
28
|
map "home", to: :home
|
|
26
29
|
map "fallbacks", to: :fallbacks
|
|
30
|
+
map "short", to: :short
|
|
27
31
|
map "noPlace", to: :no_place
|
|
28
32
|
end
|
|
29
33
|
end
|
|
@@ -22,6 +22,34 @@ module Relaton
|
|
|
22
22
|
scan(source.to_s)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
# The short cite renders the reference with the first-biblio
|
|
26
|
+
# marker appended to its first component: isodoc's styled
|
|
27
|
+
# references (eref2linkshort) split there (the 1.x
|
|
28
|
+
# fmt-first-biblio-delim)
|
|
29
|
+
def evaluate_short(fields, delim)
|
|
30
|
+
rendered = @slots.filter_map do |(name, head, tail)|
|
|
31
|
+
field = fields[normalise(name)] or next
|
|
32
|
+
next unless field.present?
|
|
33
|
+
|
|
34
|
+
[head, field.text, tail]
|
|
35
|
+
end
|
|
36
|
+
return "" if rendered.empty?
|
|
37
|
+
|
|
38
|
+
parts = rendered.each_with_index.map do |(head, text, tail), i|
|
|
39
|
+
if i.zero?
|
|
40
|
+
# the split marker precedes the component's trailing
|
|
41
|
+
# punctuation (1.x ret[0] += delim, then join), with the
|
|
42
|
+
# join's separating space
|
|
43
|
+
"#{head}#{text}#{delim} #{tail}"
|
|
44
|
+
elsif i == rendered.size - 1
|
|
45
|
+
"#{head}#{text}"
|
|
46
|
+
else
|
|
47
|
+
"#{head}#{text}#{tail}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
terminate(parts.join).rstrip
|
|
51
|
+
end
|
|
52
|
+
|
|
25
53
|
def evaluate(fields)
|
|
26
54
|
rendered = @slots.filter_map do |(name, head, tail)|
|
|
27
55
|
field = fields[normalise(name)] or next
|
|
@@ -57,9 +85,11 @@ module Relaton
|
|
|
57
85
|
end
|
|
58
86
|
|
|
59
87
|
def terminate(body)
|
|
60
|
-
#
|
|
61
|
-
#
|
|
88
|
+
# 1.x punctuation cleanup: an element ending in a colon
|
|
89
|
+
# carries its own separator (the following sentence period
|
|
90
|
+
# collapses), and spaces collapse before a comma
|
|
62
91
|
body = body.gsub(/:\s*\.\s*/, ": ")
|
|
92
|
+
body = body.gsub(/ +/, " ").gsub(" ,", ",")
|
|
63
93
|
return body if @terminator.strip.empty?
|
|
64
94
|
return body if body.rstrip.end_with?(@terminator.strip)
|
|
65
95
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-render
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.0.pre.alpha.
|
|
4
|
+
version: 3.0.0.pre.alpha.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -121,6 +121,7 @@ files:
|
|
|
121
121
|
- lib/relaton/render/iso690/element.rb
|
|
122
122
|
- lib/relaton/render/iso690/elements.rb
|
|
123
123
|
- lib/relaton/render/iso690/elements/access.rb
|
|
124
|
+
- lib/relaton/render/iso690/elements/citeid.rb
|
|
124
125
|
- lib/relaton/render/iso690/elements/component_part.rb
|
|
125
126
|
- lib/relaton/render/iso690/elements/creator.rb
|
|
126
127
|
- lib/relaton/render/iso690/elements/edition.rb
|
|
@@ -133,6 +134,7 @@ files:
|
|
|
133
134
|
- lib/relaton/render/iso690/elements/pub_date.rb
|
|
134
135
|
- lib/relaton/render/iso690/elements/series.rb
|
|
135
136
|
- lib/relaton/render/iso690/elements/size.rb
|
|
137
|
+
- lib/relaton/render/iso690/elements/status.rb
|
|
136
138
|
- lib/relaton/render/iso690/elements/stddoc.rb
|
|
137
139
|
- lib/relaton/render/iso690/elements/title.rb
|
|
138
140
|
- lib/relaton/render/iso690/fields.rb
|