Sha256: 382036ac4cd499c878b15119a1174875193a2bd37803481d06063644c8d846f0

Contents?: true

Size: 1.61 KB

Versions: 10

Compression:

Stored size: 1.61 KB

Contents

module IsoDoc
  module NIST
    module BaseConvert
      NIST_PUBLISHER_XPATH =
        "./contributor[xmlns:role/@type = 'publisher']/"\
        "organization[abbreviation = 'NIST' or xmlns:name = 'NIST']".freeze

      # we are taking the ref number/code out as prefix to reference
      def nonstd_bibitem(list, b, ordinal, bibliography)
        list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
          if !b.at(ns("./formattedref"))
            nist_reference_format(b, r)
          else
            reference_format(b, r)
          end
        end
      end

      def std_bibitem_entry(list, b, ordinal, biblio)
        nonstd_bibitem(list, b, ordinal, biblio)
      end

      def reference_format(b, r)
        id = bibitem_ref_code(b)
        code = render_identifier(id)
        if id["type"] == "metanorma"
          r << "[#{code}] "
          insert_tab(r, 1)
        end
        reference_format1(b, r)
        r << " [#{code}] " unless id["type"] == "metanorma"
      end

      def reference_format1(b, r)
        if ftitle = b.at(ns("./formattedref"))
          ftitle&.children&.each { |n| parse(n, r) }
        else
          title = b.at(ns("./title[@language = '#{@language}']")) || b.at(ns("./title"))
          r.i do |i|
            title&.children&.each { |n| parse(n, i) }
          end
        end
      end

      def omit_docid_prefix(prefix)
        return true if prefix.nil? || prefix.empty?
        super || prefix == "NIST"
      end

      def nist_reference_format(b, r)
        bibitem = b.dup.to_xml
        r.parent.add_child ::Iso690Render.render(bibitem, true)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
metanorma-nist-1.0.7 lib/isodoc/nist/refs.rb
metanorma-nist-1.0.6 lib/isodoc/nist/refs.rb
metanorma-nist-1.0.5 lib/isodoc/nist/refs.rb
metanorma-nist-1.0.4 lib/isodoc/nist/refs.rb
metanorma-nist-1.0.3 lib/isodoc/nist/refs.rb
metanorma-nist-1.0.2 lib/isodoc/nist/refs.rb
metanorma-nist-1.0.1 lib/isodoc/nist/refs.rb
metanorma-nist-1.0.0 lib/isodoc/nist/refs.rb
metanorma-nist-0.2.14 lib/isodoc/nist/refs.rb
metanorma-nist-0.2.13 lib/isodoc/nist/refs.rb