metanorma-iso 1.10.0 → 1.10.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ubuntu.yml +41 -0
  3. data/Gemfile +3 -4
  4. data/Makefile +44 -0
  5. data/Rakefile +1 -1
  6. data/bin/rspec +1 -2
  7. data/lib/asciidoctor/iso/base.rb +1 -1
  8. data/lib/asciidoctor/iso/cleanup.rb +7 -6
  9. data/lib/asciidoctor/iso/front.rb +2 -2
  10. data/lib/asciidoctor/iso/isodoc.rng +68 -18
  11. data/lib/asciidoctor/iso/isostandard.rng +14 -0
  12. data/lib/asciidoctor/iso/section.rb +1 -1
  13. data/lib/asciidoctor/iso/validate.rb +1 -1
  14. data/lib/asciidoctor/iso/validate_section.rb +1 -1
  15. data/lib/isodoc/iso/html/isodoc.css +0 -1
  16. data/lib/isodoc/iso/html/isodoc.scss +0 -1
  17. data/lib/isodoc/iso/html/style-human.css +21 -1
  18. data/lib/isodoc/iso/html/style-human.scss +26 -1
  19. data/lib/isodoc/iso/html/style-iso.css +21 -1
  20. data/lib/isodoc/iso/html/style-iso.scss +26 -1
  21. data/lib/isodoc/iso/html_convert.rb +81 -22
  22. data/lib/isodoc/iso/i18n.rb +10 -9
  23. data/lib/isodoc/iso/iso.amendment.xsl +304 -118
  24. data/lib/isodoc/iso/iso.international-standard.xsl +304 -118
  25. data/lib/isodoc/iso/isosts_convert.rb +6 -2
  26. data/lib/isodoc/iso/presentation_xml_convert.rb +19 -9
  27. data/lib/isodoc/iso/sections.rb +2 -0
  28. data/lib/isodoc/iso/sts_convert.rb +5 -2
  29. data/lib/isodoc/iso/word_cleanup.rb +94 -0
  30. data/lib/isodoc/iso/word_convert.rb +12 -91
  31. data/lib/metanorma/iso/processor.rb +2 -2
  32. data/lib/metanorma/iso/version.rb +1 -1
  33. data/metanorma-iso.gemspec +3 -3
  34. data/spec/asciidoctor/base_spec.rb +543 -209
  35. data/spec/asciidoctor/blocks_spec.rb +4 -43
  36. data/spec/asciidoctor/cleanup_spec.rb +15 -12
  37. data/spec/asciidoctor/refs_spec.rb +174 -88
  38. data/spec/isodoc/i18n_spec.rb +32 -18
  39. data/spec/isodoc/inline_spec.rb +4 -4
  40. data/spec/isodoc/postproc_spec.rb +111 -28
  41. data/spec/isodoc/section_spec.rb +3 -3
  42. data/spec/isodoc/table_spec.rb +6 -8
  43. data/spec/isodoc/terms_spec.rb +30 -37
  44. data/spec/isodoc/xref_spec.rb +3 -3
  45. data/spec/metanorma/processor_spec.rb +110 -14
  46. data/spec/vcr_cassettes/docrels.yml +783 -0
  47. data/spec/vcr_cassettes/sortrefs.yml +599 -0
  48. metadata +12 -8
@@ -10,39 +10,98 @@ module IsoDoc
10
10
  super
11
11
  end
12
12
 
13
- def googlefonts()
14
- <<~HEAD.freeze
15
- <link href="https://fonts.googleapis.com/css?family=Space+Mono:400,400i,700,700i&display=swap" rel="stylesheet">
16
- <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
17
- HEAD
18
- end
13
+ def googlefonts
14
+ <<~HEAD.freeze
15
+ <link href="https://fonts.googleapis.com/css?family=Space+Mono:400,400i,700,700i&display=swap" rel="stylesheet">
16
+ <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
17
+ HEAD
18
+ end
19
19
 
20
20
  def default_fonts(options)
