metanorma-document 0.5.16 → 0.5.17

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: 197da2368a2c9e538934835694a190d0746357a6a65d04a6675f1ed00d544100
4
- data.tar.gz: a17400f1d394f94da92140aece6cc0867b4335958d8db412e0fbc27a8509c65c
3
+ metadata.gz: 16dcef40346ee95c83a097ad861e0dd3acf209988f546c3ee810bfb8c38cf551
4
+ data.tar.gz: c0ebe20d588efeb96eddd6cf2b5ff7f9e6dc6d4d583eb8d85dfeb44ad4b14825
5
5
  SHA512:
6
- metadata.gz: 6b0bedc8c660856b77ba32e85bdc56f44338f59653474f02f1366f094a1283c56f7e591c76f2dfec85e664abf3edb702913e421a39648378739cc0d013656610
7
- data.tar.gz: 011f88791a600e4fd29858cb2a8b5acca2cc889476758686d5401fc7d7cf0a4f8efb3042718fef681121d7299fc09206e45985261f9448e7b1771bb776c36c18
6
+ metadata.gz: dbf4df040c12ba774107adf56655de45285bb0c535c48e97fbdd639a3e1828f824dca1265ed0b08f26b9fb80c202620aa8510389f36c18153b3967d1f0308c85
7
+ data.tar.gz: ba6374cf5ab17904eb8abdcf363de6d680ed16438b18d11c32b01503ccd922f36c343a409c2637d935841163d167d3e116f506e8f40afe915e0957cd022dd3a9
@@ -472,7 +472,7 @@ module Metanorma
472
472
  def build_fn_paragraph_text(mn_p, fn_element, first:)
473
473
  text = RenderedTextExtractor.text_of(mn_p)
474
474
  label = fn_element.reference if fn_element.is_a?(Metanorma::Document::Components::Inline::FnElement)
475
- text = "#{label})#{text}" if first && label && !label.to_s.empty? && !text.empty?
475
+ text = "#{label}) #{text}" if first && label && !label.to_s.empty? && !text.empty?
476
476
  ::Sts::NisoSts::Paragraph.new(text: [text])
477
477
  end
478
478
 
@@ -624,12 +624,19 @@ module Metanorma
624
624
  explicit = text_of(node)
625
625
  return explicit unless explicit.empty?
626
626
 
627
- raw = node.target.to_s
628
- case raw
629
- when /\Asec-(.+)\z/, /\Afig-(.+)\z/, /\Atable-(.+)\z/, /\Afn-(.+)\z/
627
+ # Prefer the remapped engine id: it carries the kind prefix
628
+ # (sec_A, fig_2, tab1, annB). Bare consumer anchors (_tab1)
629
+ # pass through unchanged by the registry, so strip their
630
+ # underscore markers and decompose the same way instead of
631
+ # leaking the raw id as visible text.
632
+ raw = rid.to_s.empty? ? node.target.to_s : rid.to_s
633
+ stripped = raw.sub(/\A_+/, "")
634
+ case stripped
635
+ when /\Asec[-_](.+)\z/, /\Afig[-_](.+)\z/, /\Atable[-_](.+)\z/, /\Afn[-_](.+)\z/,
636
+ /\Aann([A-Z]|\d+)\z/, /\Afig(\d+)\z/, /\Atab(\d+)\z/, /\Aformula(\d+)\z/
630
637
  "#{Regexp.last_match(1)} "
631
638
  else
632
- explicit.empty? ? rid : explicit
639
+ explicit.empty? ? stripped : explicit
633
640
  end
634
641
  end
635
642
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Metanorma
4
4
  module Document
5
- VERSION = "0.5.16"
5
+ VERSION = "0.5.17"
6
6
  Version = VERSION
7
7
  end
8
8
  end
@@ -35,24 +35,31 @@ module RoundtripSamples
35
35
 
36
36
  HTTP_TIMEOUT = 30
37
37
 
