asciidoctor-latex 1.5.0.dev → 1.5.0.1.dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +118 -122
  3. data/data/extras.css +6 -0
  4. data/{try-out → examples}/README.adoc +8 -4
  5. data/examples/box.adoc +16 -0
  6. data/examples/chem.adoc +17 -0
  7. data/{try-out → examples}/click.adoc +0 -0
  8. data/{try-out → examples}/code.adoc +0 -0
  9. data/{try-out → examples}/env.adoc +0 -0
  10. data/examples/eq-alignment.adoc +5 -0
  11. data/examples/eq-block.adoc +60 -0
  12. data/{try-out → examples}/eq-latex.adoc +0 -0
  13. data/{try-out → examples}/eq-stem.adoc +0 -0
  14. data/{try-out → examples}/eqno-latex.adoc +0 -0
  15. data/{try-out → examples}/math_article.adoc +0 -0
  16. data/{try-out → examples}/pyth-stem.adoc +0 -0
  17. data/{try-out → examples}/theorem-latex.adoc +0 -0
  18. data/{try-out → examples}/xref-equations.adoc +2 -1
  19. data/lib/asciidoctor/latex/click_block.rb +0 -2
  20. data/lib/asciidoctor/latex/converter.rb +90 -77
  21. data/lib/asciidoctor/latex/environment_block.rb +44 -26
  22. data/lib/asciidoctor/latex/prepend_processor.rb +1 -1
  23. data/lib/asciidoctor/latex/preprocess.rb +0 -8
  24. data/lib/asciidoctor/latex/tex_preprocessor.rb +2 -2
  25. data/lib/asciidoctor/latex/version.rb +1 -1
  26. data/manual.adoc +2 -2
  27. data/test/examples/adoc/env.adoc +1 -9
  28. data/test/examples/adoc/eq.adoc +1 -1
  29. data/test/examples/adoc/zero.adoc +2 -0
  30. data/test/examples/asciidoc-html/env.adoc +103 -0
  31. data/test/examples/asciidoc-html/equations.adoc +15 -0
  32. data/test/examples/tex/env.tex +1 -127
  33. data/test/examples/tex/eq.tex +2 -125
  34. data/test/examples/tex/zero.tex +2 -120
  35. metadata +39 -21
  36. data/rake/cacert.pem +0 -3894
  37. data/rake/jdk_helper.rb +0 -105
  38. data/rake/tar-licence +0 -19
  39. data/rake/tar.rb +0 -38
  40. data/test/examples/asciidoc-html/block_open.adoc +0 -17
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -25,4 +25,5 @@ Proin ac blandit magna, vel ultrices magna. Suspendisse non ligula lobortis, fau
25
25
 
26
26
  The first section is <<This is a test>>
27
27
 
28
- The professor harrumphed and said: I repeat, equation <<qq>> is very important.
28
+ The professor harrumphed and said: I repeat,
29
+ equation (<<qq>>) is very important.
@@ -36,8 +36,6 @@ module Asciidoctor::LaTeX
36
36
 
37
37
  def process parent, reader, attrs
38
38
 
39
- warn "env: attributes = #{attrs}".yellow if $VERBOSE
40
-
41
39
  click_name = attrs["role"]
42
40
  original_title = attrs['title']
43
41
 
@@ -157,90 +157,27 @@ module Asciidoctor::LaTeX
157
157
 
158
158
  def info node
159
159
 
160
- attrs = node.attributes
161
-
162
- warn "\n HTMLConverter, node: #{node.node_name}".red
163
- # warn " title: #{attrs['title']}".cyan
164
- # warn " role: #{attrs['role']}".cyan
165
- # warn " options: #{attrs['options']}".cyan
160
+ warn "\n HTMLConverter, node: #{node.node_name}".red if $VERBOSE
166
161
 
167
162
  end
168
163
 
169
164
  def environment node
170
165
 
171
- # info node if $VERBOSE
172
- options = node.attributes['options']
173
166
  attrs = node.attributes
174
167
 
