Skip to content

Commit

Permalink
ensure dl has fmt-name: #617
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Nov 14, 2024
1 parent 6ce108d commit 670e9ae
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/isodoc/function/references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def biblio_list(refs, div, biblio)
i += 1
bibitem_entry(div, b, i, biblio)
else
parse(b, div) unless %w(title).include? b.name
parse(b, div) unless %w(fmt-title).include? b.name
end
end
end
Expand Down
10 changes: 8 additions & 2 deletions lib/isodoc/presentation_function/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def table(docxml)
def table1(elem)
table_fn(elem)
labelled_ancestor(elem) and return
# elem["unnumbered"] && !elem.at(ns("./name")) and return
elem["unnumbered"] && !elem.at(ns("./name")) and return
n = @xrefs.anchor(elem["id"], :label, false)
lbl = "<span class='fmt-element-name'>#{lower2cap @i18n.table}</span> "\
"#{autonum(elem['id'], n)}"
Expand Down Expand Up @@ -146,7 +146,13 @@ def amend1(elem)
elem.replace(elem.children)
end

def dl(docxml); end
def dl(docxml)
docxml.xpath(ns("//dl")).each { |f| dl1(f) }
end

def dl1(elem)
prefix_name(elem, {}, "", "name") # copy name to fmt-name
end

def ol(docxml)
docxml.xpath(ns("//ol")).each { |f| ol1(f) }
Expand Down
96 changes: 74 additions & 22 deletions spec/isodoc/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</tr>
</tfoot>
<dl key="true">
<name>Key</name>
<name>Key</name>
<dt>Drago</dt>
<dd>A type of rice</dd>
</dl>
Expand Down Expand Up @@ -109,18 +109,43 @@
<iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
<preface>
<clause type="toc" displayorder="1" id="_">
<title depth="1">Table of contents</title>
<fmt-title depth="1">Table of contents</fmt-title>
</clause>
<foreword displayorder="2"><title>Foreword</title>
<table id='tableD-1' alt='tool tip' summary='long desc' width='70%' keep-with-next='true' keep-lines-together='true'>
<name>
Table 1&#xA0;&#x2014; Repeatability and reproducibility of
<em>husked</em>
rice yield
<fn reference='1'>
<foreword displayorder="2">
<title id="_">Foreword</title>
<fmt-title depth="1">
<span class="fmt-caption-label">
<semx element="title" source="_">Foreword</semx>
</span>
</fmt-title>
<table id='tableD-1' alt='tool tip' summary='long desc' width='70%' keep-with-next='true' keep-lines-together='true' autonum="1">
<name id="_">
Repeatability and reproducibility of
<em>husked</em>
rice yield
<fn reference="1">
<p>X</p>
</fn>
</name>
<fmt-name>
<span class="fmt-caption-label">
<span class="fmt-element-name">Table</span>
<semx element="autonum" source="tableD-1">1</semx>
<span class="fmt-caption-delim"> — </span>
<semx element="name" source="_">
Repeatability and reproducibility of
<em>husked</em>
rice yield
<fn reference="1">
<p>X</p>
</fn>
</name>
</fn>
</semx>
</span>
</fmt-name>
<fmt-xref-label>
<span class="fmt-element-name">Table</span>
<semx element="autonum" source="tableD-1">1</semx>
</fmt-xref-label>
<colgroup>
<col width='30%'/>
<col width='20%'/>
Expand Down Expand Up @@ -187,14 +212,23 @@
</tr>
</tfoot>
<dl key="true">
<name>Key</name>
<name id="_">Key</name>
<fmt-name>
<span class="fmt-caption-label">
<semx element="name" source="_">Key</semx>
</span>
</fmt-name>
<dt>Drago</dt>
<dd>A type of rice</dd>
</dl>
<source status="generalisation">[SOURCE: <xref type="inline" target="ISO712">ISO 712, Section 1</xref>
— with adjustments ; <xref type="inline" target="ISO712">ISO 712, Section 2</xref>]</source>
<note>
<name>NOTE</name>
<fmt-name>
<span class="fmt-caption-label">
<span class="fmt-element-name">NOTE</span>
</span>
</fmt-name>
<p>This is a table about rice</p>
</note>
</table>
Expand All @@ -209,7 +243,21 @@
</preface>
<sections>
<references id="_" obligation="informative" normative="true" displayorder="3">
<title depth="1">1.<tab/>Normative References</title>
<title id="_">Normative References</title>
<fmt-title depth="1">
<span class="fmt-caption-label">
<semx element="autonum" source="_">1</semx>
<span class="fmt-autonum-delim">.</span>
<span class="fmt-caption-delim">
<tab/>
</span>
<semx element="title" source="_">Normative References</semx>
</span>
</fmt-title>
<fmt-xref-label>
<span class="fmt-element-name">Clause</span>
<semx element="autonum" source="_">1</semx>
</fmt-xref-label>
<bibitem id="ISO712" type="standard">
<formattedref>International Organization for Standardization. <em>Cereals and cereal products</em>.</formattedref>
<docidentifier type="ISO">ISO 712</docidentifier>
Expand Down Expand Up @@ -329,7 +377,7 @@
OUTPUT

word = <<~OUTPUT
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
<head><style/></head>
<body lang="EN-US" link="blue" vlink="#954F72">
<div class="WordSection1">
Expand Down Expand Up @@ -458,13 +506,17 @@
</body>
</html>
OUTPUT
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to Xml::C14n.format(html)
expect(Xml::C14n.format(IsoDoc::WordConvert.new({})
.convert("test", presxml, true)
.gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")))
pres_output = IsoDoc::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true)
expect(Xml::C14n.format(strip_guid(pres_output)))
.to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({})
.convert("test", pres_output, true))))
.to be_equivalent_to Xml::C14n.format(html)
expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({})
.convert("test", pres_output, true)
.gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref"))))
.to be_equivalent_to Xml::C14n.format(word)
end

Expand Down

0 comments on commit 670e9ae

Please sign in to comment.