Skip to content

Commit

Permalink
Presentation XML refactor, terms: metanorma/isodoc#630
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Jan 8, 2025
1 parent 9978287 commit a183679
Show file tree
Hide file tree
Showing 8 changed files with 371 additions and 129 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-iso", git: "https://github.com/metanorma/metanorma-iso", branch: "feature/presentation-terms"
gem "mn-requirements", git: "https://github.com/metanorma/mn-requirements", branch: "main"
16 changes: 0 additions & 16 deletions lib/isodoc/jis/base_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@
module IsoDoc
module Jis
module BaseConvert
# KILL
def termnote_parsex(node, out)
name = node.at(ns("./name"))&.remove
out.div **note_attrs(node) do |div|
div.p do |p|
if name
p.span class: "note_label" do |s|
name.children.each { |n| parse(n, s) }
end
p << " "
end
para_then_remainder(node.first_element_child, node, p, div)
end
end
end

def make_tr_attr(cell, row, totalrows, header, bordered)
cell["border"] == "0" and bordered = false
super
Expand Down
20 changes: 19 additions & 1 deletion lib/isodoc/jis/presentation_xml_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def ol_depth(node)
end

def admits(elem)
elem.children.first.previous = @i18n.l10n("#{@i18n.admitted}: ")
#elem.children.first.previous = @i18n.l10n("#{@i18n.admitted}: ")
elem.xpath(ns(".//semx[@element = 'admitted']")).each do |t|
t.previous = @i18n.l10n("#{@i18n.admitted}: ")
end
end

def dl(docxml)
Expand Down Expand Up @@ -127,13 +130,28 @@ def full_row(cols, elem)
"<tr><td border='0' colspan='#{cols}'>#{elem}</td></tr>"
end

# KILL
def tablesource(elem)
while elem&.next_element&.name == "source"
elem << "; #{to_xml(elem.next_element.remove.children)}"
end
elem.children = l10n("#{@i18n.source}: #{to_xml(elem.children).strip}")
end

# TODO preserve original Semantic XML source
def tablesource(elem)
ret = [semx_fmt_dup(elem)]
while elem&.next_element&.name == "source"
ret << semx_fmt_dup(elem.next_element.remove)
end
s = ret.map { |x| to_xml(x) }.map(&:strip).join("; ")
tablesource_label(elem, s)
end

def tablesource_label(elem, sources)
elem.children = l10n("#{@i18n.source}: #{sources}")
end

def table_fn1(_table, fnote, _idx)
fnote["reference"] += ")"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/isodoc/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<source status="generalisation">
[SOURCE:
<xref type="inline" target="ISO712">ISO 712, Section 1</xref>
— with adjustments]
<semx element="modification" source="_">with adjustments</semx>]
</source>
<note id="note1" autonum="">
<fmt-name>
Expand Down
40 changes: 33 additions & 7 deletions spec/isodoc/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,18 @@
<span class="fmt-autonum-delim">.</span>
<semx element="autonum" source="J">1</semx>
</fmt-xref-label>
<preferred>
<strong>Term2</strong>
<preferred id="_">
<expression>
<name>Term2</name>
</expression>
</preferred>
<fmt-preferred>
<p>
<semx element="preferred" source="_">
<strong>Term2</strong>
</semx>
</p>
</fmt-preferred>
</term>
</terms>
<definitions id="K">
Expand Down Expand Up @@ -963,9 +972,18 @@
<span class="fmt-autonum-delim">・</span>
<semx element="autonum" source="J">一</semx>
</fmt-xref-label>
<preferred>
<strong>Term2</strong>
<preferred id="_">
<expression>
<name>Term2</name>
</expression>
</preferred>
<fmt-preferred>
<p>
<semx element="preferred" source="_">
<strong>Term2</strong>
</semx>
</p>
</fmt-preferred>
</term>
</terms>
<definitions id="K">
Expand Down Expand Up @@ -1422,7 +1440,6 @@
<doctype language="en">International standard</doctype>
</ext>
</bibdata>
<preface>
<foreword obligation="informative" displayorder="1">
<title id="_">Foreword</title>
Expand Down Expand Up @@ -1543,9 +1560,18 @@
<span class="fmt-autonum-delim">.</span>
<semx element="autonum" source="J">1</semx>
</fmt-xref-label>
<preferred>
<strong>Term2</strong>
<preferred id="_">
<expression>
<name>Term2</name>
</expression>
</preferred>
<fmt-preferred>
<p>
<semx element="preferred" source="_">
<strong>Term2</strong>
</semx>
</p>
</fmt-preferred>
</term>
</terms>
<definitions id="K">
Expand Down
67 changes: 28 additions & 39 deletions spec/isodoc/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,26 +198,33 @@
<semx element="name" source="_">Key</semx>
</p>
<p class="dl">Drago: A type of rice</p>
<source status="generalisation">
<source status="generalisation" id="_">
SOURCE:
<origin bibitemid="ISO712" type="inline" citeas="">
<localityStack>
<locality type="section">
<referenceFrom>1</referenceFrom>
</locality>
</localityStack>
, Section 1
</origin>
— with adjustments ;
<origin bibitemid="ISO713" type="inline" citeas="">
<localityStack>
<locality type="section">
<referenceFrom>3</referenceFrom>
</locality>
</localityStack>
, Section 3
</origin>
— with alterations
<semx element="source" source="_">
<origin bibitemid="ISO712" type="inline" citeas="">
<localityStack>
<locality type="section">
<referenceFrom>1</referenceFrom>
</locality>
</localityStack>
, Section 1
</origin>
<semx element="modification" source="_">with adjustments</semx>
</semx>
;
<semx element="source" source="_">
<origin bibitemid="ISO713" type="inline" citeas="">
<localityStack>
<locality type="section">
<referenceFrom>3</referenceFrom>
</locality>
</localityStack>
, Section 3
</origin>
<semx element="modification" source="_">with alterations</semx>
</semx>
</source>
<note>
<fmt-name>
Expand Down Expand Up @@ -381,14 +388,7 @@
<p class="ListTitle">Key</p>
<p class="dl">Drago: A type of rice</p>
<div class="BlockSource">
<p>SOURCE: , Section 1
with adjustments
;
, Section 3
with alterations</p>
<p>SOURCE: , Section 1 — with adjustments; , Section 3 — with alterations</p>
</div>
<div class="Note">
<p>
Expand Down Expand Up @@ -525,18 +525,7 @@
<tr>
<td colspan="5" style="border-top:0pt;mso-border-top-alt:0pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;border-left:solid windowtext 1.5pt;mso-border-left-alt:solid windowtext 1.5pt;border-right:solid windowtext 1.5pt;mso-border-right-alt:solid windowtext 1.5pt;">
<div class="BlockSource">
<p class="MsoNormal">SOURCE:
, Section 1
— with adjustments ;
, Section 3
— with alterations
</p>
<p class="MsoNormal">SOURCE: , Section 1 — with adjustments; , Section 3 — with alterations</p>
</div>
<div>
<p class="Note">
Expand Down
Loading

0 comments on commit a183679

Please sign in to comment.