From df4dcb657bbbd16e22f1a88729c0de8cbe00ac19 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 28 Feb 2024 21:11:42 +1100 Subject: [PATCH 1/2] Hide references with hidden bibitems even if they also have a title: https://github.com/metanorma/metanorma-standoc/issues/709 --- lib/isodoc/presentation_function/math.rb | 10 +++++----- lib/isodoc/presentation_function/refs.rb | 4 +++- spec/isodoc/ref_spec.rb | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/isodoc/presentation_function/math.rb b/lib/isodoc/presentation_function/math.rb index 34c9c84f..cbd0ef71 100644 --- a/lib/isodoc/presentation_function/math.rb +++ b/lib/isodoc/presentation_function/math.rb @@ -79,12 +79,12 @@ def twitter_cldr_localiser def parse_localize_number @localizenumber or return {} - m = %r{(?[^#])?(?#+0)(?.)(?#+)(?[^#])?} + m = %r{(?[^#])?(?#+0)(?.)(?#+)(?[^#])?} .match(@localizenumber) or return {} - ret = { decimal: m[:decimal], group_digits: m[:groupdigits].size, - fraction_group_digits: m[:fractdigits].size, - group: m[:group] || "", - fraction_group: m[:fractgroup] || "" }.compact + ret = { decimal: m[:decpt], group_digits: m[:grpdig].size, + fraction_group_digits: m[:frdig].size, + group: m[:grp] || "", + fraction_group: m[:frgrp] || "" }.compact %i(group fraction_group).each { |x| ret[x] == " " and ret[x] = "\u00A0" } ret end diff --git a/lib/isodoc/presentation_function/refs.rb b/lib/isodoc/presentation_function/refs.rb index 58dafdd1..046a0198 100644 --- a/lib/isodoc/presentation_function/refs.rb +++ b/lib/isodoc/presentation_function/refs.rb @@ -25,7 +25,9 @@ def move_norm_ref_to_sections(docxml) def hidden_items(docxml) docxml.xpath(ns("//references[bibitem/@hidden = 'true']")).each do |x| x.at(ns("./bibitem[not(@hidden = 'true')]")) and next - x.elements.map(&:name).any? { |n| n != "bibitem" } and next + x.elements.map(&:name).any? do |n| + !%w(title bibitem).include?(n) + end and next x["hidden"] = "true" end end diff --git a/spec/isodoc/ref_spec.rb b/spec/isodoc/ref_spec.rb index 791a9a94..ad5926d4 100644 --- a/spec/isodoc/ref_spec.rb +++ b/spec/isodoc/ref_spec.rb @@ -511,6 +511,7 @@ + Title