isodoc 1.2.8 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +15 -1
  3. data/isodoc.gemspec +1 -1
  4. data/lib/isodoc-yaml/i18n-en.yaml +55 -0
  5. data/lib/isodoc-yaml/i18n-fr.yaml +56 -0
  6. data/lib/isodoc/base_style/blocks.scss +2 -2
  7. data/lib/isodoc/base_style/typography.scss +1 -1
  8. data/lib/isodoc/convert.rb +13 -85
  9. data/lib/isodoc/css.rb +95 -0
  10. data/lib/isodoc/function/inline_simple.rb +10 -1
  11. data/lib/isodoc/function/lists.rb +2 -1
  12. data/lib/isodoc/function/references.rb +7 -12
  13. data/lib/isodoc/function/section.rb +1 -1
  14. data/lib/isodoc/function/table.rb +10 -0
  15. data/lib/isodoc/function/to_word_html.rb +4 -2
  16. data/lib/isodoc/function/utils.rb +2 -2
  17. data/lib/isodoc/gem_tasks.rb +4 -0
  18. data/lib/isodoc/html_function/html.rb +7 -0
  19. data/lib/isodoc/html_function/mathvariant_to_plain.rb +82 -0
  20. data/lib/isodoc/html_function/postprocess.rb +43 -22
  21. data/lib/isodoc/metadata_contributor.rb +4 -3
  22. data/lib/isodoc/presentation_function/bibdata.rb +3 -3
  23. data/lib/isodoc/presentation_function/inline.rb +5 -3
  24. data/lib/isodoc/presentation_function/section.rb +9 -0
  25. data/lib/isodoc/presentation_xml_convert.rb +2 -0
  26. data/lib/isodoc/version.rb +1 -1
  27. data/lib/isodoc/word_convert.rb +0 -20
  28. data/lib/isodoc/word_function/inline.rb +2 -2
  29. data/lib/isodoc/word_function/postprocess.rb +38 -80
  30. data/lib/isodoc/word_function/postprocess_cover.rb +55 -0
  31. data/lib/isodoc/word_function/table.rb +10 -0
  32. data/lib/isodoc/xref.rb +1 -0
  33. data/lib/isodoc/xref/xref_counter.rb +63 -20
  34. data/lib/isodoc/xref/xref_gen.rb +20 -2
  35. data/lib/isodoc/xref/xref_sect_gen.rb +34 -27
  36. data/spec/assets/html.scss +14 -0
  37. data/spec/isodoc/blocks_spec.rb +26 -73
  38. data/spec/isodoc/cleanup_spec.rb +0 -1
  39. data/spec/isodoc/inline_spec.rb +14 -14
  40. data/spec/isodoc/lists_spec.rb +1 -1
  41. data/spec/isodoc/metadata_spec.rb +3 -1
  42. data/spec/isodoc/postproc_spec.rb +473 -11
  43. data/spec/isodoc/presentation_xml_spec.rb +2 -2
  44. data/spec/isodoc/ref_spec.rb +323 -5
  45. data/spec/isodoc/table_spec.rb +28 -0
  46. data/spec/isodoc/xref_spec.rb +472 -19
  47. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 491a322b0df2e6b1c8b4f12e520ca349657a009058b416067acdd5437a16085c
4
- data.tar.gz: 1f52844ffdc37875d2b40f8d46f52263abcbe5101c99adaf88d839a28a18ed49
3
+ metadata.gz: f3c777ea5977413526f9c0178d0460978e495a4292335201d871c1150b0f48ac
4
+ data.tar.gz: d5a5cbf4385dbdaa4ab65be04bc902853a236d470247d093f35eb3c12fe3cbc4
5
5
  SHA512:
6
- metadata.gz: ce472eadec9ab44d5739f0e506813cb89cf7de6def2909e8ffd0788cf4fe246bf3433b75c22490528b0287bbfad1e2cc5ca50eeaacdd4156fe9bb32a36e912df
7
- data.tar.gz: efb30d195c6a15f97133b76d1d4cac762800fe7620d11a58a2655e7ccd3bc972827d419337cbff13fb7d1c4b96004da7b9d95323ae7d8f6c1eaa07d784f67834
6
+ metadata.gz: 554df5885f22823b5aaec3453da4695fce9c0c32ee90de6830a4159f8029b070385f2124c9fae5a7082b63688df596f8ea2b39d58297e64f20304b0e40e030cb
7
+ data.tar.gz: f8adad1944d3062b2ce674c7fb0201f81e6ad4ff43bdd4f43f08429b6cc808f5ab40aa1905473365e3b59d66a6a413a064fdbc20f755c986ed3a763b017fe5b3
@@ -36,7 +36,7 @@ jobs:
36
36
  with:
37
37
  ruby-version: ${{ matrix.ruby }}
38
38
 
39
- - uses: actions/cache@v1
39
+ - uses: actions/cache@v2
40
40
  with:
41
41
  path: vendor/bundle
42
42
  key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
@@ -67,3 +67,17 @@ jobs:
67
67
  inkscape --version
68
68
 
69
69
  - run: bundle exec rake
70
+
71
+ tests-passed:
72
+ needs: rake
73
+ runs-on: ubuntu-latest
74
+ continue-on-error: true
75
+ steps:
76
+ - name: Trigger tests passed event
77
+ uses: Sibz/github-status-action@v1
78
+ with:
79
+ authToken: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
80
+ context: 'tests-passed-successfully'
81
+ description: 'Tests passed successfully'
82
+ state: 'success'
83
+ sha: ${{ github.event.pull_request.head.sha || github.sha }}
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_dependency "asciimath"
32
32
  spec.add_dependency "htmlentities", "~> 4.3.4"
33
- spec.add_dependency "nokogiri", ">= 1.10.4"
33
+ spec.add_dependency "nokogiri", "~> 1.10.4"
34
34
  spec.add_dependency "thread_safe"
35
35
  spec.add_dependency "uuidtools"
36
36
  spec.add_dependency "html2doc", "~> 1.0.0"
@@ -97,3 +97,58 @@ locality: {
97
97
  note: Note,
98
98
  formula: Formula
99
99
  }
100
+ inflection:
101
+ Clause:
102
+ sg: Clause
103
+ pl: Clauses
104
+ Annex:
105
+ sg: Annex
106
+ pl: Annexes
107
+ Appendix:
108
+ sg: Appendix
109
+ pl: Appendixes
110
+ Note:
111
+ sg: Note
112
+ pl: Notes
113
+ "Note % to entry":
114
+ sg: Note % to entry
115
+ pl: Notes % to entry
116
+ List:
117
+ sg: List
118
+ pl: Lists
119
+ Figure:
120
+ sg: Figure
121
+ pl: Figures
122
+ Formula:
123
+ sg: Formula
124
+ pl: Formulas
125
+ Table:
126
+ sg: Table
127
+ pl: Tables
128
+ Requirement:
129
+ sg: Requirement
130
+ pl: Requirements
131
+ Recommendation:
132
+ sg: Recommendation
133
+ pl: Recommendations
134
+ Permission:
135
+ sg: Permission
136
+ pl: Permissions
137
+ Example:
138
+ sg: Example
139
+ pl: Examples
140
+ Part:
141
+ sg: Part
142
+ pl: Parts
143
+ Section:
144
+ sg: Section
145
+ pl: Sections
146
+ Paragraph:
147
+ sg: Paragraph
148
+ pl: Paragraphs
149
+ Chapter:
150
+ sg: Chapter
151
+ pl: Chapters
152
+ Page:
153
+ sg: Page
154
+ pl: Pages
@@ -90,3 +90,59 @@ locality: {
90
90
  note: Note,
91
91
  formula: Formule
92
92
  }
93
+ inflection:
94
+ Clause:
95
+ sg: Article
96
+ pl: Articles
97
+ Annex:
98
+ sg: Annexe
99
+ pl: Annexes
100
+ Appendix:
101
+ sg: Appendice
102
+ pl: Appendices
103
+ Note:
104
+ sg: Note
105
+ pl: Notes
106
+ "Note % à l’article":
107
+ sg: Note % à l’article
108
+ pl: Notes % à l’article
109
+ List:
110
+ sg: Liste
111
+ pl: Listes
112
+ Figure:
113
+ sg: Figure
114
+ pl: Figures
115
+ Formula:
116
+ sg: Formule
117
+ pl: Formules
118
+ Table:
119
+ sg: Tableau
120
+ pl: Tableaux
121
+ Requirement:
122
+ sg: Exigence
123
+ pl: Exigences
124
+ Recommendation:
125
+ sg: Recommandation
126
+ pl: Recommandations
127
+ Permission:
128
+ sg: Autorisation
129
+ pl: Autorisations
130
+ Example:
131
+ sg: Exemple
132
+ pl: Exemples
133
+ Part:
134
+ sg: Partie
135
+ pl: Parties
136
+ Section:
137
+ sg: Section
138
+ pl: Sections
139
+ Paragraph:
140
+ sg: Alinéa
141
+ pl: Alinéas
142
+ Chapter:
143
+ sg: Chapitre
144
+ pl: Chapitres
145
+ Page:
146
+ sg: Page
147
+ pl: Pages
148
+
@@ -50,7 +50,7 @@
50
50
  }