21
21
  {
22
- bodyfont: (options[:script] == "Hans" ? '"Source Han Sans",serif' :
23
- options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'),
24
- headerfont: (options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
25
- options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'),
26
- monospacefont: (options[:alt] ? '"Space Mono",monospace' :
27
- '"Courier New",monospace'),
28
- normalfontsize: "1.0em",
29
- smallerfontsize: "0.9em",
30
- footnotefontsize: "0.9em",
31
- monospacefontsize: "0.8em",
22
+ bodyfont: (if options[:script] == "Hans"
23
+ '"Source Han Sans",serif'
24
+ else
25
+ options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'
26
+ end),
27
+ headerfont: (if options[:script] == "Hans"
28
+ '"Source Han Sans",sans-serif'
29
+ else
30
+ options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'
31
+ end),
32
+ monospacefont: (if options[:alt]
33
+ '"Space Mono",monospace'
34
+ else
35
+ '"Courier New",monospace'
36
+ end),
37
+ normalfontsize: "1.0em",
38
+ smallerfontsize: "0.9em",
39
+ footnotefontsize: "0.9em",
40
+ monospacefontsize: "0.8em",
32
41
  }
33
42
  end
34
43
 
35
44
  def default_file_locations(options)
36
45
  {
37
- htmlstylesheet: (options[:alt] ? html_doc_path("style-human.scss") :
38
- html_doc_path("style-iso.scss")),
39
- htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
40
- htmlintropage: html_doc_path("html_iso_intro.html"),
46
+ htmlstylesheet: (if options[:alt]
47
+ html_doc_path("style-human.scss")
48
+ else
49
+ html_doc_path("style-iso.scss")
50
+ end),
51
+ htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
52
+ htmlintropage: html_doc_path("html_iso_intro.html"),
41
53
  }
42
54
  end
43
55
 
44
- def footnote_reference_format(a)
45
- a.content = a.content + ")"
56
+ def footnote_reference_format(link)
57
+ link.content += ")"
58
+ end
59
+
60
+ def html_toc_entry(level, header)
61
+ if level == "h1" && header.parent.at(".//h2[not(@class = 'TermNum')]"\
62
+ "[not(@class = 'noTOC')][text()]")
63
+ <<~HDR
64
+ <li class="#{level}"><div class="collapse-group"><a href="##{header['id']}">#{header_strip(header)}</a></li>
65
+ <div class="collapse-button"></div></div>
66
+ HDR
67
+ else
68
+ %(<li class="#{level}"><a href="##{header['id']}">\
69
+ #{header_strip(header)}</a></li>)
70
+ end
71
+ end
72
+
73
+ def html_toc(docxml)
74
+ super
75
+ docxml.xpath("//div[@id = 'toc']/ul[li[@class = 'h2']]").each do |u|
76
+ html_toc1(u)
77
+ end
78
+ docxml
79
+ end
80
+
81
+ def html_toc1(ulist)
82
+ u2 = nil
83
+ ulist.xpath("./li").each do |l|
84
+ if l["class"] != "h2"
85
+ u2 = nil
86
+ elsif u2 then u2.add_child(l.remove)
87
+ else
88
+ u2 = l.replace("<ul class='content collapse'>#{l}</ul>").first
89
+ p = u2.previous_element and p << u2
90
+ end
91
+ end
92
+ end
93
+
94
+ def inject_script(doc)
95
+ scr = <<~HEAD.freeze
96
+ <script>
97
+ $(".collapse-button").click(function () {
98
+ $(this).toggleClass('expand'); // expand: the class to change the collapse button shape
99
+ // collapse: the class to collapse/expand the li elements with the h2 class
100
+ $(this).closest('li').children(".content").toggleClass('collapse');})
101
+ </script>
102
+ HEAD
103
+ a = super.split(%r{</body>})
104
+ "#{a[0]}#{scr}</body>#{a[1]}"
46
105
  end
47
106
 
48
107
  def table_th_center(docxml)
@@ -1,16 +1,17 @@
1
1
  module IsoDoc
2
2
  module Iso
3
3
  class I18n < IsoDoc::I18n
4
+ def load_file(fname)
5
+ YAML.load_file(File.join(File.dirname(__FILE__), fname))
6
+ end
7
+
4
8
  def load_yaml1(lang, script)
5
- y = if lang == "en"
6
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
7
- elsif lang == "fr"
8
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-fr.yaml"))
9
- elsif lang == "zh" && script == "Hans"
10
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
11
- else
12
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
13
- end
9
+ y = if lang == "en" then load_file("i18n-en.yaml")
10
+ elsif lang == "fr" then load_file("i18n-fr.yaml")
11
+ elsif lang == "zh" && script == "Hans"
12
+ load_file("i18n-zh-Hans.yaml")
13
+ else load_file("i18n-en.yaml")
14
+ end
14
15
  super.merge(y)
15
16
  end
16
17
  end