lib/isodoc/presentation_function/section.rb in isodoc-2.11.2 vs lib/isodoc/presentation_function/section.rb in isodoc-2.11.3
- old
+ new
@@ -4,21 +4,19 @@
class PresentationXMLConvert < ::IsoDoc::Convert
def middle_title(docxml)
s = docxml.at(ns("//sections")) or return
t = @meta.get[:doctitle]
t.nil? || t.empty? and return
- #s.children.first.previous =
s.add_first_child "<p class='zzSTDTitle1'>#{t}</p>"
end
def clause(docxml)
docxml.xpath(ns("//clause | " \
"//terms | //definitions | //references"))
.each do |f|
f.parent.name == "annex" &&
@xrefs.klass.single_term_clause?(f.parent) and next
-
clause1(f)
end
end
def unnumbered_clause?(elem)
@@ -39,18 +37,17 @@
def floattitle(docxml)
p = "//clause | //annex | //appendix | //introduction | //foreword | " \
"//preface/abstract | //acknowledgements | //terms | " \
"//definitions | //references | //colophon | //indexsect"
- docxml.xpath(ns(p)).each do |f|
- floattitle1(f)
- end
+ docxml.xpath(ns(p)).each { |f| floattitle1(f) }
# top-level
docxml.xpath(ns("//sections | //preface | //colophon"))
.each { |f| floattitle1(f) }
end
+ # TODO not currently doing anything with the @depth attribute of floating-title
def floattitle1(elem)
elem.xpath(ns(".//floating-title")).each do |p|
p.name = "p"
p["type"] = "floating-title"
end
@@ -65,13 +62,12 @@
@xrefs.parse_inclusions(clauses: true).parse(docxml)
end
def annex1(elem)
lbl = @xrefs.anchor(elem["id"], :label)
- if t = elem.at(ns("./title"))
+ t = elem.at(ns("./title")) and
t.children = "<strong>#{to_xml(t.children)}</strong>"
- end
unnumbered_clause?(elem) and return
prefix_name(elem, "<br/><br/>", lbl, "title")
end
def single_term_clause_retitle(elem)
@@ -127,11 +123,11 @@
out = node.xpath("./preceding-sibling::*")
.reverse.each_with_object([]) do |p, m|
%w(note admonition p).include?(p.name) or break m
m << p
end
- out.reject { |c| c["displayorder"] }.reverse.each do |c|
+ out.reject { |c| c["displayorder"] }.reverse_each do |c|
c["displayorder"] = idx
idx += 1
end
idx
end
@@ -193,11 +189,10 @@
def preface_move1(clause, preface, float, prev, xpath)
preface.elements.each do |x|
((x.name == "floating-title" || x.at(xpath)) &&
xpath != "./self::*[not(following-sibling::*)]") or prev = x
- # after.include?(x.name) or next
x.at(xpath) or next
clause == prev and break
prev ||= preface.children.first
float << clause
float.each { |n| prev.next = n }
@@ -246,10 +241,9 @@
end
def toc_refs(docxml)
docxml.xpath(ns("//toc//xref[text()]")).each do |x|
lbl = @xrefs.anchor(x["target"], :label) or next
- #x.children.first.previous = "#{lbl}<tab/>"
x.add_first_child "#{lbl}<tab/>"
end
end
end
end