module IsoDoc module NIST module BaseConvert def keywords(docxml, out) f = docxml.at(ns("//preface/clause[@type = 'keyword']")) || return preface1(f, f&.at(ns("./title")), false, out) end def skip_render(c, isoxml) return false unless c.name == "reviewernote" status = isoxml&.at(ns("//bibdata/status/stage"))&.text return true if status.nil? /^final/.match status end def abstract(isoxml, out) f = isoxml.at(ns("//preface/abstract")) || return out.div **attr_code(id: f["id"]) do |s| clause_name(nil, f.at(ns("./title")) || @i18n.abstract, s, class: "AbstractTitle") f.elements.each { |e| parse(e, s) unless e.name == "title" } end end FRONT_CLAUSE = "//*[parent::preface][not(local-name() = 'abstract' or "\ "local-name() = 'foreword' or @type = 'keyword')]".freeze # All "[preface]" sections should have class "IntroTitle" to prevent # page breaks, but for the Exec Summary def preface(isoxml, out) isoxml.xpath(ns(FRONT_CLAUSE)).each do |c| next if skip_render(c, isoxml) || !is_clause?(c.name) title = c&.at(ns("./title")) patent = ["Call for Patent Claims", "Patent Disclosure Notice"].include? title&.text preface1(c, title, patent, out) end end def preface1(c, title, patent, out) out.div **attr_code(id: c["id"]) do |s| page_break(s) if patent clause_name(nil, title, s, class: (c.name == "executivesummary") ? "NormalTitle" : "IntroTitle") c.elements.reject { |c1| c1.name == "title" }.each do |c1| parse(c1, s) end end end def foreword(isoxml, out) f = isoxml.at(ns("//foreword")) || return out.div **attr_code(id: f["id"]) do |s| title = f.at(ns("./title")) s.h1(**{ class: "ForewordTitle" }) do |h1| title and title.children.each { |e| parse(e, h1) } end f.elements.each { |e| parse(e, s) unless e.name == "title" } end end def is_clause?(name) return true if %w(reviewernote executivesummary).include? name super end end end end