Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symbol concepts: https://github.com/metanorma/metanorma-standoc/issue… #315

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/isodoc/presentation_function/inline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ def concept(docxml)
end

def concept1(node)
xref = node&.at(ns("./xref/@target"))&.text or
return concept_term1(node)
if node.at(ns("//definitions//dt[@id = '#{xref}']"))
concept_symbol1(node)
else concept_term1(node)
end
end

def concept_symbol1(node)
r = node.at(ns("./renderterm")) and node.replace(r.children)
end

def concept_term1(node)
node&.at(ns("./refterm"))&.remove
r = node.at(ns("./renderterm"))
r&.next = " "
Expand Down
84 changes: 84 additions & 0 deletions spec/isodoc/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,90 @@
.convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
end

it "processes concept markup for symbols" do
input = <<~INPUT
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<p>
<ul>
<li><concept>
<refterm>term</refterm>
<renderterm>ISO</renderterm>
<xref target='d1'/>
</concept></li>
</ul>
</p>
</foreword>
</preface>
<sections>
<definitions id="d">
<dl>
<dt id="d1">ISO</dt> <dd>xyz</xyz>
<dt id="d2">IEC</dt> <dd>abc</xyz>
</dl>
</definitions>
</sections>
</iso-standard>
INPUT
presxml = <<~OUTPUT
<iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
<preface>
<foreword displayorder='1'>
<p>
<ul>
<li>ISO</li>
</ul>
</p>
</foreword>
</preface>
<sections>
<definitions id='d' displayorder='2'>
<title>1.</title>
<dl>
<dt id='d1'>ISO</dt>
<dd>xyz</dd>
<dt id='d2'>IEC</dt>
<dd>abc</dd>
</dl>
</definitions>
</sections>
</iso-standard>
OUTPUT
output = <<~OUTPUT
#{HTML_HDR}
<br/>
<div>
<h1 class='ForewordTitle'>Foreword</h1>
<p>
<ul>
<li>ISO</li>
</ul>
</p>
</div>
<p class='zzSTDTitle1'/>
<div id='d' class='Symbols'>
<h1>1.</h1>
<dl>
<dt id='d1'>
<p>ISO</p>
</dt>
<dd>xyz</dd>
<dt id='d2'>
<p>IEC</p>
</dt>
<dd>abc</dd>
</dl>
</div>
</div>
</body>
</html>
OUTPUT
expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
.convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
end

it "processes embedded inline formatting" do
input = <<~INPUT
<iso-standard xmlns="http://riboseinc.com/isoxml">
Expand Down