38
- # Maps mn-samples-* repo name to the model class name for
39
- # round-tripping. Resolved lazily: the flavor trees moved to their
40
- # gems (Phase 5), and this task must not require every flavor gem at
41
- # load time — missing constants resolve to nil ("no_model").
38
+ # Maps mn-samples-* repo name to [gem to require, model class] for
39
+ # round-tripping. The gem require happens at resolution time, not load
40
+ # time: a missing gem (or missing model) resolves to nil ("no_model").
42
41
  # OIML moved to the metanorma-oiml gem — its roundtrip lives there.
42
+ # flavor => [gem to require, document model class]. The gem require is
43
+ # needed because the rake process loads only metanorma-document: without
44
+ # it the model constant resolves to nil and every file reports no_model.
43
45
  FLAVOR_MODEL_MAP = {
44
- "iso" => "Metanorma::Iso::Document::Root",
45
- "iec" => "Metanorma::Iec::Document::Root",
46
- "ieee" => "Metanorma::Ieee::Document::Root",
47
- "iho" => "Metanorma::Iho::Document::Root",
48
- "cc" => "Metanorma::Cc::Document::Root",
49
- "bipm" => "Metanorma::Bipm::Document::Root",
50
- "itu" => "Metanorma::Itu::Document::Root",
51
- "ogc" => "Metanorma::Ogc::Document::Root",
52
- "ribose" => "Metanorma::Ribose::Document::Root",
53
- "ietf" => "Metanorma::Ietf::Document::Root",
54
- "csa" => "Metanorma::Csa::Document::Root",
55
- "un" => nil,
46
+ "iso" => ["metanorma-iso", "Metanorma::Iso::Document::Root"],
47
+ "iec" => ["metanorma-iec", "Metanorma::Iec::Document::Root"],
48
+ "ieee" => ["metanorma-ieee", "Metanorma::Ieee::Document::Root"],
49
+ "iho" => ["metanorma-iho", "Metanorma::Iho::Document::Root"],
50
+ "cc" => ["metanorma-cc", "Metanorma::Cc::Document::Root"],
51
+ "bipm" => ["metanorma-bipm", "Metanorma::Bipm::Document::Root"],
52
+ "itu" => ["metanorma-itu", "Metanorma::Itu::Document::Root"],
53
+ "ogc" => ["metanorma-ogc", "Metanorma::Ogc::Document::Root"],
54
+ "ribose" => ["metanorma-ribose", "Metanorma::Ribose::Document::Root"],
55
+ "ietf" => ["metanorma-ietf", "Metanorma::Ietf::Document::Root"],
56
+ "csa" => ["metanorma-csa", "Metanorma::Csa::Document::Root"],
57
+ # standoc is the base flavor and iala/un are tastes on the base: they
58
+ # consume the root Document model from this gem directly — no
59
+ # per-flavor model exists or is needed.
60
+ "iala" => [nil, "Metanorma::Document::Root"],
61
+ "standoc" => [nil, "Metanorma::Document::Root"],
62
+ "un" => [nil, "Metanorma::Document::Root"],
56
63
  }.freeze
57
64
 
58
65
  module_function
@@ -61,8 +68,14 @@ module RoundtripSamples
61
68
  # Flavor gems load on demand; a missing gem resolves to nil
62
69
  # ("no_model"), never a load-time NameError.
63
70
  def resolve_flavor_model(repo_name)
64
- name = FLAVOR_MODEL_MAP[repo_name]
65
- name && safe_const(name)
71
+ entry = FLAVOR_MODEL_MAP[repo_name]
72
+ return unless entry
73
+
74
+ gem_require, const_name = entry
75
+ require gem_require if gem_require
76
+ safe_const(const_name)
77
+ rescue LoadError
78
+ nil
66
79
  end
67
80
 
68
81
  def safe_const(name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-document
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.16
4
+ version: 0.5.17
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-11-27 00:00:00.000000000 Z
11
+ date: 2026-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64