asciidoctor-latex 1.5.0.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 (89) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.adoc +22 -0
  3. data/README.adoc +213 -0
  4. data/Rakefile +55 -0
  5. data/bin/asciidoctor-latex +22 -0
  6. data/data/asciidoc_tex_macros.tex +42 -0
  7. data/data/preamble_article.tex +45 -0
  8. data/data/preamble_book.tex +44 -0
  9. data/lib/asciidoctor-latex.rb +1 -0
  10. data/lib/asciidoctor/latex.rb +8 -0
  11. data/lib/asciidoctor/latex/chem.rb +24 -0
  12. data/lib/asciidoctor/latex/click_block.rb +121 -0
  13. data/lib/asciidoctor/latex/converter.rb +358 -0
  14. data/lib/asciidoctor/latex/core_ext/colored_string.rb +35 -0
  15. data/lib/asciidoctor/latex/dollar.rb +28 -0
  16. data/lib/asciidoctor/latex/ent_to_uni.rb +17 -0
  17. data/lib/asciidoctor/latex/environment_block.rb +190 -0
  18. data/lib/asciidoctor/latex/inject_html.rb +49 -0
  19. data/lib/asciidoctor/latex/inline_macros.rb +20 -0
  20. data/lib/asciidoctor/latex/macro_insert.rb +49 -0
  21. data/lib/asciidoctor/latex/node_processors.rb +695 -0
  22. data/lib/asciidoctor/latex/prepend_processor.rb +36 -0
  23. data/lib/asciidoctor/latex/preprocess.rb +37 -0
  24. data/lib/asciidoctor/latex/tex_block.rb +108 -0
  25. data/lib/asciidoctor/latex/tex_postprocessor.rb +44 -0
  26. data/lib/asciidoctor/latex/tex_preprocessor.rb +65 -0
  27. data/lib/asciidoctor/latex/version.rb +5 -0
  28. data/manual.adoc +285 -0
  29. data/rake/cacert.pem +3894 -0
  30. data/rake/jdk_helper.rb +105 -0
  31. data/rake/tar-licence +19 -0
  32. data/rake/tar.rb +38 -0
  33. data/rspec/README.adoc +45 -0
  34. data/rspec/a.rb +79 -0
  35. data/rspec/b.rb +111 -0
  36. data/rspec/c.rb +121 -0
  37. data/rspec/data/tex1 +65 -0
  38. data/rspec/data/tex2 +5 -0
  39. data/rspec/data/tex2.expect +5 -0
  40. data/rspec/transform.rb +36 -0
  41. data/spec/README.adoc +45 -0
  42. data/spec/a.rb +79 -0
  43. data/spec/b.rb +111 -0
  44. data/spec/c.rb +121 -0
  45. data/spec/data/foo +1 -0
  46. data/spec/data/lorem +1 -0
  47. data/spec/data/tex1 +65 -0
  48. data/spec/data/tex2 +5 -0
  49. data/spec/data/tex2.expect +5 -0
  50. data/spec/transform.rb +36 -0
  51. data/test/examples/adoc/env.adoc +16 -0
  52. data/test/examples/adoc/eq.adoc +12 -0
  53. data/test/examples/adoc/zero.adoc +3 -0
  54. data/test/examples/asciidoc-html/block_open.adoc +17 -0
  55. data/test/examples/tex/env.tex +132 -0
  56. data/test/examples/tex/eq.tex +132 -0
  57. data/test/examples/tex/zero.tex +121 -0
  58. data/test/html_test.rb +8 -0
  59. data/test/latex_test.rb +8 -0
  60. data/test/test_helper.rb +4 -0
  61. data/test_jc/admonition.adoc +4 -0
  62. data/test_jc/click.adoc +7 -0
  63. data/test_jc/env.adoc +31 -0
  64. data/test_jc/example.adoc +17 -0
  65. data/test_jc/floating_title.adoc +15 -0
  66. data/test_jc/image.adoc +84 -0
  67. data/test_jc/images/frog.jpg +0 -0
  68. data/test_jc/images/red_frog.jpeg +0 -0
  69. data/test_jc/images/yellow_frog.jpeg +0 -0
  70. data/test_jc/listing.adoc +9 -0
  71. data/test_jc/lists.adoc +20 -0
  72. data/test_jc/math.adoc +10 -0
  73. data/test_jc/preamble.adoc +14 -0
  74. data/test_jc/section-numbered.adoc +9 -0
  75. data/test_jc/section.adoc +7 -0
  76. data/test_jc/sidebar.adoc +61 -0
  77. data/test_jc/verse.adoc +15 -0
  78. data/try-out/README.adoc +348 -0
  79. data/try-out/click.adoc +108 -0
  80. data/try-out/code.adoc +122 -0
  81. data/try-out/env.adoc +139 -0
  82. data/try-out/eq-latex.adoc +37 -0
  83. data/try-out/eq-stem.adoc +41 -0
  84. data/try-out/eqno-latex.adoc +120 -0
  85. data/try-out/math_article.adoc +138 -0
  86. data/try-out/pyth-stem.adoc +52 -0
  87. data/try-out/theorem-latex.adoc +50 -0
  88. data/try-out/xref-equations.adoc +28 -0
  89. metadata +210 -0