175
- warn "env role = #{attrs['role']}".yellow if $VERBOSE
176
-
177
- if attrs['role'] == 'equation'
178
- node.title = nil
179
- number_part = '<td style="text-align:right">' + "(#{node.caption}) </td>"
180
- number_part = ["+++ #{number_part} +++"]
181
- equation_part = ['+++<td style="width:100%";>+++'] + ['\\['] + node.lines + ['\\]'] + ['+++</td>+++']
182
- table_style='style="width:100%; border-collapse:collapse;border:0" class="zero" '
183
- row_style='style="border-collapse: collapse; border:0; font-size: 12pt; "'
184
- if options['numbered']
185
- node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + number_part + [TABLE_ROW_END]
168
+ case attrs['role']
169
+ when 'box'
170
+ handle_null(node)
171
+ when 'equation'
172
+ handle_equation(node)
173
+ when 'equationalign'
174
+ handle_equation_align(node)
175
+ when 'chem'
176
+ handle_chem(node)
177
+ when 'jsxgraph'
178
+ handle_jsxgraph(node)
186
179
  else
187
- node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + [TABLE_ROW_END]
188
- end
189
- elsif attrs['role'] == 'equationalign'
190
- warn "execting env role = #{attrs['role']}".yellow if $VERBOSE
191
- node.title = nil
192
- number_part = '<td style="text-align:right">' + "(#{node.caption}) </td>"
193
- number_part = ["+++ #{number_part} +++"]
194
- equation_part = ['+++<td style="width:100%";>+++'] + ['\\[\\begin{split}'] + node.lines + ['\\end{split}\\]'] + ['+++</td>+++']
195
- table_style='style="width:100%; border-collapse:collapse;border:0" class="zero" '
196
- row_style='style="border-collapse: collapse; border:0; font-size: 12pt; "'
197
- if options['numbered']
198
- node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + number_part + [TABLE_ROW_END]
199
- else
200
- node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + [TABLE_ROW_END]
201
- end
202
- elsif node.attributes['role'] == 'chem'
203
- node.title = nil
204
- number_part = '<td style="text-align:right">' + "(#{node.caption}) </td>"
205
- number_part = ["+++ #{number_part} +++"]
206
- equation_part = ['+++<td style="width:100%;">+++'] + [' \\[\\ce{' + node.lines[0] + '}\\] '] + ['+++</td>+++']
207
- table_style='class="zero" style="width:100%; border-collapse:collapse; border:0"'
208
- row_style='class="zero" style="border-collapse: collapse; border:0; font-size: 10pt; "'
209
- node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + number_part +['+++</tr></table>+++']
210
- elsif attrs['role'] == 'jsxgraph'
211
- if attrs['box'] == nil
212
- attrs['box'] = 'box'
213
- end
214
- if attrs['width'] == nil
215
- attrs['width'] = 450
216
- end
217
- if attrs['height'] == nil
218
- attrs['height'] = 450
219
- end
220
- warn "jxxgraph attributes: #{attrs}".cyan if $VERBOSE
221
- line_array = ["\n+++\n"]
222
- # line_array += ["<link rel='stylesheet' type='text/css' href='jsxgraph.css' />"]
223
-
224
- line_array += ["<link rel='stylesheet' type='text/css' href='http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css' />"]
225
- line_array += ['<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jsxgraph/0.99.3/jsxgraphcore.js"></script>']
226
- line_array += ["<script src='http://jsxgraph.uni-bayreuth.de/distrib/GeonextReader.js' type='text/javascript'></script>"]
227
- # line_array += ['<div id="box" class="jxgbox" style="width:500px; height:500px;"></div>']
228
- line_array += ["<div id='#{attrs['box']}' class='jxgbox' style='width:" + "#{attrs['width']}" + "px; height:" + "#{attrs['height']}" +"px;'></div>"]
229
- line_array += ['<script type="text/javascript">']
230
-
231
- # line_array += ["<link rel='stylesheet' type='text/css' href='http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css' />"]
232
- # line_array += ["<script src='http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js' type='text/javascript'></script>"]
233
- # line_array += ["<script src='http://jsxgraph.uni-bayreuth.de/distrib/GeonextReader.js' type='text/javascript'></script>"]
234
- # line_array += ["<div id='jxgbox' class='jxgbox' style='width:500px; height:500px;'></div>"]
235
- # line_array += ["<script type='text/javascript'>"]
236
-
237
- line_array += node.lines
238
- line_array += ['</script>']
239
- line_array += ['<br/>']
240
- line_array += ["\n+++\n"]
241
- node.lines = line_array
242
- else
243
- node.lines = [ENV_CSS] + node.lines + [DIV_END]
180
+ handle_default(node)
244
181
  end
245
182
 
246
183
  node.attributes['roles'] = (node.roles + ['environment']) * ' '
@@ -249,7 +186,6 @@ module Asciidoctor::LaTeX
249
186
 
