relaton-doi 2.1.2 → 2.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a94f21c895d9262dbe8ac4ff23fdf39d90222ae4870932f467f8b29cf71f905
4
- data.tar.gz: d927cd65ed6552b679b85625433c8afc6a41d9d5adda9dec8f03cfa03647fe3e
3
+ metadata.gz: 1f985958ac631dbcb90d8d435d4cd8d771ef1eb661096bd62d0aa05ea0739291
4
+ data.tar.gz: f0e7a7392db7ff8e082682c92afa15eabdad7230d35cb96335068f5ddaebd14f
5
5
  SHA512:
6
- metadata.gz: 9b9ab1daeaa246358597b904ebdd6b606b0fd31caef80d7de01b76d07c1eb75451637df51424279771b97e67577c28f2109a43bfc6beb2cb2a0007371e02630a
7
- data.tar.gz: b65e7cfdd691f5278a92da2a8b010d8f0bba91b0653733d1fb07665f2527a2f5f2905f58b3450a0db47ea61ebd256b158ea8760431ef8051eadb677f6c662a53
6
+ metadata.gz: e1474c8687f0772f77aa5a29cd5394722c12700a041bdb70cfab7fd2f84cb36d16f4cee676de366d262a2344075197b2fd6b18ea615c373495fc83f94756591d
7
+ data.tar.gz: fd1d94c456aed217671bd968d60815f5e06ed5d87bad05efd950f04fe43e6e1a46cbb1c8f8c28f8a57f90520894c384de29a29da7fd1a051533342ea5eac6fb8
data/CLAUDE.md CHANGED
@@ -43,3 +43,19 @@ Key classes in `lib/relaton/doi/`:
43
43
  - `TYPES` — maps 23 Crossref document types to Relaton types (e.g., `"book-chapter"` → `"inbook"`)
44
44
  - `REALATION_TYPES` — maps 37 Crossref relation types to Relaton relation types
45
45
  - `COUNTRIES` — `%w[USA]`, used by `parse_place` to distinguish country vs region