@@ -0,0 +1 @@
1
+ require 'asciidoctor/latex'
@@ -0,0 +1,8 @@
1
+ module Asciidoctor
2
+ module LaTeX
3
+ DATA_DIR = File.expand_path '../../data', __dir__
4
+ end
5
+ end
6
+
7
+ require 'asciidoctor/latex/version'
8
+ require 'asciidoctor/latex/converter'
@@ -0,0 +1,24 @@
1
+
2
+
3
+ require 'asciidoctor'
4
+ require 'asciidoctor/extensions'
5
+
6
+ # Modify the default mathJax script to run mhchem instead
7
+ # of autonumbuering of equations -- which is taken care of
8
+ # by [env.equation], [env.equationalign]
9
+ #
10
+ # See http://www.noteshare.io/section/the-chem-environment
11
+ #
12
+ module Asciidoctor::LaTeX
13
+ # Map @@DOLLAR: to $
14
+ class Chem < Asciidoctor::Extensions::Postprocessor
15
+
16
+ def process document, output
17
+ output = output.gsub($tex_snippet, $chem_snippet)
18
+ end
19
+
20
+ end
21
+ end
22
+
23
+ $tex_snippet = 'TeX: { equationNumbers: { autoNumber: "none" } }'
24
+ $chem_snippet = 'TeX: { extensions: ["mhchem.js"] }'
@@ -0,0 +1,121 @@
1
+ # Test doc: work/click.adoc
2
+
3
+
4
+ # ClickBlock implements the construct
5
+ #
6
+ # [click.answer]
7
+ # --
8
+ # 73
9
+ # --
10
+ #
11
+ # See http://epsilon.my.noteshare.io/lessons/click-blocks-jc
12
+ #
13
+ # Documents containing click-blocks must be rendered with
14
+ #
15
+ # asciidoctor-latex -b html -a click_extras=include
16
+ #
17
+ require 'asciidoctor'
18
+ require 'asciidoctor/extensions'
19
+ require 'asciidoctor/latex/core_ext/colored_string'
20
+
21
+
22
+ module Asciidoctor::LaTeX
23
+ class ClickBlock < Asciidoctor::Extensions::BlockProcessor
24
+
25
+ use_dsl
26
+ # ^^^ don't know what this is. Could you explain?
27
+
28
+ named :click
29
+ on_context :open
30
+ # parse_context_as :complex
31
+ # ^^^ The above line gave me an error. I'm not sure what do to with it.
32
+
33
+ # Hash to count the number of times each environment is encountered
34
+ # Global variables again. Is there a better way?
35
+ $counter = {}
36
+
37
+ def process parent, reader, attrs
38
+
39
+ warn "env: attributes = #{attrs}".yellow if $VERBOSE
40
+
41
+ click_name = attrs["role"]
42
+ original_title = attrs['title']
43
+
44
+ # Ensure that role is defined
45
+ original_role = attrs['role']
46
+ if attrs['role'] == nil
47
+ role = 'item'
48
+ else
49
+ role = attrs['role']
50
+ end
51
+
52
+ # Use the value of the role to determine
53
+ # whether this is a numbered block
54
+ numbered = false
55
+ if attrs['options'] and attrs['options'].include? 'number'
56
+ numbered = true
57
+ end
58
+
59
+
60
+ # If the block is numbered, update the counter
61
+ if numbered
62
+ env_name = role ############## 'click-'+role
63
+ if $counter[env_name] == nil
64
+ $counter[env_name] = 1
65
+ else
66
+ $counter[env_name] += 1
67
+ end
68
+ end
69
+
70
+
71
+ # Set title
72
+ if role == 'code'
73
+ title = 'Listing'
74
+ else
75
+ title = role.capitalize
76
+ end
77
+ if numbered
78
+ title = title + ' ' + $counter[env_name].to_s
79
+ end
80
+ if attrs['title']
81
+ if numbered
82
+ title = title + '. ' + attrs['title'].capitalize
83
+ else
84
+ title = title + ': ' + attrs['title'].capitalize
85
+ end
86
+ end
87
+
88
+ if original_role == nil
89
+ title = original_title
90
+ end
91
+
92
+ if role != 'equation'
93
+ attrs['title'] = title
94
+ else
95
+ if numbered
96
+ attrs['equation_number'] = $counter[env_name].to_s
97
+ end
98
+ end
99
+
100
+
101
+ attrs['title'] = title
102
+
103
+
104
+ if attrs['role'] == 'code'
105
+ role = 'listing'
106
+ else
107
+ role = 'click'
108
+ end
109
+ attrs['role'] = 'click'
110
+
111
+ if role == 'listing'
112
+ create_block parent, :listing, reader.lines, attrs
113
+ else
114
+ create_block parent, :click, reader.lines, attrs
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+ end
121
+
@@ -0,0 +1,358 @@
1
+
2
+ #
3
+ # File: latex-converter.rb
4
+ # Author: J. Carlson (jxxcarlson@gmail.com)
5
+ # First commit: 9/26/2014
6
+ # Date: 2/20/1015
7
+ #
8
+ # OVERVIEW
9
+ #
10
+ # Asciidoctor-latex does two things:
11
+ #
12
+ # -- provides an HTML backend which adds latex-like features to asciidoctor
13
+ # asciidoc(tor) with these additional features will be called 'asciidoctor-latex'
14
+ #
15
+ # -- provides a converter from asciidoctor-latex to asciidoctor. This converter
16
+ # is 'usable' but has limited coverage of asciidoctor-latex
17
+ #
18
+ # See http://www.noteshare.io/section/asciidoctor-latex-manual-intro
19
+ # for a description (with examples) of asciidoctor-latex.
20
+ #
21
+ # INSTALLATION
22
+ #
23
+ # Run 'rake install' to install the asciidoctor-latex gem locally.
24
+ #
25
+ # USAGE (1: html)
26
+ #
27
+ # Run
28
+ #
29
+ # 'asciidoctor-latex -b html foo.adoc'
30
+ #
31
+ # to render an asciidoctor-latex document to html
32
+ #
33
+ # Some documents (those with 'click blocks', see http://www.noteshare.io/section/homework-problems)
34
+ # For these, run
35
+ #
36
+ # 'asciidoctor-latex -b html -a click_extras=include foo.adoc'
37
+ #
38
+ # In both cases the output is 'foo.html'
39
+ #
40
+ # USAGE (2: latex)
41
+ #
42
+ # Run
43
+ #
44
+ # 'asciidoctor-latex foo.adoc'
45
+ #
46
+ # to convert foo.adoc to foo.tex. This feature
47
+ # needs a lot of work.
48
+ #
49
+ # to convert foo.tex to the latex file foo.latex
50
+ # You can put files 'macros.tex' and 'preamble.tex' to
51
+ # replace the default preamble and set of macros.
52
+ # Define your own 'newEnvironments.tex' to use yours
53
+ # as opposed to the default definitons of environments
54
+ # in tex mapping to [tex.ENVIRNOMENT] in asciidoctor-latex.
55
+ #
56
+ # TECHNICAL NOTES
57
+ #
58
+ # This is a first step towards writing a LaTeX backend
59
+ # for Asciidoctor. It is based on the
60
+ # Dan Allen's demo-converter.rb. The "convert" method
61
+ # is unchanged, the methods "document node" and "section node"
62
+ # have been redefined, and several new methods have been added.
63
+ #
64
+ # The main work will be in identifying asciidoc elements
65
+ # that need to be transformed and adding a method for
66
+ # each such element. As noted below, the "warn" clause
67
+ # in the "convert" method is a useful tool for this task.
68
+ #
69
+ # Usage:
70
+ #
71
+ # $ asciidoctor -r ./latex-converter.rb -b latex test/sample1.adoc
72
+ #
73
+ # Comments
74
+ #
75
+ # 1. The "warn" clause in the converter code is quite useful.
76
+ # For example, you will discover in running the converter on
77
+ # "test/sample-1.adoc" that you have not implemented code for
78
+ # the "olist" node. Thus you can work through ever more complex
79
+ # examples to discover what you need to do to increase the coverage
80
+ # of the converter. Hackish and ad hoc, but a process nonetheless.
81
+ #
82
+ # 2. The converter simply passes on what it does not understand, e.g.,
83
+ # LaTeX, This is good. However, we will have to map constructs
84
+ # like"+\( a^2 = b^2 \)+" to $ a^2 + b^2 $, etc.
85
+ # This can be done at the preprocessor level.
86
+ #
87
+ # 3. In view of the preceding, we may need to chain a frontend
88
+ # (preprocessor) to the backend. In any case, the main work
89
+ # is in transforming Asciidoc elements to TeX elements.
90
+ # Other than the asciidoc -> tex mapping, the tex-converter
91
+ # does not need to understand tex.
92
+ #
93
+ # 4. Included in this repo are the files "test/sample1.adoc", "test/sample2.adoc",
94
+ # and "test/elliptic.adoc" which can be used to test the code
95
+ #
96
+ # 5. Beginning with version 0.0.2 we use a new dispatch mechanism
97
+ # which should permit one to better manage growth of the code
98
+ # as the coverage of the converter increases. Briefly, the
99
+ # main convert method, whose duty is to process nodes, looks
100
+ # at node.node_name, then makes the method call node.tex_process
101
+ # if the node_name is registered in NODE_TYPES. The method
102
+ # tex_process is defined by extending the various classes to
103
+ # which the node might belong, e.g., Asciidoctor::Block,
104
+ # Asciidoctor::Inline, etc. See the file "node_processor.rb",
105
+ # where these extensions are housed for the time being.
106
+ #
107
+ # If node.node_name is not found in NODE_TYPES, then
108
+ # a warning message is issued. We can use it as a clue
109
+ # to find what to do to handle this node. All the code
110
+ # in "node_processors.rb" to date was written using this
111
+ # hackish process.
112
+ #
113
+ #
114
+ # CURRENT STATUS
115
+ #
116
+ # The following constructs are processed
117
+ #
118
+ # * sections to a depth of five, e.g., == foo, === foobar, etc.
119
+ # * ordered and unordered lists, though nestings is untested and
120
+ # likely does not work.
121
+ # * *bold* and _italic_
122
+ # * hyperlinks like http://foo.com[Nerdy Stuff]
123
+ #
124
+
125
+ require 'asciidoctor'
126
+ require 'asciidoctor/converter/html5'
127
+ require 'asciidoctor/latex/inline_macros'
128
+ require 'asciidoctor/latex/core_ext/colored_string'
129
+ require 'asciidoctor/latex/click_block'
130
+ require 'asciidoctor/latex/inject_html'
131
+ require 'asciidoctor/latex/ent_to_uni'
132
+ require 'asciidoctor/latex/environment_block'
133
+ require 'asciidoctor/latex/node_processors'
134
+ require 'asciidoctor/latex/prepend_processor'
135
+ require 'asciidoctor/latex/macro_insert'
136
+ require 'asciidoctor/latex/tex_block'
137
+ require 'asciidoctor/latex/tex_preprocessor'
138
+ require 'asciidoctor/latex/dollar'
139
+ require 'asciidoctor/latex/tex_postprocessor'
140
+ require 'asciidoctor/latex/chem'
141
+
142
+
143
+
144
+ # require 'asciidoctor/latex/preamble_processor'
145
+
146
+ $VERBOSE = true
147
+
148
+
149
+ # code for Html5ConverterExtension & its insertion
150
+ # template by @mojavelinux
151
+ module Asciidoctor::LaTeX
152
+ module Html5ConverterExtensions
153
+
154
+ ENV_CSS = "+++<div style='line-height:1.5em;font-size:1.05em;font-style:oblique;margin-bottom:1.5em'>+++"
155
+ DIV_END = '+++</div>+++'
156
+ TABLE_ROW_END = '+++</tr></table>+++'
157
+
158
+ def info node
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
166
+
167
+ end
168
+
169
+ def environment node
170
+
171
+ # info node if $VERBOSE
172
+ options = node.attributes['options']
173
+ attrs = node.attributes
174
+
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]
186
+ 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]
244
+ end
245
+
246
+ node.attributes['roles'] = (node.roles + ['environment']) * ' '
247
+ self.open node
248
+ end
249
+
250
+ def click node
251
+
252
+ # info node if $VERBOSE
253
+ node.lines = [ENV_CSS] + node.lines + [DIV_END]
254
+ node.attributes['roles'] = (node.roles + ['click']) * ' '
255
+ self.open node
256
+ end
257
+
258
+ def inline_anchor node
259
+
260
+ case node.type.to_s
261
+ when 'xref'
262
+ refid = node.attributes['refid']
263
+ if refid and refid[0] == '_'
264
+ output = "<a href=\##{refid}>#{refid.gsub('_',' ')}</a>"
265
+ else
266
+ refs = node.parent.document.references[:ids]
267
+ # FIXME: the next line is HACKISH (and it crashes the app when refs[refid]) is nil)
268
+ # FIXME: and with the fix for nil results is even more hackish
269
+ if refs[refid]
270
+ reftext = refs[refid].gsub('.', '')
271
+ reftext = reftext.gsub(/:.*/,'')
272
+ if refid =~ /\Aeq-/
273
+ output = "<span><a href=\##{refid}>equation #{reftext}</a></span>"
274
+ elsif refid =~ /\Aformula-/
275
+ output = "<span><a href=\##{refid}>formula #{reftext}</a></span>"
276
+ elsif refid =~ /\Areaction-/
277
+ output = "<span><a href=\##{refid}>reaction #{reftext}</a></span>"
278
+ else
279
+ output = "<span><a href=\##{refid} style='text-decoration:none'>#{reftext}</a></span>"
280
+ end
281
+ else
282
+ output = 'ERROR: refs[refid] was nil'
283
+ end
284
+ end
285
+ when 'link'
286
+ output = "<a href=#{node.target}>#{node.text}</a>"
287
+ else
288
+ output = 'FOOBAR'
289
+ end
290
+ output
291
+ end
292
+
293
+ end
294
+
295
+
296
+ class Converter
297
+ include Asciidoctor::Converter
298
+
299
+ register_for 'latex'
300
+
301
+
302
+ Asciidoctor::Extensions.register do
303
+ preprocessor TeXPreprocessor
304
+ preprocessor MacroInsert if File.exist? 'macros.tex' and document.basebackend? 'html'
305
+ block EnvironmentBlock
306
+ block ClickBlock
307
+ inline_macro ChemInlineMacro
308
+ # preprocessor ClickStyleInsert if document.attributes['click_extras'] == 'include2'
309
+ postprocessor InjectHTML unless document.attributes['noteshare'] == 'yes'
310
+ postprocessor EntToUni if document.basebackend? 'tex' unless document.attributes['unicode'] == 'no'
311
+ postprocessor Chem if document.basebackend? 'html'
312
+ postprocessor HTMLPostprocessor if document.basebackend? 'html'
313
+ postprocessor TexPostprocessor if document.basebackend? 'tex'
314
+ end
315
+
316
+
317
+ Asciidoctor::Extensions.register :latex do
318
+ # EnvironmentBlock
319
+ end
320
+
321
+
322
+
323
+ TOP_TYPES = %w(document section)
324
+ LIST_TYPES = %w(dlist olist ulist)
325
+ INLINE_TYPES = %w(inline_anchor inline_break inline_footnote inline_quoted)
326
+ BLOCK_TYPES = %w(admonition listing literal page_break paragraph stem pass open quote \
327
+ example floating_title image click preamble sidebar verse)
328
+ OTHER_TYPES = %w(environment table)
329
+ NODE_TYPES = TOP_TYPES + LIST_TYPES + INLINE_TYPES + BLOCK_TYPES + OTHER_TYPES
330
+
331
+ def initialize backend, opts
332
+ super
333
+ basebackend 'tex'
334
+ outfilesuffix '.tex'
335
+ end
336
+
337
+ $latex_environment_names = []
338
+ $label_counter = 0
339
+
340
+ def convert node, transform = nil
341
+
342
+ if NODE_TYPES.include? node.node_name
343
+ node.tex_process
344
+ else
345
+ warn %(Node to implement: #{node.node_name}, class = #{node.class}).magenta if $VERBOSE
346
+ # This warning should not be switched off by $VERBOSE
347
+ end
348
+
349
+ end
350
+
351
+ end
352
+ end
353
+
354
+
355
+ class Asciidoctor::Converter::Html5Converter
356
+ # inject our custom code into the existing Html5Converter class (Ruby 2.0 and above)
357
+ prepend Asciidoctor::LaTeX::Html5ConverterExtensions
358
+ end