asciidoctor-latex 1.5.0.5.dev → 1.5.0.7.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.
- checksums.yaml +4 -4
- data/data/asciidoc_tex_macros.tex +3 -1
- data/data/extras.css +125 -5
- data/doc/Asciidoctor.html +19 -4
- data/doc/Asciidoctor/Block.html +1074 -426
- data/doc/Asciidoctor/Converter/Html5Converter.html +28 -4
- data/doc/Asciidoctor/Document.html +73 -89
- data/doc/Asciidoctor/Inline.html +154 -134
- data/doc/Asciidoctor/LaTeX.html +5 -5
- data/doc/Asciidoctor/LaTeX/Chem.html +2 -2
- data/doc/Asciidoctor/LaTeX/ChemInlineMacro.html +7 -5
- data/doc/Asciidoctor/LaTeX/ClickBlock.html +13 -7
- data/doc/Asciidoctor/LaTeX/ClickStyleInsert.html +10 -9
- data/doc/Asciidoctor/LaTeX/Converter.html +33 -22
- data/doc/Asciidoctor/LaTeX/Dollar.html +2 -2
- data/doc/Asciidoctor/LaTeX/EntToUni.html +2 -2
- data/doc/Asciidoctor/LaTeX/EnvironmentBlock.html +26 -12
- data/doc/Asciidoctor/LaTeX/HTMLPostprocessor.html +15 -9
- data/doc/Asciidoctor/LaTeX/Html5ConverterExtensions.html +701 -180
- data/doc/Asciidoctor/LaTeX/InjectHTML.html +3 -3
- data/doc/Asciidoctor/LaTeX/MacroInsert.html +2 -2
- data/doc/Asciidoctor/LaTeX/TeXBlock.html +2 -2
- data/doc/Asciidoctor/LaTeX/TeXPostProcess.html +49 -49
- data/doc/Asciidoctor/LaTeX/TeXPreprocessor.html +93 -22
- data/doc/Asciidoctor/LaTeX/TexPostprocessor.html +8 -4
- data/doc/Asciidoctor/List.html +54 -116
- data/doc/Asciidoctor/Section.html +23 -19
- data/doc/Asciidoctor/Table.html +25 -25
- data/doc/PreambleProcessor.html +2 -2
- data/doc/String.html +257 -4
- data/doc/_index.html +54 -5
- data/doc/class_list.html +1 -1
- data/doc/file.LICENSE.html +2 -2
- data/doc/file.README.html +113 -51
- data/doc/file_list.html +3 -0
- data/doc/index.html +113 -51
- data/doc/method_list.html +253 -55
- data/doc/top-level-namespace.html +25 -4
- data/lib/asciidoctor/latex/converter.rb +171 -45
- data/lib/asciidoctor/latex/{css.rb → css_doc_info.rb} +0 -0
- data/lib/asciidoctor/latex/environment_block.rb +137 -0
- data/lib/asciidoctor/latex/inject_html.rb +25 -13
- data/lib/asciidoctor/latex/inline_macros.rb +44 -2
- data/lib/asciidoctor/latex/macro_preprocessor.rb +28 -0
- data/lib/asciidoctor/latex/node_processors.rb +23 -2
- data/lib/asciidoctor/latex/sectnumoffset-treeprocessor.rb +43 -0
- data/lib/asciidoctor/latex/tex_postprocessor.rb +1 -1
- data/lib/asciidoctor/latex/tex_preprocessor.rb +2 -2
- data/lib/asciidoctor/latex/version.rb +1 -1
- data/spec/make_index_spec.rb +104 -0
- data/test/examples/tex/block_preamble.tex +0 -4
- metadata +8 -4
@@ -75,6 +75,10 @@
|
|
75
75
|
|
76
76
|
|
77
77
|
|
78
|
+
<dt class="r1">Includes:</dt>
|
79
|
+
<dd class="r1"><span class='object_link'><a href="Asciidoctor.html" title="Asciidoctor (module)">Asciidoctor</a></span></dd>
|
80
|
+
|
81
|
+
|
78
82
|
|
79
83
|
|
80
84
|
|
@@ -85,11 +89,11 @@
|
|
85
89
|
<p class="children">
|
86
90
|
|
87
91
|
|
88
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Asciidoctor.html" title="Asciidoctor (module)">Asciidoctor</a></span>
|
92
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Asciidoctor.html" title="Asciidoctor (module)">Asciidoctor</a></span>, <span class='object_link'><a href="TexUtilities.html" title="TexUtilities (module)">TexUtilities</a></span>
|
89
93
|
|
90
94
|
|
91
95
|
|
92
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="PreambleProcessor.html" title="PreambleProcessor (class)">PreambleProcessor</a></span>, <span class='object_link'><a href="String.html" title="String (class)">String</a></span>
|
96
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="CSSDocinfoProcessor.html" title="CSSDocinfoProcessor (class)">CSSDocinfoProcessor</a></span>, <span class='object_link'><a href="PreambleProcessor.html" title="PreambleProcessor (class)">PreambleProcessor</a></span>, <span class='object_link'><a href="String.html" title="String (class)">String</a></span>
|
93
97
|
|
94
98
|
|
95
99
|
</p>
|
@@ -101,13 +105,30 @@
|
|
101
105
|
|
102
106
|
|
103
107
|
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<h2>Method Summary</h2>
|
121
|
+
|
122
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="TexUtilities.html" title="TexUtilities (module)">TexUtilities</a></span></h3>
|
123
|
+
<p class="inherited"><span class='object_link'><a href="TexUtilities.html#apply_macros-class_method" title="TexUtilities.apply_macros (method)">apply_macros</a></span>, <span class='object_link'><a href="TexUtilities.html#begin-class_method" title="TexUtilities.begin (method)">begin</a></span>, <span class='object_link'><a href="TexUtilities.html#end-class_method" title="TexUtilities.end (method)">end</a></span>, <span class='object_link'><a href="TexUtilities.html#env-class_method" title="TexUtilities.env (method)">env</a></span>, <span class='object_link'><a href="TexUtilities.html#hypertarget-class_method" title="TexUtilities.hypertarget (method)">hypertarget</a></span>, <span class='object_link'><a href="TexUtilities.html#macro-class_method" title="TexUtilities.macro (method)">macro</a></span>, <span class='object_link'><a href="TexUtilities.html#macro_opt-class_method" title="TexUtilities.macro_opt (method)">macro_opt</a></span>, <span class='object_link'><a href="TexUtilities.html#region-class_method" title="TexUtilities.region (method)">region</a></span></p>
|
124
|
+
|
104
125
|
|
105
126
|
</div>
|
106
127
|
|
107
128
|
<div id="footer">
|
108
|
-
Generated on
|
129
|
+
Generated on Tue May 3 13:31:55 2016 by
|
109
130
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
|
-
0.8.7.6 (ruby-2.
|
131
|
+
0.8.7.6 (ruby-2.3.0).
|
111
132
|
</div>
|
112
133
|
|
113
134
|
</body>
|
@@ -3,17 +3,46 @@
|
|
3
3
|
# File: latex-converter.rb
|
4
4
|
# Author: J. Carlson (jxxcarlson@gmail.com)
|
5
5
|
# First commit: 9/26/2014
|
6
|
-
# Date: 2/20/
|
6
|
+
# Date: 2/20/2015
|
7
7
|
#
|
8
8
|
# OVERVIEW
|
9
9
|
#
|
10
|
-
# Asciidoctor-latex
|
10
|
+
# Asciidoctor-latex adds certain latex-like constructs to the asciidoc markup
|
11
|
+
# language and provides two backends:
|
11
12
|
#
|
12
|
-
#
|
13
|
-
# asciidoc(tor) with these additional features will be called 'asciidoctor-latex'
|
13
|
+
# - a converter with HTML as output
|
14
14
|
#
|
15
|
-
# --
|
16
|
-
#
|
15
|
+
# -- a convert with LaTeX as output
|
16
|
+
#
|
17
|
+
# The goal of this project is to be able to combine the
|
18
|
+
# strengths of asciidoc and late:
|
19
|
+
#
|
20
|
+
# - to use asciidoc for most of the non-mathematical text
|
21
|
+
#
|
22
|
+
# - to write inline mathematical text as one does in LaTeX:
|
23
|
+
#
|
24
|
+
# $ a^2 + b^2 = c^1 $,
|
25
|
+
#
|
26
|
+
# for example.
|
27
|
+
#
|
28
|
+
# - the same for displayed mathematical text
|
29
|
+
#
|
30
|
+
# \[
|
31
|
+
# \int_0^1 x^n dx = \frac{1}{n+1}
|
32
|
+
# \]
|
33
|
+
#
|
34
|
+
# - to provide constructs which map to LaTeX environments.
|
35
|
+
# Thus one can say
|
36
|
+
#
|
37
|
+
# [env.theorem]
|
38
|
+
# --
|
39
|
+
# There are infinitely many primes
|
40
|
+
# --
|
41
|
+
#
|
42
|
+
# In the HTML converter the output will appear just
|
43
|
+
# as if it had been rendered by xelatex. If the
|
44
|
+
# LaTeX backend is used, the output is as one would
|
45
|
+
# expect
|
17
46
|
#
|
18
47
|
# See http://www.noteshare.io/section/asciidoctor-latex-manual-intro
|
19
48
|
# for a description (with examples) of asciidoctor-latex.
|
@@ -30,12 +59,14 @@
|
|
30
59
|
#
|
31
60
|
# to render an asciidoctor-latex document to html
|
32
61
|
#
|
33
|
-
# Some documents
|
34
|
-
#
|
62
|
+
# Some documents -- those with 'click blocks',
|
63
|
+
# use a variant of the regular command:
|
35
64
|
#
|
36
65
|
# 'asciidoctor-latex -b html -a click_extras=include foo.adoc'
|
37
66
|
#
|
38
67
|
# In both cases the output is 'foo.html'
|
68
|
+
# see http://www.noteshare.io/section/homework-problems)
|
69
|
+
# for information on this topic.
|
39
70
|
#
|
40
71
|
# USAGE (2: latex)
|
41
72
|
#
|
@@ -43,37 +74,33 @@
|
|
43
74
|
#
|
44
75
|
# 'asciidoctor-latex foo.adoc'
|
45
76
|
#
|
46
|
-
# to convert foo.adoc to foo.tex.
|
47
|
-
#
|
77
|
+
# to convert foo.adoc to foo.tex. The resulting
|
78
|
+
# file should be typeset with xelatex
|
79
|
+
# because of the likely appearance of unicode
|
80
|
+
# characters.
|
48
81
|
#
|
49
|
-
#
|
82
|
+
# To convert foo.tex to the latex file foo.latex,
|
50
83
|
# You can put files 'macros.tex' and 'preamble.tex' to
|
51
84
|
# replace the default preamble and set of macros.
|
52
|
-
# Define your own 'newEnvironments.tex' to use
|
85
|
+
# Define your own 'newEnvironments.tex' to use your definitions
|
53
86
|
# as opposed to the default definitons of environments
|
54
|
-
# in tex mapping to [tex.
|
87
|
+
# in tex mapping to [tex.ENVIRONOMENT] in asciidoctor-latex.
|
55
88
|
#
|
56
|
-
# TECHNICAL NOTES
|
89
|
+
# TECHNICAL NOTES (This section needs a thorough rewrite)
|
57
90
|
#
|
58
91
|
# This is a first step towards writing a LaTeX backend
|
59
92
|
# for Asciidoctor. It is based on the
|
60
|
-
# Dan Allen's demo-converter.rb.
|
61
|
-
# is unchanged, the methods "document node" and "section node"
|
62
|
-
# have been redefined, and several new methods have been added.
|
93
|
+
# Dan Allen's demo-converter.rb.
|
63
94
|
#
|
64
95
|
# The main work will be in identifying asciidoc elements
|
65
96
|
# that need to be transformed and adding a method for
|
66
97
|
# each such element. As noted below, the "warn" clause
|
67
98
|
# in the "convert" method is a useful tool for this task.
|
68
99
|
#
|
69
|
-
# Usage:
|
70
|
-
#
|
71
|
-
# $ asciidoctor -r ./latex-converter.rb -b latex test/sample1.adoc
|
72
|
-
#
|
73
100
|
# Comments
|
74
101
|
#
|
75
102
|
# 1. The "warn" clause in the converter code is quite useful.
|
76
|
-
# For example, you
|
103
|
+
# For example, you may discover in running the converter on
|
77
104
|
# "test/sample-1.adoc" that you have not implemented code for
|
78
105
|
# the "olist" node. Thus you can work through ever more complex
|
79
106
|
# examples to discover what you need to do to increase the coverage
|
@@ -81,7 +108,7 @@
|
|
81
108
|
#
|
82
109
|
# 2. The converter simply passes on what it does not understand, e.g.,
|
83
110
|
# LaTeX, This is good. However, we will have to map constructs
|
84
|
-
# like"+\( a^2 = b^2 \)+" to $ a^2 + b^2 $, etc.
|
111
|
+
# like "+\( a^2 = b^2 \)+" to $ a^2 + b^2 $, etc.
|
85
112
|
# This can be done at the preprocessor level.
|
86
113
|
#
|
87
114
|
# 3. In view of the preceding, we may need to chain a frontend
|
@@ -110,22 +137,13 @@
|
|
110
137
|
# in "node_processors.rb" to date was written using this
|
111
138
|
# hackish process.
|
112
139
|
#
|
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
|
-
#
|
140
|
+
|
124
141
|
|
125
142
|
require 'asciidoctor'
|
126
143
|
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
|
127
144
|
require 'asciidoctor/converter/html5'
|
128
|
-
|
145
|
+
|
146
|
+
require 'asciidoctor/latex/css_doc_info'
|
129
147
|
require 'asciidoctor/latex/inline_macros'
|
130
148
|
require 'asciidoctor/latex/core_ext/colored_string'
|
131
149
|
require 'asciidoctor/latex/click_block'
|
@@ -137,15 +155,17 @@ require 'asciidoctor/latex/prepend_processor'
|
|
137
155
|
require 'asciidoctor/latex/macro_insert'
|
138
156
|
require 'asciidoctor/latex/tex_block'
|
139
157
|
require 'asciidoctor/latex/tex_preprocessor'
|
158
|
+
require 'asciidoctor/latex/macro_preprocessor'
|
140
159
|
require 'asciidoctor/latex/dollar'
|
141
160
|
require 'asciidoctor/latex/tex_postprocessor'
|
142
161
|
require 'asciidoctor/latex/chem'
|
162
|
+
require 'asciidoctor/latex/sectnumoffset-treeprocessor'
|
143
163
|
|
144
164
|
|
145
165
|
|
146
166
|
# require 'asciidoctor/latex/preamble_processor'
|
147
167
|
|
148
|
-
$VERBOSE =
|
168
|
+
$VERBOSE = false
|
149
169
|
|
150
170
|
|
151
171
|
|
@@ -186,25 +206,79 @@ module Asciidoctor::LaTeX
|
|
186
206
|
handle_equation(node)
|
187
207
|
when 'equationalign'
|
188
208
|
handle_equation_align(node)
|
209
|
+
when 'cd'
|
210
|
+
handle_cd(node)
|
189
211
|
when 'chem'
|
190
212
|
handle_chem(node)
|
191
213
|
when 'jsxgraph'
|
192
214
|
handle_jsxgraph(node)
|
193
215
|
when 'texmacro'
|
194
216
|
handle_texmacro(node)
|
217
|
+
when 'include_latex'
|
218
|
+
handle_include_latex(node)
|
195
219
|
else
|
196
220
|
handle_default(node)
|
197
221
|
end
|
198
222
|
|
199
223
|
node.attributes['roles'] = (node.roles + ['environment']) * ' '
|
200
224
|
self.open node
|
201
|
-
end
|
225
|
+
end # method environment
|
226
|
+
|
227
|
+
def environment_literal node
|
228
|
+
|
229
|
+
warn "entering environment(node)".red if $VERBOSE
|
230
|
+
|
231
|
+
attrs = node.attributes
|
232
|
+
|
233
|
+
warn "attrs['role'] = #{attrs['role']}".blue if $VERBOSE
|
234
|
+
|
235
|
+
case attrs['role']
|
236
|
+
when 'box', 'capsule'
|
237
|
+
handle_null(node)
|
238
|
+
when 'code'
|
239
|
+
handle_code(node)
|
240
|
+
when 'equation'
|
241
|
+
handle_equation_literal(node)
|
242
|
+
when 'equationalign'
|
243
|
+
handle_equation_align(node)
|
244
|
+
when 'cd'
|
245
|
+
handle_cd(node)
|
246
|
+
when 'chem'
|
247
|
+
handle_chem(node)
|
248
|
+
when 'jsxgraph'
|
249
|
+
handle_jsxgraph(node)
|
250
|
+
when 'texmacro'
|
251
|
+
handle_texmacro(node)
|
252
|
+
else
|
253
|
+
handle_default(node)
|
254
|
+
end
|
255
|
+
|
256
|
+
node.attributes['roles'] = (node.roles + ['environment']) * ' '
|
257
|
+
self.open node
|
258
|
+
end # method environment_literal
|
202
259
|
|
203
260
|
def handle_texmacro node
|
204
261
|
node.title = nil
|
205
262
|
node.lines = ["+++\n\\("] + node.lines + ["\\)\n+++"]
|
206
263
|
end
|
207
264
|
|
265
|
+
# Example:
|
266
|
+
# [env.include_latex]
|
267
|
+
# --
|
268
|
+
# \nput abc.text
|
269
|
+
# \usepackage{def}
|
270
|
+
# --
|
271
|
+
# Nothing appears in the HTML,
|
272
|
+
# bu lines
|
273
|
+
# \nput abc.text
|
274
|
+
# \usepackage{def}
|
275
|
+
# appear in the generated tex file.
|
276
|
+
def handle_include_latex node
|
277
|
+
node.title = nil
|
278
|
+
node.lines = [] # ["// "] + node.lines
|
279
|
+
self.open node
|
280
|
+
end
|
281
|
+
|
208
282
|
def click node
|
209
283
|
if node.attributes['plain-option']
|
210
284
|
node.lines = [ENV_CSS_PLAIN] + node.lines + [DIV_END]
|
@@ -215,9 +289,37 @@ module Asciidoctor::LaTeX
|
|
215
289
|
self.open node
|
216
290
|
end
|
217
291
|
|
292
|
+
def old_inline_anchor node
|
293
|
+
target = node.target
|
294
|
+
case node.type
|
295
|
+
when :xref
|
296
|
+
refid = node.attributes['refid'] || target
|
297
|
+
# NOTE we lookup text in converter because DocBook doesn't need this logic
|
298
|
+
text = node.text || (node.document.references[:ids][refid] || %([#{refid}]))
|
299
|
+
# FIXME shouldn't target be refid? logic seems confused here
|
300
|
+
%(<a href="#{target}">#{text}</a>)
|
301
|
+
when :ref
|
302
|
+
%(<a id="#{target}"></a>)
|
303
|
+
when :link
|
304
|
+
attrs = []
|
305
|
+
attrs << %( id="#{node.id}") if node.id
|
306
|
+
if (role = node.role)
|
307
|
+
attrs << %( class="#{role}")
|
308
|
+
end
|
309
|
+
attrs << %( title="#{node.attr 'title'}") if node.attr? 'title', nil, false
|
310
|
+
attrs << %( target="#{node.attr 'window'}") if node.attr? 'window', nil, false
|
311
|
+
%(<a href="#{target}"#{attrs.join}>#{node.text}</a>)
|
312
|
+
when :bibref
|
313
|
+
%(<a id="#{target}"></a>[#{target}])
|
314
|
+
else
|
315
|
+
warn %(asciidoctor: WARNING: unknown anchor type: #{node.type.inspect})
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
218
319
|
def inline_anchor node
|
219
320
|
|
220
321
|
case node.type.to_s
|
322
|
+
|
221
323
|
when 'xref'
|
222
324
|
refid = node.attributes['refid']
|
223
325
|
if refid and refid[0] == '_'
|
@@ -239,13 +341,13 @@ module Asciidoctor::LaTeX
|
|
239
341
|
output = "<span class='xref'><a href=\##{refid}>#{reftext}</a></span>"
|
240
342
|
end
|
241
343
|
else
|
242
|
-
output =
|
344
|
+
output = old_inline_anchor node
|
243
345
|
end
|
244
346
|
end
|
245
347
|
when 'link'
|
246
348
|
output = "<a href=#{node.target}>#{node.text}</a>"
|
247
349
|
else
|
248
|
-
output =
|
350
|
+
output = old_inline_anchor node
|
249
351
|
end
|
250
352
|
output
|
251
353
|
end
|
@@ -266,6 +368,21 @@ module Asciidoctor::LaTeX
|
|
266
368
|
end
|
267
369
|
end
|
268
370
|
|
371
|
+
def handle_equation_literal(node)
|
372
|
+
attrs = node.attributes
|
373
|
+
options = attrs['options']
|
374
|
+
node.title = nil
|
375
|
+
number_part = '<td class="equation_number_style">' + "(#{node.caption}) </td>"
|
376
|
+
equation_part = ['<td class="equation_content_style";>'] + ['\\['] + node.lines + ['\\]'] + ['</td>']
|
377
|
+
table_style='class="equation_table_style"'
|
378
|
+
row_style='class="equation_row_style"'
|
379
|
+
if options.include? 'numbered'
|
380
|
+
node.lines = ["<table #{table_style}><tr #{row_style}>"] + equation_part + number_part + ['</tr></table>']
|
381
|
+
else
|
382
|
+
node.lines = ["<table #{table_style}><tr #{row_style}>"] + equation_part + ['</tr></table>']
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
269
386
|
def handle_equation_align(node)
|
270
387
|
attrs = node.attributes
|
271
388
|
options = attrs['options']
|
@@ -282,6 +399,11 @@ module Asciidoctor::LaTeX
|
|
282
399
|
end
|
283
400
|
end
|
284
401
|
|
402
|
+
def handle_cd(node)
|
403
|
+
node.title = nil
|
404
|
+
node.lines = ['\\[', '\require{AMScd}', '\\begin{CD}', node.lines, '\\end{CD}', '\\]']
|
405
|
+
end
|
406
|
+
|
285
407
|
def handle_chem(node)
|
286
408
|
node.title = nil
|
287
409
|
number_part = '<td class="equation_number_style">' + "(#{node.caption}) </td>"
|
@@ -319,9 +441,6 @@ module Asciidoctor::LaTeX
|
|
319
441
|
node.lines = line_array
|
320
442
|
end
|
321
443
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
444
|
def handle_null(node)
|
326
445
|
|
327
446
|
end
|
@@ -354,12 +473,16 @@ module Asciidoctor::LaTeX
|
|
354
473
|
Asciidoctor::Extensions.register do
|
355
474
|
docinfo_processor CSSDocinfoProcessor
|
356
475
|
preprocessor TeXPreprocessor
|
357
|
-
preprocessor
|
476
|
+
preprocessor MacroPreprocessor
|
477
|
+
preprocessor MacroInsert if (File.exist? 'macros.tex' and document.basebackend? 'html' and document.attributes['include_macros'] == 'yes')
|
358
478
|
block EnvironmentBlock
|
479
|
+
block EnvironmentBlock2
|
359
480
|
block ClickBlock
|
360
481
|
inline_macro ChemInlineMacro
|
482
|
+
inline_macro GlossInlineMacro
|
483
|
+
inline_macro IndexTermInlineMacro
|
361
484
|
# preprocessor ClickStyleInsert if document.attributes['click_extras'] == 'include2'
|
362
|
-
postprocessor InjectHTML unless document.attributes['
|
485
|
+
postprocessor InjectHTML unless document.attributes['inject_javascript'] == 'no'
|
363
486
|
postprocessor EntToUni if document.basebackend? 'tex' unless document.attributes['unicode'] == 'no'
|
364
487
|
postprocessor Chem if document.basebackend? 'html'
|
365
488
|
postprocessor HTMLPostprocessor if document.basebackend? 'html'
|
@@ -398,7 +521,7 @@ module Asciidoctor::LaTeX
|
|
398
521
|
if NODE_TYPES.include? node.node_name
|
399
522
|
node.tex_process
|
400
523
|
else
|
401
|
-
warn %(Node to implement: #{node.node_name}, class = #{node.class}).magenta if $VERBOSE
|
524
|
+
warn %(Node to implement: #{node.node_name}, class = #{node.class}).magenta # if $VERBOSE
|
402
525
|
# This warning should not be switched off by $VERBOSE
|
403
526
|
end
|
404
527
|
|
@@ -410,6 +533,9 @@ end # module Asciidoctor::LaTeX
|
|
410
533
|
|
411
534
|
class Asciidoctor::Converter::Html5Converter
|
412
535
|
# inject our custom code into the existing Html5Converter class (Ruby 2.0 and above)
|
536
|
+
# the ideal is to use 'prepend'; however, this is incompatible
|
537
|
+
# with the current version of Opal, so the alternative of 'include' is provided for
|
538
|
+
# cases in which 'prepend' is not available
|
413
539
|
if respond_to? :prepend
|
414
540
|
prepend Asciidoctor::LaTeX::Html5ConverterExtensions
|
415
541
|
else
|
File without changes
|
@@ -86,6 +86,8 @@ module Asciidoctor::LaTeX
|
|
86
86
|
|
87
87
|
class EnvironmentBlock < Asciidoctor::Extensions::BlockProcessor
|
88
88
|
|
89
|
+
# include Common # for method process
|
90
|
+
|
89
91
|
use_dsl
|
90
92
|
|
91
93
|
named :env
|
@@ -212,4 +214,139 @@ module Asciidoctor::LaTeX
|
|
212
214
|
end
|
213
215
|
|
214
216
|
end
|
217
|
+
|
218
|
+
class EnvironmentBlock2 < Asciidoctor::Extensions::BlockProcessor
|
219
|
+
|
220
|
+
# include Common # for method process
|
221
|
+
|
222
|
+
use_dsl
|
223
|
+
|
224
|
+
named :envv
|
225
|
+
on_context :literal
|
226
|
+
# parse_context_as :complex
|
227
|
+
# ^^^ The above line gave me an error. I'm not sure what do to with it.
|
228
|
+
|
229
|
+
def process parent, reader, attrs
|
230
|
+
|
231
|
+
original_title = attrs['title']
|
232
|
+
attrs['original_title'] = attrs['title']
|
233
|
+
|
234
|
+
# Ensure that role is defined
|
235
|
+
if attrs['role'] == nil
|
236
|
+
role = 'item'
|
237
|
+
else
|
238
|
+
role = attrs['role']
|
239
|
+
end
|
240
|
+
|
241
|
+
# fixme: this should not be necessary
|
242
|
+
if attrs['role'] =~ /\\/
|
243
|
+
attrs['role'] = attrs['role'].gsub(/\\/, '')
|
244
|
+
end
|
245
|
+
|
246
|
+
# Determine whether the block is numbered
|
247
|
+
# Use the option set if present (numbered, no+_number) otherwise
|
248
|
+
# use a default value, e.g. 'box' is not numbered, the others are numbered
|
249
|
+
if !(attrs['options'] =~ /no_number|numbered/)
|
250
|
+
if %w(capsule box equation equationalign).include? role
|
251
|
+
attrs['options'] = 'no_number'
|
252
|
+
else
|
253
|
+
attrs['options'] = 'numbered'
|
254
|
+
end
|
255
|
+
end
|
256
|
+
if attrs['id']
|
257
|
+
attrs['options'] = 'numbered'
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
# Adjust title according to environment name
|
262
|
+
env_name = role # roles.first # FIXME: roles.first is probably best
|
263
|
+
if %w(equation equationalign chem).include? role
|
264
|
+
attrs['title'] = env_name
|
265
|
+
elsif role == 'code'
|
266
|
+
if attrs['id'] or attrs['title']
|
267
|
+
attrs['title'] = 'Listing'
|
268
|
+
else
|
269
|
+
attrs['title'] = ''
|
270
|
+
attrs['options'] = 'no_number'
|
271
|
+
end
|
272
|
+
elsif role == 'jsxgraph'
|
273
|
+
attrs['title'] = 'JSXGraph'
|
274
|
+
elsif role == 'box'or role == 'capsule'
|
275
|
+
attrs['title'] = ''
|
276
|
+
else
|
277
|
+
attrs['title'] = env_name.capitalize
|
278
|
+
end
|
279
|
+
env_title = attrs['title']
|
280
|
+
|
281
|
+
|
282
|
+
# Creat the block
|
283
|
+
if attrs['role'] == 'code'
|
284
|
+
warn "for rode = code, attrs = #{attrs}".cyan
|
285
|
+
block = create_block parent, :listing, reader.lines, attrs
|
286
|
+
else
|
287
|
+
# block = create_block parent, :environment, reader.lines, attrs
|
288
|
+
# block = create_pass_block parent, html, attrs, subs: nil
|
289
|
+
block = create_block parent, :environment_literal, reader.lines, attrs, subs: nil
|
290
|
+
end
|
291
|
+
|
292
|
+
if attrs['options'] =~ /numbered/
|
293
|
+
# THE NUMBERED OPTION
|
294
|
+
# Use same prefix for cross referencing for the
|
295
|
+
# equation_align environment as for the equation
|
296
|
+
# environment so as not to have separate numbering
|
297
|
+
# sequences
|
298
|
+
if env_name == 'equationalign'
|
299
|
+
env_ref_prefix = 'equation'
|
300
|
+
else
|
301
|
+
env_ref_prefix = env_name
|
302
|
+
end
|
303
|
+
# Define caption_num so that we can make references
|
304
|
+
# that display as "(17)", for example
|
305
|
+
# This is where we can set the caption number by hand
|
306
|
+
# once I figure out how to do so.
|
307
|
+
caption_num = parent.document.counter_increment("#{env_ref_prefix}-number", block)
|
308
|
+
attrs['caption-num'] = caption_num
|
309
|
+
caption = "#{caption_num}"
|
310
|
+
# Set the title, e.g., "Theorem 3: Pythagoras" or just "Theorem 3"
|
311
|
+
# depending on whether the user sets a title, .e.g, ".Pythagoras"
|
312
|
+
# in the line preceding "[env.theorem]"
|
313
|
+
if original_title
|
314
|
+
attrs['title'] = "#{env_title} #{caption_num}: #{original_title}"
|
315
|
+
else
|
316
|
+
attrs['title'] = "#{env_title} #{caption_num}."
|
317
|
+
end
|
318
|
+
else
|
319
|
+
# THE NON-NUMBERED OPTION
|
320
|
+
# Set the title, e.g., "Pythagoras" or just "Theorem"
|
321
|
+
# depending on whether the user sets a title, .e.g, ".Pythgoras"
|
322
|
+
# in the line preceding "[env.theorem]"
|
323
|
+
# FIXME: this code is a tad spaghetti-like
|
324
|
+
if original_title
|
325
|
+
if %w(box).include? role
|
326
|
+
attrs['title'] = "#{original_title}"
|
327
|
+
else
|
328
|
+
attrs['title'] = "#{env_title}: #{original_title}"
|
329
|
+
end
|
330
|
+
else
|
331
|
+
attrs['title'] = "#{env_title}"
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
if attrs['role'] == 'code'
|
336
|
+
caption = nil
|
337
|
+
end
|
338
|
+
|
339
|
+
block.assign_caption caption
|
340
|
+
if %w(equation equationalign chem).include? role
|
341
|
+
block.title = "#{caption_num}"
|
342
|
+
else
|
343
|
+
block.title = attrs['title']
|
344
|
+
end
|
345
|
+
block
|
346
|
+
|
347
|
+
end
|
348
|
+
|
349
|
+
end
|
350
|
+
|
351
|
+
|
215
352
|
end
|