46
+
47
+ ## Crossref Markup Handling
48
+
49
+ `Parser#normalize_markup` decodes the HTML entities of raw Crossref content. Crossref
50
+ sometimes returns the JATS markup entity-encoded, and the relaton-bib sanitizer detects a
51
+ tag by a real `<`, so it would treat the encoded form as plain text.
52
+
53
+ `Bib::Title` and `Bib::Abstract` are `LocalizedMarkedUpString` subclasses, so their
54
+ `content=` setter runs `Relaton::Bib::Sanitizer` on assignment. Since relaton-bib 2.1.9 that
55
+ sanitizer also removes the `jats:` and `xlink:` namespace prefixes. Relaton never declares
56
+ those prefixes, so leaving them in place made the output fail every namespace-aware parser
57
+ downstream, including relaton-render (metanorma-pdfa#99). relaton-doi carried its own prefix
58
+ stripping until 2.1.9 shipped that fix, which is why the gemspec pins `~> 2.1.9`.
59
+
60
+ The sanitizer removes only the prefixes it could not resolve. A namespace that the content
61
+ declares itself survives, such as the MathML `xmlns` inside a `<stem>`.
@@ -209,10 +209,29 @@ module Relaton
209
209
  # @return [Bib::Title] The title.
210
210
  #
211
211
  def create_title(title, type = "main")
212
- cnt = str_cleanup CGI.unescapeHTML(title)
212
+ cnt = str_cleanup normalize_markup(title)
213
213
  Bib::Title.new type: type, content: cnt, script: "Latn"
214
214
  end
215
215
 
216
+ #
217
+ # Decode the HTML entities of raw Crossref content.
218
+ #
219
+ # Crossref sometimes returns the JATS markup as HTML entities. The
220
+ # relaton-bib sanitizer detects a tag by a real `<`, so it treats the
221
+ # encoded form as plain text and leaves it alone. Decode the entities
222
+ # here, and the sanitizer maps the markup to the basicdoc set.
223
+ #
224
+ # The sanitizer removes the `jats:` and `xlink:` namespace prefixes
225
+ # itself since relaton-bib 2.1.9, so this method no longer does.
226
+ #
227
+ # @param [String] str The raw Crossref content.
228
+ #
229
+ # @return [String] The content without HTML entities.
230
+ #
231
+ def normalize_markup(str)
232
+ CGI.unescapeHTML(str)
233
+ end
234
+
216
235
  #
217
236
  # Parse a docidentifier from the source hash.
218
237
  #
@@ -303,9 +322,10 @@ module Relaton
303
322
  def parse_abstract
304
323
  return [] unless @src["abstract"]
305
324
 
306
- content = @src["abstract"]
307
325
  abstract = Bib::Abstract.new(
308
- content: content, language: "en", script: "Latn",
326
+ content: normalize_markup(@src["abstract"]),
327
+ language: "en",
328
+ script: "Latn",
309
329
  )
310
330
  [abstract]
311
331
  end
@@ -448,8 +468,10 @@ module Relaton
448
468
  # @return [Bib::Organization] The organization.
449
469
  #
450
470
  def create_org(name, abbreviation = nil)
451
- n = [Bib::TypedLocalizedString.new(content: name)]
452
- a = abbreviation ? Bib::LocalizedString.new(content: abbreviation) : nil
471
+ n = [Bib::TypedLocalizedString.new(content: CGI.unescapeHTML(name))]
472
+ a = if abbreviation
473
+ Bib::LocalizedString.new(content: CGI.unescapeHTML(abbreviation))
474
+ end
453
475
  Bib::Organization.new name: n, abbreviation: a
454
476
  end
455
477
 
@@ -462,11 +484,7 @@ module Relaton
462
484
  return [] unless @src["standards-body"]
463
485
 
464
486
  name, acronym = @src["standards-body"].values_at("name", "acronym")
465
- org = create_org(
466
- CGI.unescapeHTML(name),
467
- acronym && CGI.unescapeHTML(acronym),
468
- )
469
- [contributor(org, "authorizer")]
487
+ [contributor(create_org(name, acronym), "authorizer")]
470
488
  end
471
489
 
472
490
  #
@@ -728,7 +746,8 @@ module Relaton
728
746
 
729
747
  @src["container-title"].map do |ct|
730
748
  contrib = create_authors_editors false, "editor"
731
- bib = Bib::ItemBase.new(title: [Bib::Title.new(content: ct)], contributor: contrib)
749
+ title = Bib::Title.new content: normalize_markup(ct)
750
+ bib = Bib::ItemBase.new(title: [title], contributor: contrib)
732
751
  Bib::Relation.new(type: "includedIn", bibitem: bib)
733
752
  end
734
753
  end
@@ -777,7 +796,7 @@ module Relaton
777
796
  else []
778
797
  end
779
798
  con_ttl.map do |ct|
780
- title = Bib::Title.new content: ct
799
+ title = Bib::Title.new content: normalize_markup(ct)
781
800
  Bib::Series.new title: [title], abbreviation: abbrev
782
801
  end
783
802
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Doi
5
- VERSION = "2.1.2"
5
+ VERSION = "2.1.4"
6
6
  end
7
7
  end
data/relaton-doi.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  # Uncomment to register a new dependency of your gem
35
35
  # spec.add_dependency "example-gem", "~> 1.0"
36
36
 
37
- spec.add_dependency "relaton-bib", "~> 2.1.3"
37
+ spec.add_dependency "relaton-bib", "~> 2.1.9"
38
38
  spec.add_dependency "relaton-bipm", "~> 2.1.0"
39
39
  spec.add_dependency "relaton-ieee", "~> 2.1.0"
40
40
  spec.add_dependency "relaton-ietf", "~> 2.1.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-doi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-21 00:00:00.000000000 Z
11
+ date: 2026-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-bib
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.3
19
+ version: 2.1.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.1.3
26
+ version: 2.1.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: relaton-bipm
29
29
  requirement: !ruby/object:Gem::Requirement