pubid-iso 1.15.8 → 1.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1893bea151d26da77c42fde6779f38a9bb07f4807115c567a52811ac4e9bb41a
4
- data.tar.gz: 68d31036867e076d3f597c22774e95b62662ea01709c3944b22a78d3ed2e3cb5
3
+ metadata.gz: 9f281981e42f4fe123fb11766a42a161efe7ea7ca67177217cb7b0e25abf605f
4
+ data.tar.gz: db7553520345a7860be01d909404dd208355f62bd6c3ea89debf80c259c7ca24
5
5
  SHA512:
6
- metadata.gz: 96ec944e72e01a6b9e53a429ad12fb89250801a6f49570da9d3b68facb03c51ebce36b9088eb6de9b86d4498c3ca14cff4c8819bbcd5c3ce2decf1393b0f090d
7
- data.tar.gz: b6553af3511c3de43919bc6b871dd8996200f0620c2e9fb96e73f379d72227ec6d5cb2c8cbb12e165c92e5c4fbb281df1bd9620cf8e6b9b4256cb6c8c6b2d7ed
6
+ metadata.gz: a892b598fb4be0cb9e2e59bff00f51a55138db6071db1e8d17a9bafc4acdef9afdb16cc48a8cc9be4fe2afa4f5293034e3b26ab4bdf994bc85915721ef8747ce
7
+ data.tar.gz: f434672ef4e38510f2d8af2c40104e859b7d9e9a2c885063c3555e2c3d4cf349fc89f6f1c7da42b915993c18e76f374212e20f1765a250b85a60a14fd5bf2e95
data/README.adoc CHANGED
@@ -162,6 +162,30 @@ to see all available options.
162
162
  => "ISO 8601-1:2019/DAM 1"
163
163
  ----
164
164
 
165
+ === Annotated rendering
166
+
167
+ Use `to_s(annotated: true)` to wrap each semantic component of the identifier in
168
+ an HTML `<span>` tag with a CSS class, useful for styling in web applications.
169
+
170
+ [source,ruby]
171
+ ----
172
+ > pubid = Pubid::Iso::Identifier.parse("ISO 1234-1:2013")
173
+ > pubid.to_s(annotated: true)
174
+ => '<span class="publisher">ISO</span> <span class="docnumber">1234</span>-<span class="part">1</span>:<span class="year">2013</span>'
175
+ ----
176
+
177
+ With copublisher and document type:
178
+
179
+ [source,ruby]
180
+ ----
181
+ > pubid = Pubid::Iso::Identifier.parse("ISO/IEC TR 2131-1:2013")
182
+ > pubid.to_s(annotated: true)
183
+ => '<span class="publisher">ISO/IEC</span> <span class="doctype">TR</span> <span class="docnumber">2131</span>-<span class="part">1</span>:<span class="year">2013</span>'
184
+ ----
185
+
186
+ The `annotated:` option can be combined with other `to_s` options like `format:`,
187
+ `lang:`, etc.
188
+
165
189
  === Using language specific rendering
166
190
  [source,ruby]
167
191
  ----
@@ -266,11 +266,12 @@ module Pubid::Iso
266
266
  # :ref_undated -- reference undated: no language code + short form (DAM) + undated
267
267
  # :ref_undated_long -- reference undated long: 1 letter language code + long form (DAmd) + undated
268
268
  # @return [String] pubid identifier
269
- def to_s(lang: nil, with_edition: false, with_prf: false, format: :ref_dated_long)
269
+ def to_s(lang: nil, with_edition: false, with_prf: false, format: :ref_dated_long, annotated: false)
270
270
  options = resolve_format(format)
271
271
  options[:with_edition] = with_edition
272
272
  options[:with_prf] = with_prf
273
273
  options[:language] = lang
274
+ options[:annotated] = annotated
274
275
 
275
276
  self.class.get_renderer_class.new(to_h(deep: false)).render(**options) +
276
277
  render_joint_document(@joint_document) + render_all_parts
@@ -32,10 +32,11 @@ module Pubid::Iso::Renderer
32
32
  # Render identifier
33
33
  # @param with_edition [Boolean] include edition in output
34
34
  # @see Pubid::Core::Renderer::Base for another options
35
- def render(with_edition: true, with_language_code: :iso, with_date: true, **args)
35
+ def render(with_edition: true, with_language_code: :iso, with_date: true, annotated: false, **args)
36
36
  render_base_identifier(**args.merge({ with_date: with_date,
37
37
  with_language_code: with_language_code,
38
- with_edition: with_edition })) +
38
+ with_edition: with_edition,
39
+ annotated: annotated })) +
39
40
  @prerendered_params[:language].to_s
40
41
  end
41
42
 
@@ -54,6 +55,10 @@ module Pubid::Iso::Renderer
54
55
  def render_identifier(params, opts)
55
56
  stage = params.key?(:stage) ? postrender_stage(params[:stage], opts, params) : ""
56
57
  type = render_type_prefix(params, opts)
58
+ if opts[:annotated]
59
+ stage = annotate_value(:stage, stage) if stage && !stage.to_s.empty?
60
+ type = annotate_value(:typed_stage, type) if type && !type.to_s.empty?
61
+ end
57
62
  "%<publisher>s#{stage}#{type} %<number>s%<part>s%<iteration>s%<year>s%" \
58
63
  "<amendments>s%<corrigendums>s%<addendum>s%<edition>s" % params
59
64
  end
@@ -7,11 +7,11 @@ module Pubid::Iso::Renderer
7
7
  # Render identifier
8
8
  # @param with_edition [Boolean] include edition in output
9
9
  # @see Pubid::Core::Renderer::Base for another options
10
- def render(with_edition: true, with_language_code: :iso, with_date: true, **args) # rubocop:disable Metrics/MethodLength
11
- @params[:base].to_s(lang: args[:language], with_edition: with_edition) +
10
+ def render(with_edition: true, with_language_code: :iso, with_date: true, annotated: false, **args) # rubocop:disable Metrics/MethodLength
11
+ @params[:base].to_s(lang: args[:language], with_edition: with_edition, annotated: annotated) +
12
12
  super(
13
13
  with_edition: with_edition, with_language_code: with_language_code, with_date: with_date,
14
- base_type: @params[:base].type[:key],
14
+ annotated: annotated, base_type: @params[:base].type[:key],
15
15
  **args
16
16
  ) +
17
17
  if !@params[:language] && @params[:base].language
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Iso
3
- VERSION = "1.15.8".freeze
3
+ VERSION = "1.15.9".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.8
4
+ version: 1.15.9
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-03-19 00:00:00.000000000 Z
11
+ date: 2026-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.15.8
33
+ version: 1.15.9
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 1.15.8
40
+ version: 1.15.9
41
41
  description: Library to generate, parse and manipulate ISO PubID.
42
42
  email:
43
43
  - open.source@ribose.com