51
51
 
52
52
  background-color: $colorBg;
53
- font-size: 0.8em;
53
+ font-size: $monospacefontsize;
54
54
  line-height: 1.6em;
55
55
  padding: 1.5em;
56
56
  margin: 2em 0 1em 0;
@@ -68,7 +68,7 @@
68
68
  }
69
69
 
70
70
  background-color: $colorBg;
71
- font-size: 0.8em;
71
+ font-size: $monospacefontsize;
72
72
  line-height: 1.6em;
73
73
  padding: 1.5em;
74
74
  margin: 2em 0 1em 0;
@@ -56,7 +56,7 @@
56
56
 
57
57
  &, th, td {
58
58
  border: $border;
59
- font-size: 0.95em;
59
+ font-size: 0.95em; // NN 20201115: ??? normalfontsize - 0.05?
60
60
  }
61
61
  th, td {
62
62
  padding: 1em;
@@ -3,6 +3,7 @@ require "isodoc/common"
3
3
  require "fileutils"
4
4
  require "tempfile"
5
5
  require_relative "i18n"
6
+ require_relative "css"
6
7
 
7
8
  module IsoDoc
8
9
  class Convert < ::IsoDoc::Common
@@ -17,6 +18,10 @@ module IsoDoc
17
18
  # wordcoverpage: Cover page for Word
18
19
  # htmlintropage: Introductory page for HTML
19
20
  # wordintropage: Introductory page for Word
21
+ # normalfontsize: Font size for body text
22
+ # smallerfontsize: Font size for smaller than body text
23
+ # monospacefontsize: Font size for monospace font
24
+ # footnotefontsize: Font size for footnotes
20
25
  # i18nyaml: YAML file for internationalisation of text
21
26
  # ulstyle: list style in Word CSS for unordered lists
22
27
  # olstyle: list style in Word CSS for ordered lists
@@ -25,8 +30,10 @@ module IsoDoc
25
30
  # monospace: font to use for monospace text
26
31
  # suppressheadingnumbers: suppress heading numbers for clauses
27
32
  # scripts: Scripts file for HTML
28
- # scripts_pdf: Scripts file for PDF
33
+ # scripts_pdf: Scripts file for PDF (not used in XSLT PDF)
29
34
  # datauriimage: Encode images in HTML output as data URIs
35
+ # break_up_urls_in_tables: whether to insert spaces in URLs in tables
36
+ # every 40-odd chars
30
37
  def initialize(options)
31
38
  @libdir ||= File.dirname(__FILE__)
32
39
  options.merge!(default_fonts(options)) do |_, old, new|
@@ -46,6 +53,10 @@ module IsoDoc
46
53
  @wordcoverpage = options[:wordcoverpage]
47
54
  @htmlintropage = options[:htmlintropage]
48
55
  @wordintropage = options[:wordintropage]
56
+ @normalfontsize = options[:normalfontsize]
57
+ @smallerfontsize = options[:smallerfontsize]
58
+ @monospacefontsize = options[:monospacefontsize]
59
+ @footnotefontsize = options[:footnotefontsize]
49
60
  @scripts = options[:scripts]
50
61
  @scripts_pdf = options[:scripts_pdf]
51
62
  @i18nyaml = options[:i18nyaml]
@@ -80,62 +91,10 @@ module IsoDoc
80
91
  @fn_bookmarks = {}
81
92
  end
82
93
 
83
- # Check if already compiled version(.css) exists,
84
- # if not, return original scss file. During release
85
- # we compile scss into css files in order to not depend on scss
86
- def precompiled_style_or_original(stylesheet_path)
87
- # Already have compiled stylesheet, use it
88
- return stylesheet_path if stylesheet_path.nil? ||
89
- File.extname(stylesheet_path) == '.css'
90
-
91
- basename = File.basename(stylesheet_path, '.*')
92
- compiled_path = File.join(File.dirname(stylesheet_path),
93
- "#{basename}.css")
94
- return stylesheet_path unless File.file?(compiled_path)
95
-
96
- compiled_path
97
- end
98
-
99
- # run this after @meta is populated
100
- def populate_css
101
- @htmlstylesheet = generate_css(@htmlstylesheet_name, true)
102
- @wordstylesheet = generate_css(@wordstylesheet_name, false)
103
- @standardstylesheet = generate_css(@standardstylesheet_name, false)
104
- end
105
-
106
94
  def tmpimagedir_suffix
107
95
  '_images'
108
96
  end
109
97
 
110
- def default_fonts(_options)
111
- {
112
- bodyfont: 'Arial',
113
- headerfont: 'Arial',
114
- monospacefont: 'Courier'
115
- }
116
- end
117
-
118
- # none for this parent gem, but will be populated in child gems
119
- # which have access to stylesheets &c
120
- def default_file_locations(_options)
121
- {}
122
- end
123
-
124
- def fonts_options
125
- {
126
- 'bodyfont' => options[:bodyfont] || 'Arial',
127
- 'headerfont' => options[:headerfont] || 'Arial',
128
- 'monospacefont' => options[:monospacefont] || 'Courier'
129
- }
130
- end
131
-
132
- def scss_fontheader
133
- b = options[:bodyfont] || 'Arial'
134
- h = options[:headerfont] || 'Arial'
135
- m = options[:monospacefont] || 'Courier'
136
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
137
- end
138
-
139
98
  def html_doc_path(*file)
140
99
  file.each do |f|
141
100
  ret = File.join(@libdir, File.join('html', f))
@@ -144,37 +103,6 @@ module IsoDoc
144
103
  nil
145
104
  end
146
105
 
147
- def convert_scss(filename, stylesheet)
148
- require 'sassc'
149
- require 'isodoc/sassc_importer'
150
-
151
- [File.join(Gem.loaded_specs['isodoc'].full_gem_path,
152
- 'lib', 'isodoc'),
153
- File.dirname(filename)].each do |name|
154
- SassC.load_paths << name
155
- end
156
- SassC::Engine.new(scss_fontheader + stylesheet, syntax: :scss,
157
- importer: SasscImporter)
158
- .render
159
- end
160
-
161
- def generate_css(filename, stripwordcss)
162
- return nil if filename.nil?
163
-
164
- filename = precompiled_style_or_original(filename)
165
- stylesheet = File.read(filename, encoding: 'UTF-8')
166
- stylesheet = populate_template(stylesheet, :word)
167
- stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, '\\1') if stripwordcss
168
- if File.extname(filename) == '.scss'
169
- stylesheet = convert_scss(filename, stylesheet)
170
- end
171
- Tempfile.open([File.basename(filename, '.*'), 'css'],
172
- encoding: 'utf-8') do |f|
173
- f.write(stylesheet)
174
- f
175
- end
176
- end
177
-
178
106
  def convert1(docxml, filename, dir)
