lib/asciidoctor/iso/front.rb in metanorma-iso-1.1.5 vs lib/asciidoctor/iso/front.rb in metanorma-iso-1.2.0
- old
+ new
@@ -21,11 +21,21 @@
return unless node.attr("docnumber")
part, subpart = node&.attr("partnumber")&.split(/-/)
dn = add_id_parts(node.attr("docnumber"), part, subpart)
dn = id_stage_prefix(dn, node)
xml.docidentifier dn, **attr_code(type: "iso")
- xml.docidentifier **attr_code(type: "iso-structured") do |i|
+ end
+
+ def metadata_ext(node, xml)
+ super
+ structured_id(node, xml)
+ end
+
+ def structured_id(node, xml)
+ return unless node.attr("docnumber")
+ part, subpart = node&.attr("partnumber")&.split(/-/)
+ xml.structuredidentifier do |i|
i.project_number node.attr("docnumber"),
**attr_code(part: part, subpart: subpart)
end
end
@@ -34,13 +44,15 @@
dn += "-#{subpart}" if subpart
dn
end
def id_stage_prefix(dn, node)
- if node.attr("docstage") && node.attr("docstage").to_i < 60
+ stage = get_stage(node)
+ substage = get_substage(node)
+ if stage && (stage.to_i < 60 || stage.to_i == 60 && substage.to_i < 60)
abbr = IsoDoc::Iso::Metadata.new("en", "Latn", {}).
- stage_abbrev(node.attr("docstage"), node.attr("iteration"),
+ stage_abbrev(stage, substage, node.attr("iteration"),
node.attr("draft"))
dn = "/#{abbr} #{dn}" # prefixes added in cleanup
else
dn += ":#{node.attr("copyright-year")}" if node.attr("copyright-year")
end
@@ -91,14 +103,23 @@
end
end
end
end
+ def get_stage(node)
+ stage = node.attr("status") || node.attr("docstage") || "60"
+ end
+
+ def get_substage(node)
+ stage = get_stage(node)
+ node.attr("docsubstage") || ( stage == "60" ? "60" : "00" )
+ end
+
def metadata_status(node, xml)
xml.status do |s|
- s.stage (node.attr("docstage") || "60")
- s.substage (node.attr("docsubstage") || "60")
+ s.stage get_stage(node)
+ s.substage get_substage(node)
node.attr("iteration") && (s.iteration node.attr("iteration"))
end
end
def metadata_committee(node, xml)
@@ -110,35 +131,45 @@
end
end
def title_intro(node, t, lang, at)
return unless node.attr("title-intro-#{lang}")
- t.title_intro(**attr_code(at)) do |t1|
+ t.title(**attr_code(at.merge(type: "title-intro"))) do |t1|
t1 << asciidoc_sub(node.attr("title-intro-#{lang}"))
end
end
def title_main(node, t, lang, at)
- t.title_main **attr_code(at) do |t1|
+ t.title **attr_code(at.merge(type: "title-main")) do |t1|
t1 << asciidoc_sub(node.attr("title-main-#{lang}"))
end
end
def title_part(node, t, lang, at)
return unless node.attr("title-part-#{lang}")
- t.title_part(**attr_code(at)) do |t1|
+ t.title(**attr_code(at.merge(type: "title-part"))) do |t1|
t1 << asciidoc_sub(node.attr("title-part-#{lang}"))
end
end
+ def title_full(node, t, lang, at)
+ title = node.attr("title-main-#{lang}")
+ intro = node.attr("title-intro-#{lang}")
+ part = node.attr("title-part-#{lang}")
+ title = "#{intro} -- #{title}" if intro
+ title = "#{title} -- #{part}" if part
+ t.title **attr_code(at.merge(type: "main")) do |t1|
+ t1 << asciidoc_sub(title)
+ end
+ end
+
def title(node, xml)
["en", "fr"].each do |lang|
- xml.title do |t|
- at = { language: lang, format: "text/plain" }
- title_intro(node, t, lang, at)
- title_main(node, t, lang, at)
- title_part(node, t, lang, at)
- end
+ at = { language: lang, format: "text/plain" }
+ title_full(node, xml, lang, at)
+ title_intro(node, xml, lang, at)
+ title_main(node, xml, lang, at)
+ title_part(node, xml, lang, at)
end
end
end
end
end