lib/asciidoctor/iso/front.rb in asciidoctor-iso-0.0.1 vs lib/asciidoctor/iso/front.rb in asciidoctor-iso-0.6.0

- old
+ new

@@ -9,33 +9,28 @@ module Asciidoctor module ISO module Front def metadata_id(node, xml) xml.id do |i| - i.documentnumber node.attr("docnumber"), - **attr_code(partnumber: node.attr("partnumber")) + i.project_number node.attr("docnumber"), + **attr_code(part: node.attr("partnumber")) if node.attr("tc-docnumber") - i.tc_documentnumber node.attr("tc-docnumber") + i.tc_document_number node.attr("tc-docnumber") end - if node.attr("ref-docnumber") - i.ref_documentnumber node.attr("ref-docnumber") - end end end def metadata_version(node, xml) xml.version do |v| v.edition node.attr("edition") if node.attr("edition") - v.revdate node.attr("revdate") if node.attr("revdate") - if node.attr("copyright-year") - v.copyright_year node.attr("copyright-year") - end + v.revision_date node.attr("revdate") if node.attr("revdate") + v.draft node.attr("draft") if node.attr("draft") end end def metadata_author(node, xml) - xml.author do |a| + xml.creator **{ role: "author" } do |a| a.technical_committee node.attr("technical-committee"), **attr_code(number: node.attr("technical-committee-number")) if node.attr("subcommittee") a.subcommittee node.attr("subcommittee"), **attr_code(number: node.attr("subcommittee-number")) @@ -46,32 +41,46 @@ end a.secretariat node.attr("secretariat") if node.attr("secretariat") end end - def metadata(node, xml) - xml.documenttype node.attr("doctype") - xml.documentstatus do |s| - s.stage node.attr("docstage") - s.substage node.attr("docsubstage") if node.attr("docsubstage") + def metadata_copyright(node, xml) + from = node.attr("copyright-year") || Date.today.year + xml.copyright do |c| + c.from from + c.owner do |o| + o.affiliation "ISO" + end end - metadata_id(node, xml) + end + + def metadata_status(node, xml) + xml.status do |s| + s.stage ( node.attr("docstage") || "60" ) + s.substage ( node.attr("docsubstage") || "60" ) + end + end + + def metadata(node, xml) + metadata_status(node, xml) + metadata_author(node, xml) xml.language node.attr("language") + xml.script "latn" + xml.type node.attr("doctype") + metadata_id(node, xml) metadata_version(node, xml) - metadata_author(node, xml) + metadata_copyright(node, xml) end def title(node, xml) - xml.title do |t0| - ["en", "fr"].each do |lang| - t0.send lang do |t| - if node.attr("title-intro-#{lang}") - t.title_intro { |t1| t1 << node.attr("title-intro-#{lang}") } - end - t.title_main { |t1| t1 << node.attr("title-main-#{lang}") } - if node.attr("title-part-#{lang}") - t.title_part node.attr("title-part-#{lang}") - end + ["en", "fr"].each do |lang| + xml.title **{ language: lang } do |t| + if node.attr("title-intro-#{lang}") + t.title_intro { |t1| t1 << node.attr("title-intro-#{lang}") } + end + t.title_main { |t1| t1 << node.attr("title-main-#{lang}") } + if node.attr("title-part-#{lang}") + t.title_part node.attr("title-part-#{lang}") end end end end end