asciidoctor-latex 1.5.0.1.dev → 1.5.0.2.dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +17 -31
- data/examples/README.adoc +9 -349
- data/lib/asciidoctor/latex/chem.rb +20 -12
- data/lib/asciidoctor/latex/converter.rb +9 -5
- data/lib/asciidoctor/latex/core_ext/colored_string.rb +5 -0
- data/lib/asciidoctor/latex/node_processors.rb +91 -74
- data/lib/asciidoctor/latex/tex_postprocessor.rb +1 -0
- data/lib/asciidoctor/latex/version.rb +1 -1
- data/test/examples/adoc/admonition.adoc +11 -0
- data/test/examples/adoc/box.adoc +8 -0
- data/test/examples/adoc/env.adoc +20 -0
- data/test/examples/adoc/eqalign.adoc +13 -0
- data/test/examples/adoc/line_break.adoc +5 -0
- data/test/examples/adoc/listing.adoc +12 -0
- data/test/examples/adoc/literal.adoc +20 -0
- data/test/examples/adoc/math.adoc +12 -0
- data/test/examples/adoc/open_block.adoc +17 -0
- data/test/examples/adoc/page_break.adoc +7 -0
- data/test/examples/adoc/pass.adoc +5 -0
- data/test/examples/adoc/sections.adoc +32 -0
- data/test/examples/tex/env.tex +15 -1
- data/test/examples/tex/eq.tex +1 -1
- metadata +24 -3
- data/manual.adoc +0 -285
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cf66b3d913348a3e7d5f6c5a3006c5a3375df78
|
4
|
+
data.tar.gz: 98e6b9948d24b68e3f0265c755cff59578f2713a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2c2ddd62e2dc6cf680a42bd2f62be8bcef105574812ae07e3cec6b97c677fc5e40625b0f4e438dd180d24a66973b3ddaeb4a38a23bb1a6b05264e8c9fd37801
|
7
|
+
data.tar.gz: 916024d755d904cda6e0265ed31f1a50736d6e7fdbcd6e035635b77062bdddcfaae3cfea3ff1d3427798e440bd47a5a863e82709ba960df48d026134b7b02dc8
|
data/README.adoc
CHANGED
@@ -8,49 +8,34 @@ James Carlson
|
|
8
8
|
== Purpose
|
9
9
|
|
10
10
|
Asciidoc-LaTeX defines an extended mathematical syntax
|
11
|
-
for Asciidoc
|
11
|
+
for the Asciidoc markup language
|
12
|
+
that closely parallels LaTeX. The
|
12
13
|
Asciidoctor-LaTeX converter renders documents written
|
13
14
|
in this extended markup language into both HTML
|
14
15
|
and LaTeX.footnote:[Many, but not all Asciidoc language
|
15
16
|
features are covered by this release.]
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
----
|
25
|
-
on the files `start.adoc`, etc found
|
26
|
-
in the directory `examples` of this repository.
|
27
|
-
This command produces the file `start.html`.
|
28
|
-
It can be viewed with any browser. You will
|
29
|
-
need an internet connection , since the browser
|
30
|
-
must load he MathJax fonts.
|
31
|
-
|
32
|
-
NOTE: Consult the
|
33
|
-
http://noteshare.io/book/asciidoctor-latex-manual[Asciidoctor-LaTeX manual]
|
34
|
-
for more information and for a view of both
|
35
|
-
source and rendered text for
|
36
|
-
Asciidoc-LaTeX. For more information on conversion
|
37
|
-
of Asciidoc-LaTeX documents to LaTeX, see
|
38
|
-
`manual.adoc` _(needs update)_.
|
18
|
+
Below, we descibe the main
|
19
|
+
features of Asciidoc-LaTeX. However, since
|
20
|
+
Asciidoc-LaTeX will not render in GitHub, you
|
21
|
+
are encouraged to view this write-up:
|
22
|
+
https://vschool.s3.amazonaws.com/manuscripts/372.html[Asciidoc-LaTeX].
|
23
|
+
For more information, please consult
|
24
|
+
http://www.noteshare.io/book/asciidoctor-latex-manual[Asciidoctor-LaTeX manual].
|
39
25
|
|
40
26
|
|
41
27
|
Asciidoctor-LaTeX is developed by James Carlson, Jakub Jirutka, and Dan Allen.
|
42
|
-
_In progress: Cross-compilation to Asciidoctor.js by Guillaume Grossetie makes
|
43
|
-
possible other uses, among which will be inclusion in the Chrome
|
44
|
-
Live Preview Extension._
|
45
28
|
|
46
29
|
|
47
30
|
== Installation
|
48
31
|
|
49
32
|
=== Using Rubygems
|
50
33
|
|
51
|
-
There is a development release
|
34
|
+
There is a development release at
|
35
|
+
https://rubygems.org/gems/asciidoctor-latex[RubyGems.org]
|
36
|
+
Beta alert!
|
52
37
|
|
53
|
-
=== From
|
38
|
+
=== From GitHub
|
54
39
|
|
55
40
|
If you would like to install a development version from the repository, use:
|
56
41
|
|
@@ -72,11 +57,12 @@ one can write `$ a^2 + b^2 = c^2 $` and
|
|
72
57
|
e^{2\pi \sqrt{-1}} = 1,
|
73
58
|
\]
|
74
59
|
----
|
75
|
-
for in-line and
|
60
|
+
for in-line and display mathematial
|
76
61
|
text, respectively.
|
77
62
|
You will need to express dollar-denominated
|
78
63
|
currency using
|
79
|
-
escaped dollar signs
|
64
|
+
escaped dollar signs, as
|
65
|
+
in the sentence, "He paid \$100 for that
|
80
66
|
theore.m" In AsciiMath, one writes
|
81
67
|
`+++stem:[ a^2 + b^2 = c^2 ]+++`
|
82
68
|
and
|
@@ -171,7 +157,7 @@ V & = \frac{4}{3} \pi r^3
|
|
171
157
|
|
172
158
|
== Click blocks
|
173
159
|
|
174
|
-
Click blocks are similar to `[env]` blocks
|
160
|
+
Click blocks are similar to `[env]` blocks exceptiipoo that the body of
|
175
161
|
the block is not displayed until the user clicks on the heading.
|
176
162
|
The heading of a click block is displayed in blue. Once a click
|
177
163
|
block is "opened", it can be closed by clicking again on the heading.
|
data/examples/README.adoc
CHANGED
@@ -1,352 +1,12 @@
|
|
1
|
-
|
2
|
-
:toc2:
|
3
|
-
:max-width: 60%
|
1
|
+
= README
|
4
2
|
|
5
|
-
:stem: latexmath
|
6
3
|
|
4
|
+
Read the file `start.html` to
|
5
|
+
get an overview of Asciidoc-Latex.
|
6
|
+
To install `asciidoctor-latex`, read the
|
7
|
+
README at the root of this repository.
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
The aim of the Asciidoc-LaTeX converter is
|
14
|
-
|
15
|
-
|
16
|
-
. To add LaTeX-like facilities
|
17
|
-
to Asciidoc for handling mathematical notation when rendered as HTML.
|
18
|
-
We refer to the extended Asciidoc markup language as Asciidoc-LaTeX.
|
19
|
-
|
20
|
-
. To render AsciiDoc-LaTeX documents into LaTeX.
|
21
|
-
|
22
|
-
|
23
|
-
As an example of both features, you can write automatically numbered equations, e.g.,
|
24
|
-
|
25
|
-
[env.equation]
|
26
|
-
--
|
27
|
-
\int_{|z| = 1} \frac{dz}{z} = 2\pi \sqrt{-1}
|
28
|
-
--
|
29
|
-
|
30
|
-
by writing this
|
31
|
-
|
32
|
-
----
|
33
|
-
[env.equation]
|
34
|
-
--
|
35
|
-
\int_{|z| = 1} \frac{dz}{z} = 2\pi \sqrt{-1}
|
36
|
-
--
|
37
|
-
----
|
38
|
-
|
39
|
-
|
40
|
-
To render your document as tex, type the commmand
|
41
|
-
`asciidoctor-latex foo.adoc`.
|
42
|
-
To render your document as HTML, use the `html`
|
43
|
-
backend: type the
|
44
|
-
command `asciidoctor-latex -b html foo.adoc`.
|
45
|
-
|
46
|
-
|
47
|
-
Automatically numbered theorems, definitions, etc., are
|
48
|
-
written in the same way
|
49
|
-
|
50
|
-
----
|
51
|
-
|
52
|
-
[env.theorem#th-pythag#integral]
|
53
|
-
--
|
54
|
-
For a right triangle, the square on the hypotenuse is equal to the summ
|
55
|
-
of the squares of the two remaining sides, i.e.,
|
56
|
-
\[
|
57
|
-
c^2 = a^2 + b^2.
|
58
|
-
\]
|
59
|
-
-
|
60
|
-
----
|
61
|
-
|
62
|
-
[env.theorem#th-pythag]
|
63
|
-
--
|
64
|
-
For a right triangle, the square on the hypotenuse is equal to the summ
|
65
|
-
of the squares of the two remaining sides, i.e.,
|
66
|
-
\[
|
67
|
-
c^2 = a^2 + b^2.
|
68
|
-
\]
|
69
|
-
--
|
70
|
-
|
71
|
-
The optional string `#th-pythag` is a label for purposes of cross-referencing:
|
72
|
-
----
|
73
|
-
<<th-pythag>>
|
74
|
-
----
|
75
|
-
Using the above code, we may later refer to <<th-pythag>>.
|
76
|
-
The cross-referencing style applies to env-blocks in general,
|
77
|
-
e.g., to
|
78
|
-
|
79
|
-
[env.equation#eq-pythag]
|
80
|
-
--
|
81
|
-
c^2 = a^2 + b^2
|
82
|
-
--
|
83
|
-
Cross-references are made like this:
|
84
|
-
----
|
85
|
-
<eq-pythag>>
|
86
|
-
----
|
87
|
-
but the rendered
|
88
|
-
cross-reference is different: we refer to equation <<eq-pythag>>,
|
89
|
-
formula <<eq-pythag>>, etc. The ``[env.code]`` block also receives
|
90
|
-
special treatment. The source text
|
91
|
-
----
|
92
|
-
[env.code#iter]
|
93
|
-
--
|
94
|
-
def iter(f, a, n)
|
95
|
-
n.times do
|
96
|
-
a = f.call(a)
|
97
|
-
puts a
|
98
|
-
end
|
99
|
-
return a
|
100
|
-
end
|
101
|
-
--
|
102
|
-
----
|
103
|
-
is rendered as
|
104
|
-
|
105
|
-
[env.code#iter]
|
106
|
-
--
|
107
|
-
def iter(f, a, n)
|
108
|
-
n.times do
|
109
|
-
a = f.call(a)
|
110
|
-
puts a
|
111
|
-
end
|
112
|
-
return a
|
113
|
-
end
|
114
|
-
--
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
== First tests
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
Below are some examples you can run through Asciidoctor to see what you can do with it.
|
124
|
-
We assume that you've already installed asciidoctor-latex (see README for instructions).
|
125
|
-
Now try this
|
126
|
-
|
127
|
-
```
|
128
|
-
$ asciidoctor -b html eq-latex.adoc
|
129
|
-
```
|
130
|
-
|
131
|
-
After running the above command, you should find the file `eq-latex.html`
|
132
|
-
next to the source file `eq-latex.adoc`. View it in your browser.
|
133
|
-
You will need to be connected to the internet so that your browser
|
134
|
-
can load the MathJax fonts used to render mathematical
|
135
|
-
notation.footnote:[You can also install the fonts on your system.
|
136
|
-
See http://www.mathjax.org/help/fonts/[mathjax-fonts]. this will give you faster reponse.
|
137
|
-
Turning off your internet conneection makes it better still:-(]
|
138
|
-
|
139
|
-
Lets test the analogous file written in `stem` format:
|
140
|
-
|
141
|
-
```
|
142
|
-
$ asciidoctor -r asciidoctor-latex -a stem eq-stem.adoc
|
143
|
-
```
|
144
|
-
|
145
|
-
Now convert our first file into LaTeX by running the command
|
146
|
-
|
147
|
-
```
|
148
|
-
$ asciidoctor -r asciidoctor-latex -a stem=latexmath -b latex eq-latex.adoc
|
149
|
-
```
|
150
|
-
or simply with the wrapper script
|
151
|
-
```
|
152
|
-
$ asciidoctor-latex eq-latex.adoc
|
153
|
-
```
|
154
|
-
|
155
|
-
If all was successful, there will be a file `eq-latex.tex` alongside
|
156
|
-
your source file `eq-latex.adoc`. You can process it as you
|
157
|
-
would any LaTeX file.
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
== Examples
|
164
|
-
|
165
|
-
Below is a list of files which demsonstrate various features
|
166
|
-
of the converter. In some cases there are two versions, e.g.
|
167
|
-
`eq-latex.adoc` and `eq-stem.adoc`, each written in the
|
168
|
-
indicated format.footnote:[A missing entry in the table
|
169
|
-
may mean that a feature has not yet been implemented,
|
170
|
-
or that the file demonstrating it has not yet been
|
171
|
-
written and/or tested.] In other cases, there
|
172
|
-
is the same file appears in both the LaTeX
|
173
|
-
and the STEM columns. In those cases
|
174
|
-
the `-a stem` or `-a stem:latexmath` option
|
175
|
-
is not required unless there is mathematical
|
176
|
-
content.
|
177
|
-
|
178
|
-
One of the best ways
|
179
|
-
of learning how to use the features of
|
180
|
-
Asciidotor LaTeX is to use your
|
181
|
-
natural talent for reverse-engineering:
|
182
|
-
run the example, the compare the rendered
|
183
|
-
file and its source.
|
184
|
-
|
185
|
-
[options=header, width=80%, align=center]
|
186
|
-
|===
|
187
|
-
| LaTeX | STEM | Comments
|
188
|
-
| `eq-latex.adoc` | `eq-stem.adoc` | Basic equations
|
189
|
-
| `eqno-latex.adoc` | -- | Numbered equations
|
190
|
-
| `theorem-latex.adoc` | -- | Numbered theorems
|
191
|
-
| `env.adoc` | `env.adoc` | Env blocks
|
192
|
-
| `click.adoc` | `click.adoc` | Click blocks
|
193
|
-
| `code.adoc` | code.adoc` | Code blocks
|
194
|
-
|===
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
== Comments on the examples
|
199
|
-
|
200
|
-
=== eq-latex
|
201
|
-
|
202
|
-
Basic equations, both in-line, as with \(a^2 + b^2 = c^2\),
|
203
|
-
and displayed, as with
|
204
|
-
\[
|
205
|
-
a^n + b^n = c^n
|
206
|
-
\]
|
207
|
-
|
208
|
-
|
209
|
-
The environment `[env.equation]` is automatically
|
210
|
-
numbered by default, as in the examples below.
|
211
|
-
|
212
|
-
|
213
|
-
[env.equation]
|
214
|
-
--
|
215
|
-
a^3 + b^3 = c^3
|
216
|
-
--
|
217
|
-
|
218
|
-
|
219
|
-
[env.equation]
|
220
|
-
--
|
221
|
-
\int_0^1 x^n dx = \frac{1}{n}
|
222
|
-
--
|
223
|
-
|
224
|
-
Here is how the first equation is done:
|
225
|
-
----
|
226
|
-
[env.equation]
|
227
|
-
--
|
228
|
-
a^3 + b^3 = c^3
|
229
|
-
--
|
230
|
-
----
|
231
|
-
|
232
|
-
|
233
|
-
=== theorem-latex
|
234
|
-
|
235
|
-
Numbered theorems, like the those below.
|
236
|
-
|
237
|
-
|
238
|
-
[env.theorem]
|
239
|
-
--
|
240
|
-
\[
|
241
|
-
a + (b + c) = (a + b) + c
|
242
|
-
\]
|
243
|
-
--
|
244
|
-
|
245
|
-
[env.theorem]
|
246
|
-
--
|
247
|
-
\[
|
248
|
-
a(b+c) = ab + ac
|
249
|
-
\]
|
250
|
-
--
|
251
|
-
|
252
|
-
|
253
|
-
=== env
|
254
|
-
|
255
|
-
The file `env.adoc`, which only requires the converter,
|
256
|
-
illustrates general usage of the `env`-block. It gives
|
257
|
-
an automatically numbered and titled block. Thus repeated use
|
258
|
-
of `[env.objection]` gives this.
|
259
|
-
|
260
|
-
[env.objection]
|
261
|
-
--
|
262
|
-
This is hearsay.
|
263
|
-
--
|
264
|
-
|
265
|
-
[env.objection]
|
266
|
-
--
|
267
|
-
That evidence has not been admitted before the court.
|
268
|
-
--
|
269
|
-
|
270
|
-
The first objection was written like this:
|
271
|
-
|
272
|
-
----
|
273
|
-
[env.objection]
|
274
|
-
--
|
275
|
-
This is hearsay.
|
276
|
-
--
|
277
|
-
----
|
278
|
-
|
279
|
-
=== click
|
280
|
-
|
281
|
-
|
282
|
-
Click blocks are like `env`-blocks, except that
|
283
|
-
when you open a document, only the title,
|
284
|
-
not the body of the block, is displayed.
|
285
|
-
Click on the title to reveal the body;
|
286
|
-
clicking again will return the body
|
287
|
-
to its hidden sate. Click blocks
|
288
|
-
signal their presence by the blue
|
289
|
-
color of the title.
|
290
|
-
|
291
|
-
.Secret message
|
292
|
-
[click.message]
|
293
|
-
--
|
294
|
-
The path to wisdom is written on no
|
295
|
-
secret map.
|
296
|
-
--
|
297
|
-
|
298
|
-
Click blocks are useful in making up problem sets,
|
299
|
-
homework assignments, study guides, etc.
|
300
|
-
|
301
|
-
|
302
|
-
=== code
|
303
|
-
|
304
|
-
The file `code.adoc` illstrates the versatilty of the `[env]`
|
305
|
-
and `[click]` blocks which are used here in their `code` role.
|
306
|
-
We explain how we do the two blocks below and related pieces
|
307
|
-
of writing.
|
308
|
-
|
309
|
-
|
310
|
-
[env.code#iter]
|
311
|
-
--
|
312
|
-
def iter(f, a, n)
|
313
|
-
n.times do
|
314
|
-
a = f.call(a)
|
315
|
-
puts a
|
316
|
-
end
|
317
|
-
return a
|
318
|
-
end
|
319
|
-
--
|
320
|
-
|
321
|
-
.Results
|
322
|
-
[click.code%numbered]
|
323
|
-
--
|
324
|
-
irb> iter $g, 1.0, 6
|
325
|
-
1.5
|
326
|
-
1.4166666666666665
|
327
|
-
1.4142156862745097
|
328
|
-
1.4142135623746899
|
329
|
-
1.414213562373095
|
330
|
-
1.414213562373095
|
331
|
-
=> 1.414213562373095
|
332
|
-
--
|
333
|
-
|
334
|
-
|
335
|
-
== Issues
|
336
|
-
|
337
|
-
One should be able to tex this document wihout error
|
338
|
-
and obtain the desired output. This is very much a work
|
339
|
-
in progress. In particaulr, the following have not yet been resolved.
|
340
|
-
|
341
|
-
. Dollars signs used to illustrated command cause LaTeX to choke.
|
342
|
-
We need to map dollar sign to escaped dollar sig in
|
343
|
-
post-processing for tex. Or is there a better solution?
|
344
|
-
|
345
|
-
. The table block in Asciidoc is not implmented -- or rather,
|
346
|
-
is partially implemnted.
|
347
|
-
|
348
|
-
. The Click block is not implented in teh TeX output.
|
349
|
-
|
350
|
-
. The matrix environment in `eq-stem.adoc` does not render correctly.
|
351
|
-
|
352
|
-
. Fix title in latex mode
|
9
|
+
To learn more, consult the
|
10
|
+
http://noteshare.io/section/asciidoctor-latex-manual-intro[Asciidoctor-latex manual].
|
11
|
+
or run `asciidoctor-latex` on the `.adoc`
|
12
|
+
files in this directory.
|