250
187
  def click node
251
188
 
252
- # info node if $VERBOSE
253
189
  node.lines = [ENV_CSS] + node.lines + [DIV_END]
254
190
  node.attributes['roles'] = (node.roles + ['click']) * ' '
255
191
  self.open node
@@ -290,6 +226,83 @@ module Asciidoctor::LaTeX
290
226
  output
291
227
  end
292
228
 
229
+ def handle_equation(node)
230
+ options = node.attributes['options']
231
+ node.title = nil
232
+ number_part = '<td style="text-align:right">' + "(#{node.caption}) </td>"
233
+ number_part = ["+++ #{number_part} +++"]
234
+ equation_part = ['+++<td style="width:100%";>+++'] + ['\\['] + node.lines + ['\\]'] + ['+++</td>+++']
235
+ table_style='style="width:100%; border-collapse:collapse;border:0" class="zero" '
236
+ row_style='style="border-collapse: collapse; border:0; font-size: 12pt; "'
237
+ if options['numbered']
238
+ node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + number_part + [TABLE_ROW_END]
239
+ else
240
+ node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + [TABLE_ROW_END]
241
+ end
242
+ end
243
+
244
+ def handle_equation_align(node)
245
+ options = node.attributes['options']
246
+ attrs = node.attributes
247
+ node.title = nil
248
+ number_part = '<td style="text-align:right">' + "(#{node.caption}) </td>"
249
+ number_part = ["+++ #{number_part} +++"]
250
+ equation_part = ['+++<td style="width:100%";>+++'] + ['\\[\\begin{split}'] + node.lines + ['\\end{split}\\]'] + ['+++</td>+++']
251
+ table_style='style="width:100%; border-collapse:collapse;border:0" class="zero" '
252
+ row_style='style="border-collapse: collapse; border:0; font-size: 12pt; "'
253
+ if options['numbered']
254
+ node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + number_part + [TABLE_ROW_END]
255
+ else
256
+ node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + [TABLE_ROW_END]
257
+ end
258
+ end
259
+
260
+ def handle_chem(node)
261
+ node.title = nil
262
+ number_part = '<td style="text-align:right">' + "(#{node.caption}) </td>"
263
+ number_part = ["+++ #{number_part} +++"]
264
+ equation_part = ['+++<td style="width:100%;">+++'] + [' \\[\\ce{' + node.lines[0] + '}\\] '] + ['+++</td>+++']
265
+ table_style='class="zero" style="width:100%; border-collapse:collapse; border:0"'
266
+ row_style='class="zero" style="border-collapse: collapse; border:0; font-size: 10pt; "'
267
+ node.lines = ["+++<table #{table_style}><tr #{row_style}>+++"] + equation_part + number_part +['+++</tr></table>+++']
268
+ end
269
+
270
+ def handle_jsxgraph(node)
271
+ attrs = node.attributes
272
+ if attrs['box'] == nil
273
+ attrs['box'] = 'box'
274
+ end
275
+ if attrs['width'] == nil
276
+ attrs['width'] = 450
277
+ end
278
+ if attrs['height'] == nil
279
+ attrs['height'] = 450
280
+ end
281
+ line_array = ["\n+++\n"]
282
+ # line_array += ["<link rel='stylesheet' type='text/css' href='jsxgraph.css' />"]
283
+
284
+ line_array += ["<link rel='stylesheet' type='text/css' href='http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css' />"]
285
+ line_array += ['<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jsxgraph/0.99.3/jsxgraphcore.js"></script>']
286
+ line_array += ["<script src='http://jsxgraph.uni-bayreuth.de/distrib/GeonextReader.js' type='text/javascript'></script>"]
287
+ # line_array += ['<div id="box" class="jxgbox" style="width:500px; height:500px;"></div>']
288
+ line_array += ["<div id='#{attrs['box']}' class='jxgbox' style='width:" + "#{attrs['width']}" + "px; height:" + "#{attrs['height']}" +"px;'></div>"]
289
+ line_array += ['<script type="text/javascript">']
290
+
291
+ line_array += node.lines
292
+ line_array += ['</script>']
293
+ line_array += ['<br/>']
294
+ line_array += ["\n+++\n"]
295
+ node.lines = line_array
296
+ end
297
+
298
+ def handle_null(node)
299
+
300
+ end
301
+
302
+ def handle_default(node)
303
+ node.lines = [ENV_CSS] + node.lines + [DIV_END]
304
+ end
305
+
293
306
  end
