Skip to content

Commit

Permalink
Merge pull request #107 from metanorma/features/displayorder
Browse files Browse the repository at this point in the history
Features/displayorder
  • Loading branch information
opoudjis authored Aug 7, 2023
2 parents aaeb6ca + b595a27 commit a004d00
Show file tree
Hide file tree
Showing 15 changed files with 565 additions and 382 deletions.
3 changes: 3 additions & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "features/displayorder"
gem "metanorma-iso", git: "https://github.com/metanorma/metanorma-iso", branch: "features/displayorder"

115 changes: 13 additions & 102 deletions lib/isodoc/jis/base_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,6 @@
module IsoDoc
module JIS
module BaseConvert
def middle_title(_isoxml, out)
middle_title_hdr(out)
middle_title_main(out, "zzSTDTitle1")
middle_subtitle_main(out)
# middle_title_amd(out)
end

def middle_title_hdr(out)
out.p(class: "JapaneseIndustrialStandard") do |p|
p << @i18n.jis
@meta.get[:unpublished] and p << @i18n.l10n("(#{@i18n.draft_label})")
insert_tab(p, 7)
p << "<span class='JIS'>JIS</span>"
end
out.p(class: "StandardNumber") do |p|
insert_tab(p, 1)
p << @meta.get[:docnumber_undated]
if yr = @meta.get[:docyear]
p << ": "
p << "<span class='EffectiveYear'>#{yr}</span>"
end
end
out.p(class: "IDT")
end

def middle_title_main(out, style)
out.p(class: style) do |p|
p << @meta.get[:doctitleintro]
p << " &#x2014; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
p << @meta.get[:doctitlemain]
p << " &#x2014; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
end
a = @meta.get[:doctitlepart] and out.p(class: "zzSTDTitle1") do |p|
b = @meta.get[:doctitlepartlabel] and p << "#{b}: "
p << "<br/><b>#{a}</b>"
end
end

def middle_subtitle_main(out)
@meta.get[:docsubtitlemain] or return
out.p(class: "zzSTDTitle2") do |p|
p << @meta.get[:docsubtitleintro]
p << " &#x2014; " if @meta.get[:docsubtitleintro] && @meta.get[:docsubtitlemain]
p << @meta.get[:docsubtitlemain]
p << " &#x2014; " if @meta.get[:docsubtitlemain] && @meta.get[:docsubtitlepart]
end
a = @meta.get[:docsubtitlepart] and out.p(class: "zzSTDTitle2") do |p|
b = @meta.get[:docsubtitlepartlabel] and p << "#{b}: "
p << "<br/><b>#{a}</b>"
end
end

def commentary_title(_isoxml, out)
commentary_title_hdr(out)
middle_title_main(out, "CommentaryStandardName")
end

def commentary_title_hdr(out)
out.p(class: "CommentaryStandardNumber") do |p|
p << "JIS #{@meta.get[:docnumber_undated]}"
if yr = @meta.get[:docyear]
p << ": "
p << "<span class='CommentaryEffectiveYear'>#{yr}</span>"
end
end
end

def termnote_parse(node, out)
name = node.at(ns("./name"))&.remove
out.div **note_attrs(node) do |div|
Expand All @@ -93,52 +26,30 @@ def admonition_name_parse(_node, div, name)
end
end

def para_class(node)
super || node["class"]
end

def make_tr_attr(cell, row, totalrows, header, bordered)
cell["border"] == "0" and bordered = false
super
end

def middle(isoxml, out)
middle_title(isoxml, out)
middle_admonitions(isoxml, out)
i = isoxml.at(ns("//sections/introduction")) and
introduction i, out
scope isoxml, out, 0
norm_ref isoxml, out, 0
clause_etc isoxml, out, 0
annex isoxml, out
bibliography isoxml, out
commentary isoxml, out
indexsect isoxml, out
end

def annex(isoxml, out)
def annex(node, out)
node["commentary"] = "true" and return commentary(node, out)
amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
isoxml.xpath(ns("//annex[not(@commentary = 'true')]")).each do |c|
page_break(out)
out.div **attr_code(annex_attrs(c)) do |s|
c.elements.each do |c1|
if c1.name == "title" then annex_name(c, c1, s)
else parse(c1, s)
end
end
page_break(out)
out.div **attr_code(annex_attrs(node)) do |s|
node.elements.each do |c1|
if c1.name == "title" then annex_name(node, c1, s)
else parse(c1, s) end
end
end
amd(isoxml) and @suppressheadingnumbers = true
end

