Skip to content

Commit

Permalink
update to Presentation XML refactor: metanorma/isodoc#630
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Jan 1, 2025
1 parent 5b5188f commit 5e7bfb6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
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"
32 changes: 31 additions & 1 deletion lib/isodoc/ietf/terms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ def set_termdomain(termdomain)
@termdomain = termdomain
end

def semx_definition_parse(node, out)
definition_parse(node, out)
end

def definition_parse(node, out)
node.children.each { |n| parse(n, out) }
end
Expand All @@ -15,13 +19,21 @@ def modification_parse(node, out)
para.children.each { |n| parse(n, out) }
end

def semx_deprecated_term_parse(node, out)
deprecated_term_parse(node, out)
end

def deprecated_term_parse(node, out)
name = node.at(ns(".//name"))
out.t do |p|
p << l10n("#{@i18n.deprecated}: ")
name.children.each { |c| parse(c, p) }
end
end

def semx_admitted_term_parse(node, out)
admitted_term_parse(node, out)
end

def admitted_term_parse(node, out)
name = node.at(ns(".//name"))
Expand All @@ -30,6 +42,10 @@ def admitted_term_parse(node, out)
end
end

def semx_term_parse(node, out)
term_parse(node, out)
end

def term_parse(node, out)
if domain = node.at(ns("./domain"))
set_termdomain(domain.text)
Expand All @@ -53,10 +69,20 @@ def termdef_parse(node, out)
set_termdomain("")
end
node.xpath(ns("./definition")).size > 1 and
@isodoc.multidef(node)
multidef(node)
clause_parse(node, out)
end

def multidef(elem)
d = elem.at(ns("./definition"))
d = d.replace("<ol><li>#{to_xml(d.children)}</li></ol>").first
elem.xpath(ns("./definition")).each do |f|
f = f.replace("<li>#{to_xml(f.children)}</li>").first
d << f
end
d.wrap("<definition></definition>")
end

def termdocsource_parse(_node, _out); end

def concept_parse(node, out)
Expand Down Expand Up @@ -106,6 +132,10 @@ def preprocess_termref(elem)
end
end

def semx_termref_parse(node, out)
termref_parse(node, out)
end

def termref_parse(elem, out)
preprocess_termref(elem)
elem.children = l10n("[#{@i18n.source}: #{to_xml(elem.children).strip}]")
Expand Down

0 comments on commit 5e7bfb6

Please sign in to comment.