294
307
 
295
308
 
@@ -95,16 +95,8 @@ module Asciidoctor::LaTeX
95
95
 
96
96
  def process parent, reader, attrs
97
97
 
98
- warn "env: attributes = #{attrs}".yellow if $VERBOSE
99
-
100
- # Get orginal title if there is one
101
- if attrs['title']
102
- original_title = attrs['title']
103
- attrs['original_title'] = original_title
104
- else
105
- original_title = nil
106
- end
107
-
98
+ original_title = attrs['title']
99
+ attrs['original_title'] = attrs['title']
108
100
 
109
101
  # Ensure that role is defined
110
102
  if attrs['role'] == nil
@@ -118,15 +110,19 @@ module Asciidoctor::LaTeX
118
110
  attrs['role'] = attrs['role'].gsub(/\\/, '')
119
111
  end
120
112
 
121
- # Determine whether this is a numbered block
122
- # FIXME: what if there are several options?
123
- if attrs['options'].nil?
124
- attrs['options'] = 'numbered'
125
- elsif !(attrs['options'].include? 'no-number')
126
- # attrs['options'] = 'numbered'
113
+ # Determine whether the block is numbered
114
+ # Use the option set if present (numbered, no+_number) otherwise
115
+ # use a default value, e.g. 'box' is not numbered, the others are numbered
116
+ if !(attrs['options'] =~ /no_number|numbered/)
117
+ if %w(box).include? role
118
+ attrs['options'] = 'no_number'
119
+ else
120
+ attrs['options'] = 'numbered'
121
+ end
127
122
  end
128
123
 
129
124
 
125
+ # Adjust title according to environment name
130
126
  env_name = role # roles.first # FIXME: roles.first is probably best
131
127
  if %w(equation equationalign chem).include? role
132
128
  attrs['title'] = env_name
@@ -134,51 +130,73 @@ module Asciidoctor::LaTeX
134
130
  attrs['title'] = 'Listing'
135
131
  elsif role == 'jsxgraph'
136
132
  attrs['title'] = 'JSXGraph'
133
+ elsif role == 'box'
134
+ attrs['title'] = ''
137
135
  else
138
136
  attrs['title'] = env_name.capitalize
139
137
  end
140
138
  env_title = attrs['title']
141
139
 
142
140
 
141
+ # Creat the block
143
142
  if attrs['role'] == 'code'
144
143
  block = create_block parent, :listing, reader.lines, attrs
145
144
  else
146
145
  block = create_block parent, :environment, reader.lines, attrs
147
146
  end
148
147
 
149
- warn "document.references".blue + " #{parent.document.references}".cyan if $VERBOSE
150
- warn "attrs['role'] = #{attrs['role']} and role = #{role}".red if $VERBOSE
151
- warn "id".red + " = #{attrs['id']}".yellow if $VERBOSE
152
-
153
- if attrs['options']['numbered']
148
+ if attrs['options'] =~ /numbered/
149
+ # THE NUMBERED OPTION
150
+ # Use same prefix for cross referencing for the
151
+ # equation_align environment as for the equation
152
+ # environment so as not to have separate numbering
153
+ # sequences
154
154
  if env_name == 'equationalign'
155
155
  env_ref_prefix = 'equation'
156
156
  else
157
157
  env_ref_prefix = env_name
158
158
  end
159
+ # Define caption_num so that we can make references
160
+ # that display as "(17)", for example
161
+ # This is where we can set the caption number by hand
162
+ # once I figure out how to do so.
159
163
  caption_num = parent.document.counter_increment("#{env_ref_prefix}-number", block)
160
164
  attrs['caption-num'] = caption_num
161
165
  caption = "#{caption_num}"
166
+ # Set the title, e.g., "Theorem 3: Pythagoras" or just "Theorem 3"
167
+ # depending on whether the user sets a title, .e.g, ".Pythgoras"
168
+ # in the line preceding "[env.theorem]"
162
169
  if original_title
163
170
  attrs['title'] = "#{env_title} #{caption_num}: #{original_title}"
164
171
  else
165
172
  attrs['title'] = "#{env_title} #{caption_num}."
166
173
  end
167
- warn "eb: ".blue + "caption: #{caption}, title = #{attrs['title']}".magenta if $VERBOSE
168
174
  else