def commentary(isoxml, out)
isoxml.xpath(ns("//annex[@commentary = 'true']")).each do |c|
page_break(out)
out.div **attr_code(annex_attrs(c)) do |s|
c.elements.each do |c1|
if c1.name == "title" then annex_name(c, c1, s)
else parse(c1, s)
end
def commentary(node, out)
page_break(out)
out.div **attr_code(annex_attrs(node)) do |s|
node.elements.each do |c1|
if c1.name == "title" then annex_name(node, c1, s)
else parse(c1, s)
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions lib/isodoc/jis/html/style-human.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ q {
quotes: none;
}

blockquote:before,
blockquote:after,
q:before,
q:after {
blockquote::before,
blockquote::after,
q::before,
q::after {
content: '';
content: none;
}
Expand Down Expand Up @@ -232,7 +232,7 @@ ul>li {
list-style: none;
}

ul>li>p:first-child:before {
ul>li>p:first-child::before {
content: "\2014";
display: inline-block;
width: 1em;
Expand All @@ -246,7 +246,7 @@ li p {
line-height: 1.2;
}

#toc li:before {
#toc li::before {
content: " ";
display: none;
}
Expand All @@ -271,7 +271,7 @@ p.Terms {
// box-shadow: inset -5px 0px 10px -5px #1d1d1d !important;
// }

li:before {
li::before {
content: " ";
display: none;
}
Expand Down Expand Up @@ -694,7 +694,7 @@ aside.footnote {
display: inline;
}

ol>li>p:before {
ol>li>p::before {
content: "";
display: none;
}
Expand Down
38 changes: 19 additions & 19 deletions lib/isodoc/jis/html/style-iso.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ body {
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
blockquote::before, blockquote::after,
q::before, q::after {
content: '';
content: none;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ ul > li {
list-style: none;
}

ul > li > p:first-child:before {
ul > li > p:first-child::before {
content: "\2014";
display: inline-block;
width: 1em;
Expand Down Expand Up @@ -210,7 +210,7 @@ p.Terms {
background: none;
}

li:before {
li::before {
content: " ";
display: none;
}
Expand Down Expand Up @@ -458,57 +458,57 @@ ol > li {
list-style: none;
position: relative;
}
ol > li:before {
ol > li::before {
position: absolute;
left: -1.4em;
}
ol[class="roman"] > li:before {
ol[class="roman"] > li::before {
left: -2.0em;
}
ol[class="roman_upper"] > li:before {
ol[class="roman_upper"] > li::before {
left: -2.3em;
}
ol[class="alphabet"] > li:before {
ol[class="alphabet"] > li::before {
counter-increment: alphabet;
content: counter(alphabet, lower-alpha)") "
}
ol[class="arabic"] > li:before {
ol[class="arabic"] > li::before {
counter-increment: arabic;
content: counter(arabic, decimal)") "
}
ol[class="roman"] > li:before {
ol[class="roman"] > li::before {
counter-increment: roman;
content: counter(roman, lower-roman)") "
}
ol[class="alphabet_upper"] > li:before {
ol[class="alphabet_upper"] > li::before {
counter-increment: alphabet_upper;
content: counter(alphabet_upper, upper-alpha)") "
}
ol[class="roman_upper"] > li:before {
ol[class="roman_upper"] > li::before {
counter-increment: roman_upper;
content: counter(roman_upper, upper-roman)") "
}
ol > li:before {
ol > li::before {
counter-increment: alphabet;
content: counter(alphabet, lower-alpha)") "
}
ol[class="alphabet"] ol[class="alphabet"] > li:before {
ol[class="alphabet"] ol[class="alphabet"] > li::before {
counter-increment: alphabet2;
content: counter(alphabet2, lower-alpha)") "
}
ol[class="arabic"] ol[class="arabic"] > li:before {
ol[class="arabic"] ol[class="arabic"] > li::before {
counter-increment: arabic2;
content: counter(arabic2, decimal)") "
}
ol[class="roman"] ol[class="roman"] > li:before {
ol[class="roman"] ol[class="roman"] > li::before {
counter-increment: roman2;
content: counter(roman2, lower-roman)") "
}
ol[class="alphabet_upper"] ol[class="alphabet_upper"] > li:before {
ol[class="alphabet_upper"] ol[class="alphabet_upper"] > li::before {
counter-increment: alphabet_upper2;
content: counter(alphabet_upper2, upper-alpha)") "
}
ol[class="roman_upper"] ol[class="roman_upper"] > li:before {
ol[class="roman_upper"] ol[class="roman_upper"] > li::before {
counter-increment: roman_upper2;
content: counter(roman_upper2, upper-roman)") "
}
Expand Down Expand Up @@ -723,7 +723,7 @@ ol.footnotes-list p, aside.footnote p {
display: inline;
}

ol > li > p:before {
ol > li > p::before {
content: "";
display: none;
}
Expand Down
71 changes: 70 additions & 1 deletion lib/isodoc/jis/presentation_xml_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def full_row(cols, elem)
end

def annex1(elem)
elem["commentary"] == "true" and return
elem["commentary"] == "true" and return commentary(elem)
lbl = @xrefs.anchor(elem["id"], :label)
if t = elem.at(ns("./title"))
t.children = "<strong>#{to_xml(t.children)}</strong>"
Expand All @@ -157,6 +157,21 @@ def move_commentaries_to_end(docxml)
end
end

def commentary(elem)
t = elem.elements.first
commentary_title_hdr(t)
middle_title_main(t, "CommentaryStandardName")
end

def commentary_title_hdr(elem)
ret = <<~COMMENTARY
<p class="CommentaryStandardNumber">JIS #{@meta.get[:docnumber_undated]}
COMMENTARY
yr = @meta.get[:docyear] and
ret += ": <span class='CommentaryEffectiveYear'>#{yr}</span>"
elem.previous = ret
end

def display_order(docxml)
i = 0
i = display_order_xpath(docxml, "//preface/*", i)
Expand Down Expand Up @@ -202,6 +217,60 @@ def move_introduction(doc)
dest.children.first.next = source
end

def middle_title(docxml)
s = docxml.at(ns("//sections")) or return
elem = s.children.first
middle_title_hdr(elem)
middle_title_main(elem, "zzSTDTitle1")
middle_subtitle_main(elem)
# middle_title_amd(s.children.first)
end

def middle_title_hdr(out)
ret = "<p class='JapaneseIndustrialStandard'>#{@i18n.jis}"
@meta.get[:unpublished] and ret += @i18n.l10n("(#{@i18n.draft_label})")
ret += ("<tab/>" * 7)
ret += "<span class='JIS'>JIS</span></p>"
ret += "<p class='StandardNumber'><tab/>#{@meta.get[:docnumber_undated]}"
if yr = @meta.get[:docyear]
ret += ": <span class='EffectiveYear'>#{yr}</span>"
end
ret += "</p><p class='IDT'/>"
out.previous = ret
end

def middle_title_main(out, style)
t = @meta.get[:doctitlemain]
(t && !t.empty?) or return
ret = "<p class='#{style}'>#{@meta.get[:doctitleintro]}"
ret += " &#x2014; " if @meta.get[:doctitleintro] && t
ret += t
ret += " &#x2014; " if t && @meta.get[:doctitlepart]
ret += "</p>"
if a = @meta.get[:doctitlepart]
ret += "<p class='zzSTDTitle1'>"
b = @meta.get[:doctitlepartlabel] and ret += "#{b}: "
ret += "<br/><strong>#{a}</strong></p>"
end
out.previous = ret
end

def middle_subtitle_main(out)
t = @meta.get[:docsubtitlemain]
(t && !t.empty?) or return
ret = "<p class='zzSTDTitle2'>#{@meta.get[:docsubtitleintro]}"
ret += " &#x2014; " if @meta.get[:docsubtitleintro] && t
ret += @meta.get[:docsubtitlemain]
ret += " &#x2014; " if t && @meta.get[:docsubtitlepart]
ret += "</p>"
if a = @meta.get[:docsubtitlepart]
ret += "<p class='zzSTDTitle2'>"
b = @meta.get[:docsubtitlepartlabel] and ret += "#{b}: "
ret += "<br/><strong>#{a}</strong></p>"
end
out.previous = ret
end

include Init
end
end
Expand Down
Loading

0 comments on commit a004d00

Please sign in to comment.