lib/metanorma/util.rb in metanorma-1.7.4 vs lib/metanorma/util.rb in metanorma-1.7.5

- old
+ new

@@ -72,9 +72,27 @@ /_#{suffix}$/.match?(a) or elem.attributes[attr_name].value = "#{a}_#{suffix}" end end + def self.hash_key_detect(directives, key, variable) + c = directives.detect { |x| x.is_a?(Hash) && x.has_key?(key) } or + return variable + c[key] + end + + def self.rel_path_resolve(dir, path) + path.nil? and return path + path.empty? and return path + p = Pathname.new(path) + p.absolute? ? path : File.join(dir, path) + end + + def self.key(ident) + @c ||= HTMLEntities.new + @c.decode(ident).gsub(/(\p{Zs})+/, " ") + end + class DisambigFiles def initialize @seen_filenames = [] end