179
107
  @xrefs.parse docxml
180
108
  noko do |xml|
@@ -229,7 +157,7 @@ module IsoDoc
229
157
  FileUtils.rm_rf dir
230
158
  end
231
159
 
232
- def middle_clause
160
+ def middle_clause(docxml = nil)
233
161
  "//clause[parent::sections][not(@type = 'scope')]"\
234
162
  '[not(descendant::terms)]'
235
163
  end
@@ -0,0 +1,95 @@
1
+ module IsoDoc
2
+ class Convert < ::IsoDoc::Common
3
+ # Check if already compiled version(.css) exists,
4
+ # if not, return original scss file. During release
5
+ # we compile scss into css files in order to not depend on scss
6
+ def precompiled_style_or_original(stylesheet_path)
7
+ # Already have compiled stylesheet, use it
8
+ return stylesheet_path if stylesheet_path.nil? ||
9
+ File.extname(stylesheet_path) == '.css'
10
+ basename = File.basename(stylesheet_path, '.*')
11
+ compiled_path = File.join(File.dirname(stylesheet_path),
12
+ "#{basename}.css")
13
+ return stylesheet_path unless File.file?(compiled_path)
14
+ compiled_path
15
+ end
16
+
17
+ # run this after @meta is populated
18
+ def populate_css
19
+ @htmlstylesheet = generate_css(@htmlstylesheet_name, true)
20
+ @wordstylesheet = generate_css(@wordstylesheet_name, false)
21
+ @standardstylesheet = generate_css(@standardstylesheet_name, false)
22
+ end
23
+
24
+ def default_fonts(_options)
25
+ {
26
+ bodyfont: 'Arial',
27
+ headerfont: 'Arial',
28
+ monospacefont: 'Courier',
29
+ }
30
+ end
31
+
32
+ # none for this parent gem, but will be populated in child gems
33
+ # which have access to stylesheets &c
34
+ def default_file_locations(_options)
35
+ {}
36
+ end
37
+
38
+ def fonts_options
39
+ {
40
+ 'bodyfont' => options[:bodyfont] || 'Arial',
41
+ 'headerfont' => options[:headerfont] || 'Arial',
42
+ 'monospacefont' => options[:monospacefont] || 'Courier',
43
+ "normalfontsize" => options[:normalfontsize],
44
+ "monospacefontsize" => options[:monospacefontsize],
45
+ "smallerfontsize" => options[:smallerfontsize],
46
+ "footnotefontsize" => options[:footnotefontsize]
47
+ }
48
+ end
49
+
50
+ def scss_fontheader(is_html_css)
51
+ b = options[:bodyfont] || 'Arial'
52
+ h = options[:headerfont] || 'Arial'
53
+ m = options[:monospacefont] || 'Courier'
54
+ ns = options[:normalfontsize] || (is_html_css ? "1.0em" : '12.0pt')
55
+ ms = options[:monospacefontsize] || (is_html_css ? "0.8em" : '11.0pt')
56
+ ss = options[:smallerfontsize] || (is_html_css ? "0.9em" : '10.0pt')
57
+ fs = options[:footnotefontsize] || (is_html_css ? "0.9em" : '9.0pt')
58
+ "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"\
59
+ "$normalfontsize: #{ns};\n$monospacefontsize: #{ms};\n"\
60
+ "$smallerfontsize: #{ss};\n$footnotefontsize: #{fs};\n"
61
+ end
62
+
63
+ def convert_scss(filename, stylesheet, stripwordcss)
64
+ require 'sassc'
65
+ require 'isodoc/sassc_importer'
66
+
67
+ [File.join(Gem.loaded_specs['isodoc'].full_gem_path,
68
+ 'lib', 'isodoc'),
69
+ File.dirname(filename)].each do |name|
70
+ SassC.load_paths << name
71
+ end
72
+ SassC::Engine.new(scss_fontheader(stripwordcss) + stylesheet,
73
+ syntax: :scss, importer: SasscImporter)
74
+ .render
75
+ end
76
+
77
+ # stripwordcss if HTML stylesheet, !stripwordcss if DOC stylesheet
78
+ def generate_css(filename, stripwordcss)
79
+ return nil if filename.nil?
80
+
81
+ filename = precompiled_style_or_original(filename)
82
+ stylesheet = File.read(filename, encoding: 'UTF-8')
83
+ stylesheet = populate_template(stylesheet, :word)
84
+ stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, '\\1') if stripwordcss
85
+ if File.extname(filename) == '.scss'
86
+ stylesheet = convert_scss(filename, stylesheet, stripwordcss)
87
+ end
88
+ Tempfile.open([File.basename(filename, '.*'), 'css'],
89
+ encoding: 'utf-8') do |f|
90
+ f.write(stylesheet)
91
+ f
92
+ end
93
+ end
94
+ end
95
+ end
@@ -23,7 +23,10 @@ module IsoDoc::Function
23
23
  def index_parse(node, out)
24
24
  end
25
25
 
26
- def bookmark_parse(node, out)
26
+ def index_xref_parse(node, out)
27
+ end
28
+
29
+ def bookmark_parse(node, out)
27
30
  out.a **attr_code(id: node["id"])
28
31
  end
29
32
 
@@ -68,5 +71,11 @@ module IsoDoc::Function
68
71
  node.children.each { |n| parse(n, e) }
69
72
  end
70
73
  end
74
+
75
+ def underline_parse(node, out)
76
+ out.u do |e|
77
+ node.children.each { |n| parse(n, e) }
78
+ end
79
+ end
71
80
  end
72
81
  end