Skip to content

Commit

Permalink
metanorma/isodoc#630: Presentation XML refactor, terms
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Jan 5, 2025
1 parent c32eb37 commit 2b6b98c
Show file tree
Hide file tree
Showing 8 changed files with 531 additions and 391 deletions.
3 changes: 3 additions & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "feature/presentation-terms"
gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc", branch: "fix/remove-asciimath2unitsml"
gem "mn-requirements", git: "https://github.com/metanorma/mn-requirements", branch: "main"
18 changes: 13 additions & 5 deletions lib/isodoc/itu/presentation_xml_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,22 @@ def bracket_opt(text)
def designation1(desgn)
super
desgn.name == "preferred" or return
desgn.children = l10n "#{to_xml desgn.children}:"
out = desgn.parent
.at(ns("./fmt-preferred//semx[@element = 'preferred'][last()]"))
out or return
out.text.strip.empty? and return
out.children = l10n "#{to_xml out.children}:"
end

def termsource1(elem)
while elem&.next_element&.name == "termsource"
elem << "; #{to_xml(elem.next_element.remove.children)}"
def designation(docxml)
super
docxml.xpath(ns("//fmt-preferred")).each do |x|
x.xpath(ns("./p")).each { |p| p.replace(p.children) }
end
elem.children = l10n(to_xml(elem.children).strip)
end

def termsource_label(elem, sources)
elem.replace(sources)
end

def eref1(elem)
Expand Down
8 changes: 4 additions & 4 deletions lib/isodoc/itu/terms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ def termdef_parse1(node, div, defn, source)
p.b do |b|
node&.at(ns("./fmt-name"))&.children&.each { |n| parse(n, b) }
insert_tab(b, 1)
node&.at(ns("./preferred"))&.children&.each { |n| parse(n, b) }
node&.at(ns("./fmt-preferred"))&.children&.each { |n| parse(n, b) }
end
source and p << "#{source.value} "
end
defn&.children&.each { |n| parse(n, div) }
end

def termdef_parse(node, out)
defn = node.at(ns("./definition"))
source = node.at(ns("./termsource/origin/@citeas"))
defn = node.at(ns("./fmt-definition"))
source = node.at(ns("./fmt-termsource//origin/@citeas"))
out.div **attr_code(id: node["id"]) do |div|
termdef_parse1(node, div, defn, source)
node.children.each do |n|
next if %w(preferred definition termsource fmt-title
next if %w(fmt-preferred fmt-definition fmt-termsource fmt-title
fmt-name).include? n.name

parse(n, out)
Expand Down
18 changes: 12 additions & 6 deletions lib/metanorma/itu/biblio.rng
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ Detailed in https://www.relaton.org/model/creator/</a:documentation>
<a:documentation>An identifier of the person according to an international identifier scheme</a:documentation>
</ref>
</zeroOrMore>
<zeroOrMore>
<optional>
<ref name="contact">
<a:documentation>Contact information for the person, including URI, address, phone number, and email</a:documentation>
</ref>
</zeroOrMore>
</optional>
</element>
</define>
<define name="fullname">
Expand Down Expand Up @@ -454,11 +454,11 @@ real names (if the person is named with a pseudonym or user name); previous lega
<a:documentation>An identifier of the organization according to an international identifier scheme</a:documentation>
</ref>
</zeroOrMore>
<zeroOrMore>
<optional>
<ref name="contact">
<a:documentation>Contact information for the organization, including address, phone number, and email</a:documentation>
</ref>
</zeroOrMore>
</optional>
<optional>
<ref name="logo">
<a:documentation>A logo for the organization</a:documentation>
Expand Down Expand Up @@ -540,12 +540,18 @@ real names (if the person is named with a pseudonym or user name); previous lega
<!-- TODO may change -->
<define name="contact">
<a:documentation>Contact information for a person or organization</a:documentation>
<choice>
<zeroOrMore>
<ref name="address"/>
</zeroOrMore>
<zeroOrMore>
<ref name="phone"/>
</zeroOrMore>
<zeroOrMore>
<ref name="email"/>
</zeroOrMore>
<zeroOrMore>
<ref name="uri"/>
</choice>
</zeroOrMore>
</define>
<define name="phone">
<a:documentation>The phone number associated with a person or organization</a:documentation>
Expand Down
31 changes: 27 additions & 4 deletions spec/isodoc/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,16 @@
<span class="fmt-autonum-delim">.</span>
<semx element="autonum" source="J">1</semx>
</fmt-xref-label>
<preferred>Term2 :</preferred>
<preferred id="_">
<expression>
<name>Term2</name>
</expression>
</preferred>
<fmt-preferred>
<semx element="preferred" source="_">
<strong>Term2</strong> :
</semx>
</fmt-preferred>
</term>
</terms>
<definitions id="L" displayorder="12">
Expand Down Expand Up @@ -342,7 +351,7 @@
</div>
<div id="I">
<h1>3.</h1>
<div id="J"><p class="TermNum" id="J"><b>3.1.&#160; Term2 :</b></p>
<div id="J"><p class="TermNum" id="J"><b>3.1.&#160; <b>Term2</b> :</b></p>
</div>
</div>
<div id="L" class="Symbols">
Expand Down Expand Up @@ -514,7 +523,17 @@
<span class="fmt-autonum-delim">.</span>
<semx element="autonum" source="J">1</semx>
</fmt-xref-label>
<preferred>Term2:</preferred>
<preferred id="_">
<expression>
<name>Term2</name>
</expression>
</preferred>
<fmt-preferred>
<semx element="preferred" source="_">
<strong>Term2</strong>
:
</semx>
</fmt-preferred>
</term>
</terms>
<definitions id="L" displayorder="11">
Expand Down Expand Up @@ -749,7 +768,11 @@
<h1>3.</h1>
<div id="J">
<p class="TermNum" id="J">
<b>3.1. Term2:</b>
<b>
3.1. 
<b>Term2</b>
:
</b>
</p>
</div>
</div>
Expand Down
16 changes: 13 additions & 3 deletions spec/isodoc/section_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,17 @@
<span class="fmt-autonum-delim">.</span>
<semx element="autonum" source="J">1</semx>
</fmt-xref-label>
<preferred>Term2:</preferred>
<preferred id="_">
<expression>
<name>Term2</name>
</expression>
</preferred>
<fmt-preferred>
<semx element="preferred" source="_">
<strong>Term2</strong>
:
</semx>
</fmt-preferred>
</term>
</terms>
<definitions id="L" displayorder="12">
Expand Down Expand Up @@ -1103,7 +1113,7 @@
</div>
<div id="I">
<h1>3.</h1>
<div id="J"><p class="TermNum" id="J"><b>3.1.&#160; Term2:</b></p>
<div id="J"><p class="TermNum" id="J"><b>3.1.&#160; <b>Term2</b>:</b></p>
</div>
</div>
<div id="L" class="Symbols">
Expand Down Expand Up @@ -1217,7 +1227,7 @@
</table>
</div>
<div id="I"><h1>3.</h1>
<div id="J"><p class="TermNum" id="J"><b>3.1.<span style="mso-tab-count:1">&#160; </span>Term2:</b> </p>
<div id="J"><p class="TermNum" id="J"><b>3.1.<span style="mso-tab-count:1">&#160; </span><b>Term2</b>:</b> </p>
</div>
</div>
<div id="L" class="Symbols">
Expand Down
Loading

0 comments on commit 2b6b98c

Please sign in to comment.