169
- attrs['title'] = "#{env_title}"
170
- warn "eb: ".blue + "caption: #{caption}, title = #{attrs['title']}".magenta if $VERBOSE
175
+ # THE NON-NUMBERED OPTION
176
+ # Set the title, e.g., "Pythagoras" or just "Theorem"
177
+ # depending on whether the user sets a title, .e.g, ".Pythgoras"
178
+ # in the line preceding "[env.theorem]"
179
+ # FIXME: this code is a tad spaghetti-like
180
+ if original_title
181
+ if %w(box).include? role
182
+ attrs['title'] = "#{original_title}"
183
+ else
184
+ attrs['title'] = "#{env_title}: #{original_title}"
185
+ end
186
+ else
187
+ attrs['title'] = "#{env_title}"
188
+ end
171
189
  end
172
190
 
173
191
  if attrs['role'] == 'code'
174
192
  caption = nil
175
193
  end
176
194
 
177
- warn "attributes are now #{attrs}" if $VERBOSE
178
-
179
195
  block.assign_caption caption
180
196
  if %w(equation equationalign chem).include? role
181
197
  block.title = "#{caption_num}"
198
+ elsif %w(box).include? role
199
+ block.title = attrs['title']
182
200
  else
183
201
  block.title = attrs['title']
184
202
  end
@@ -14,7 +14,7 @@ module Asciidoctor::LaTeX
14
14
 
15
15
  def process document, reader
16
16
 
17
- warn "Entering ClickStyleInsert".magenta
17
+ warn "Entering ClickStyleInsert".magenta if $VERBOSE
18
18
 
19
19
  @@line_array = []
20
20
 
@@ -22,16 +22,8 @@ output_file = base_name + "out"
22
22
 
23
23
  input = File.open(input_file, 'r') { |f| f.read }
24
24
 
25
- puts "input:"
26
- puts "-----------------"
27
- puts input
28
- puts "-----------------\n\n"
29
25
 
30
26
  output = Asciidoctor::LaTeX::TeXBlock.process_environments input
31
27
 
32
- puts "output:"
33
- puts "-----------------"
34
- puts output
35
- puts "-----------------\n\n"
36
28
 
37
29
  # File.open(output_file, 'w') {|f| f.write(output) }
@@ -49,10 +49,10 @@ module Asciidoctor::LaTeX
49
49
  if line.include? '$'
50
50
  line = line.gsub TEX_DOLLAR_RX, TEX_DOLLAR_SUB2
51
51
  end
52
- if line.include? '\\['
52
+ if line.include? '^\\['
53
53
  line = line.gsub '\\[', '+\\['
54
54
  end
55
- if line.include? '\\]'
55
+ if line.include? '^\\]'
56
56
  line = line.gsub '\\]', '\\]+'
57
57
  end
58
58
  line
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module LaTeX
3
- VERSION = '1.5.0.dev'
3
+ VERSION = '1.5.0.1.dev'
4
4
  end
5
5
  end
data/manual.adoc CHANGED
@@ -17,7 +17,7 @@ As a demonstration of the current state of this
17
17
  project, the file you are looking at, `manual.adoc`,
18
18
  can be rendered into HTML by
19
19
  ----
20
- $ asciidoctor manual.adoc
20
+ $ asciidoctor-latex -b html manual.adoc
21
21
  ----
22
22
  or can be rendered as a LaTeX file via
23
23
  ----
@@ -25,7 +25,7 @@ or can be rendered as a LaTeX file via
25
25
  # => manual.tex
26
26
  ----
27
27
  The `.tex` file can in turn be rendred into pdf via
28
- `pdflatex`.
28
+ `pdflatex` or `xelatex`. We recommend the latter.
29
29
 
30
30
 
31
31
  Mathematical text in Asciidoc can be written as
@@ -1,4 +1,4 @@
1
- == Env test
1
+ //.env
2
2
 
3
3
  [env.theorem]
4
4
  --
@@ -6,11 +6,3 @@ The equation $a^2 + b^2 = c^2$
6
6
  has infinitely many non-proportional
7
7
  integer solutions.
8
8
  --
9
-
10
- [env.theorem]
11
- --
12
- The equation $a^n + b^n = c^n$,
13
- for $n > 2$, has only trivial
14
- integer solutions, where one of
15
- the variables is zero.
16
- --
@@ -1,4 +1,4 @@
1
- == Equation test
1
+ //.eq
2
2
 
3
3
  The Pythagorean theorem, $a^2 + b^2 = c^2$,
4
4
  relates the hypotenuse to the altitude