isodoc 1.7.7 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,68 +0,0 @@
1
- module IsoDoc
2
- class PresentationXMLConvert < ::IsoDoc::Convert
3
- def concept(docxml)
4
- docxml.xpath(ns("//concept")).each { |f| concept1(f) }
5
- end
6
-
7
- def concept1(node)
8
- xref = node&.at(ns("./xref/@target"))&.text or
9
- return concept_render(node, ital: node["ital"] || "true",
10
- ref: node["ref"] || "true",
11
- linkref: node["linkref"] || "true",
12
- linkmention: node["linkmention"] || "false")
13
- if node.at(ns("//definitions//dt[@id = '#{xref}']"))
14
- concept_render(node, ital: node["ital"] || "false",
15
- ref: node["ref"] || "false",
16
- linkref: node["linkref"] || "true",
17
- linkmention: node["linkmention"] || "false")
18
- else concept_render(node, ital: node["ital"] || "true",
19
- ref: node["ref"] || "true",
20
- linkref: node["linkref"] || "true",
21
- linkmention: node["linkmention"] || "false")
22
- end
23
- end
24
-
25
- def concept_render(node, opts)
26
- node&.at(ns("./refterm"))&.remove
27
- r = node.at(ns("./renderterm"))
28
- ref = node.at(ns("./xref | ./eref | ./termref"))
29
- ref && opts[:ref] != "false" and r&.next = " "
30
- opts[:ital] == "true" and r&.name = "em"
31
- if opts[:linkmention] == "true" && !r.nil? && !ref.nil?
32
- ref2 = ref.clone
33
- r2 = r.clone
34
- r.replace(ref2).children = r2
35
- end
36
- concept1_ref(node, ref, opts)
37
- if opts[:ital] == "false"
38
- r = node.at(ns(".//renderterm"))
39
- r&.replace(r&.children)
40
- end
41
- node.replace(node.children)
42
- end
43
-
44
- def concept1_ref(_node, ref, opts)
45
- ref.nil? and return
46
- return ref.remove if opts[:ref] == "false"
47
-
48
- r = concept1_ref_content(ref)
49
- ref = r.at("./descendant-or-self::xmlns:xref | "\
50
- "./descendant-or-self::xmlns:eref | "\
51
- "./descendant-or-self::xmlns:termref")
52
- %w(xref eref).include? ref&.name and get_linkend(ref)
53
- if opts[:linkref] == "false" && %w(xref eref).include?(ref&.name)
54
- ref.replace(ref.children)
55
- end
56
- end
57
-
58
- def concept1_ref_content(ref)
59
- if non_locality_elems(ref).select do |c|
60
- !c.text? || /\S/.match(c)
61
- end.empty?
62
- ref.replace(@i18n.term_defined_in.sub(/%/,
63
- ref.to_xml))
64
- else ref.replace("[#{ref.to_xml}]")
65
- end
66
- end
67
- end
68
- end