Skip to content

Commit

Permalink
Presentation XML caption refactor: metanorma/isodoc#617
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Nov 28, 2024
1 parent f6bdef3 commit 7159cde
Show file tree
Hide file tree
Showing 7 changed files with 580 additions and 279 deletions.
5 changes: 5 additions & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "feature/presxml-autonum"
gem "metanorma-generic", git: "https://github.com/metanorma/metanorma-generic", branch: "feature/presxml-autonum"
gem "isodoc-i18n", git: "https://github.com/metanorma/isodoc-i18n", branch: "fix/markup-connectives"
gem "mn-requirements", git: "https://github.com/metanorma/mn-requirements", branch: "feature/presxml-autonum"

8 changes: 6 additions & 2 deletions lib/isodoc/ribose/base_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ def executivesummary(clause, out)
title_attr = { class: "IntroTitle" }
page_break(out)
out.div class: "Section3", id: clause["id"] do |div|
clause_name(clause, clause&.at(ns("./title")), div, title_attr)
clause_name(clause, clause&.at(ns("./fmt-title")), div, title_attr)
clause.elements.each do |e|
parse(e, div) unless e.name == "title"
parse(e, div) unless e.name == "fmt-title"
end
end
end

def sections_names
super << "executivesummary"
end

def is_clause?(name)
return true if name == "executivesummary"

Expand Down
14 changes: 11 additions & 3 deletions lib/isodoc/ribose/presentation_xml_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
module IsoDoc
module Ribose
class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
def annex1(elem)
# KILL
def annex1x(elem)
lbl = @xrefs.anchor(elem["id"], :label)
prefix_name(elem, "<br/><br/>", lbl, "title")
end

def annex_delim(_elem)
"<br/><br/>"
end

def middle_title(docxml); end

def termsource1(elem)
mod = elem.at(ns("./modification")) and
termsource_modification(mod)
elem.children = l10n("<strong>#{@i18n.source}:</strong> " \
"#{to_xml(elem.children).strip}")
elem&.next_element&.name == "termsource" and elem.next = "; "
Expand All @@ -33,6 +36,11 @@ def preface_rearrange(doc)
%w(), doc)
end

def clause(docxml)
super
docxml.xpath(ns("//executivesummary | //appendix")).each { |x| clause1(x) }
end

include Init
end
end
Expand Down
37 changes: 34 additions & 3 deletions lib/isodoc/ribose/xref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class Counter < IsoDoc::XrefGen::Counter
end

class Xref < IsoDoc::Generic::Xref
def annex_name_lbl(clause, num)
# KILL
def annex_name_lblx(clause, num)
obl = l10n("(#{@labels['inform_annex']})")
clause["obligation"] == "normative" and
obl = l10n("(#{@labels['norm_annex']})")
Expand All @@ -28,7 +29,8 @@ def initial_anchor_names(doc)
end
end

def section_names1(clause, num, level)
# KILL
def section_names1x(clause, num, level)
@anchors[clause["id"]] =
{ label: num, level: level, xref: num }
# subclauses are not prefixed with "Clause"
Expand All @@ -39,8 +41,25 @@ def section_names1(clause, num, level)
end
end

# subclauses are not prefixed with "Clause"
# retaining subtype for the semantics
def section_name_anchors(clause, num, level)
if clause["type"] == "section"
xref = labelled_autonum(@labels["section"], num)
label = labelled_autonum(@labels["section"], num)
@anchors[clause["id"]] =
{ label:, xref:, elem: @labels["section"],
title: clause_title(clause), level: level, type: "clause" }
elsif level > 1
#num = semx(clause, num)
@anchors[clause["id"]] =
{ label: num, level: level, xref: num, subtype: "clause" }
else super end
end

# we can reference 0-number clauses in introduction
def introduction_names(clause)
# # KILL
def introduction_namesx(clause)
clause.nil? and return
clause.at(ns("./clause")) and
@anchors[clause["id"]] = { label: "0", level: 1, type: "clause",
Expand All @@ -49,6 +68,18 @@ def introduction_names(clause)
clause.xpath(ns("./clause")).each do |c|
section_names1(c, i.increment(c).print, 2)
end
end
# we can reference 0-number clauses in introduction
def introduction_names(clause)
clause.nil? and return
clause.at(ns("./clause")) and
@anchors[clause["id"]] = { label: nil, level: 1, type: "clause",
xref: clause.at(ns("./title"))&.text }
#i = Counter.new(0, prefix: "0")
i = Counter.new(0)
clause.xpath(ns("./clause")).each do |c|
section_names1(c, semx(clause, "0"), i.increment(c).print, 2)
end
end
end
end
Expand Down
Loading

0 comments on commit 7159cde

Please sign in to comment.