asciidoctor-latex 1.5.0.dev

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3e5580fadffd5a0ff5f968e8672225c1b387a434
4
+ data.tar.gz: 67f763319571a6cb2ee224bf79b5044d945e82fe
5
+ SHA512:
6
+ metadata.gz: f7aeb65738dea61724b8295e2f6fad7eebabd95b7daa0195a6faebee124194a37d44cf0fe50a7cb1498e7454d39b767728e8f0ac873ad4456c51730ff3ab138b
7
+ data.tar.gz: e47b504a4b7b0752656d675c632aef95e3f5247e00bed9785069c2102980427edbe9f6e5640fbf068de088dc9c601e9d49f1c6b1e8b5cf6cc21a594238057e36
data/LICENSE.adoc ADDED
@@ -0,0 +1,22 @@
1
+ .The MIT License
2
+ ....
3
+ Copyright (C) 2014 James Carlson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ ....
data/README.adoc ADDED
@@ -0,0 +1,213 @@
1
+ = AsciiDoc to LaTeX Converter for Asciidoctor
2
+ James Carlson
3
+
4
+ :numbered:
5
+ :toc2:
6
+ :stem:
7
+
8
+ == Purpose
9
+
10
+ The aim of the LaTeX converter is to transform an AsciiDoc document containing
11
+ mathematical notation into a LaTeX document.
12
+ The converter also adds to Asciidoctor's facilities for handling mathematical
13
+ notation when rendered as HTML. Among these are the automatic numbering of theorems
14
+ and equations.
15
+ Please see the file [path]_manual.adoc_ in this repository for additional details
16
+ and for technical information.
17
+
18
+ For examples and a quick start guide, see <<Getting started>>.
19
+ Below, we describe the <<Document format,document formats>> used
20
+ for mathematics and the <<Command for rendering,commands>> for rendering a document into HTML or LaTeX.
21
+
22
+
23
+ == Installation
24
+
25
+ === Using Rubygems
26
+
27
+ _asciidoctor-latex has not been released yet_
28
+
29
+ === From repository
30
+
31
+ If you would like to install a development version from the repository, use:
32
+
33
+ $ git clone https://github.com/asciidoctor/asciidoctor-latex.git
34
+ $ cd asciidoctor-latex
35
+ $ gem build asciidoctor-latex.gemspec
36
+ $ gem install *.gem
37
+
38
+
39
+ == Getting started
40
+
41
+ The directory `try-out` contains a set of examples which
42
+ show what Asciidoctor LateX can do. Consult the `README` file
43
+ for directions on how to render an examples as
44
+ HTML or LaTeX. By comparing the source and rendered files,
45
+ you will quickly see how to write Asciidoc LaTeX.
46
+
47
+
48
+
49
+ == Document format
50
+
51
+ Asciidoctor supports two closely-related math formats, [blue]#AsciiMath# and [blue]#LaTeX#.
52
+ For in-line mathematics, the first looks like `+++stem:[ a^2 + b^2 = c^2 ]+++`, while the
53
+ second looks like `$ a^2 + b^2 = c^2 $`. Both render as stem:[ a^2 + b^2 = c^2 ].
54
+ For displayed text, one can use
55
+ ----
56
+ [stem]
57
+ ++++
58
+ e^{2\pi \sqrt{-1}} = 1
59
+ ++++
60
+ ----
61
+ or
62
+ ----
63
+ \[
64
+ e^{2\pi \sqrt{-1}} = 1
65
+ \]
66
+ ----
67
+ Both render as
68
+ \[
69
+ e^{2\pi \sqrt{-1}} = 1
70
+ \]
71
+ _Please note that the formulae above will not render properly
72
+ if you are reading it on GitHub. It will, however, render properly if you run
73
+ this file through Asciidoctor_.
74
+
75
+ == Asciidoctor environments
76
+
77
+ Asciidoctor supports an `env` construct that maps to LaTeX environments.
78
+ Thus
79
+ ----
80
+ [env.theorem]
81
+ --
82
+ There exist infinitely many prime numbers.
83
+ --
84
+ ----
85
+ renders as an automatically numbered theorem:
86
+
87
+ [env.theorem]
88
+ --
89
+ There exist infinitely many prime numbers.
90
+ --
91
+
92
+ Likewise, using `[env.definition]`, we obtain
93
+ [env.definition]
94
+ --
95
+ An integer $n$ is *prime* if (a) it is not $\pm 1$
96
+ and (b) it has no divisors other
97
+ than $\pm 1$ and $\pm n$.
98
+ --
99
+
100
+ For numbered equations, use `[env.equation]` like this
101
+
102
+ ----
103
+ [env.equation]
104
+ --
105
+ a^{p-1} \equiv 1\ \text{mod}\ p
106
+ --
107
+ ----
108
+
109
+ to obtain the rendered text
110
+
111
+ [env.equation]
112
+ --
113
+ a^{p-1} \equiv 1\ \text{mod}\ p
114
+ --
115
+
116
+
117
+
118
+ Except for `[env.equation]`, the TeX constructs `$ ... $` and
119
+ `\[ ... \]` can be used in `[env]` blocks.
120
+ For directions on making cross-references and labeling theorems, equations, etc., see
121
+ the `README` file in the `try-out` directory. For an extensive
122
+ example of the use of Asciidoctor LaTeX, see
123
+ http://www.noteshare.io/section/the-fundamental-class-of-projective-space[this].
124
+ All of these constructs discussed above are translated into native LaTeX when
125
+ the converter is used to produuce tex output.
126
+
127
+
128
+
129
+ == Click blocks
130
+
131
+ Click blocks are similar to `[env]` blocks excep that the body of
132
+ the block is not displayed until the user clicks on the heading.
133
+ The heading of a click block is displayed in blue. Once a click
134
+ block is "opened", it can be closed by clicking again on the heading.
135
+
136
+ [click.comment]
137
+ --
138
+ It is sometimes useful to "hide" a comment in a click block
139
+ so as not to unduly disturb the flow of the prose. Click
140
+ blocks are also useful for problem sets, since one
141
+ can make hints, solutions, etc. clickable.
142
+ --
143
+
144
+ The source for the above comment is
145
+
146
+ ----
147
+ [click.comment]
148
+ --
149
+ It is sometimes useful to "hide" a comment ...
150
+ --
151
+ ----
152
+
153
+ The default for click blocks is not to number them.
154
+ See the file `click.adoc` in the `try-out` directory
155
+ for more information.
156
+
157
+ == Commands for rendering
158
+
159
+ Asciidoc math files can be rendered
160
+
161
+ . as HTML (the default)
162
+ . with the LaTeX converter additions such as automatic theorem numbering
163
+ . as LaTeX
164
+ +
165
+ *Note.* Forthcoming releases will make it possible to render
166
+ +
167
+ . as PDF
168
+ . as EPUB3 (Electronic book)
169
+
170
+
171
+ === HTML output
172
+
173
+ To render a file into HTML, the Asciidoctor default,
174
+ use the usual `asciidoctor` command with this option:
175
+ ```
176
+ $ asciidoctor -a stem foo.adoc
177
+ ```
178
+ or with this
179
+ ```
180
+ $ asciidoctor -a stem=latexmath foo.adoc
181
+ ```
182
+ depending on the format.
183
+
184
+
185
+ === LaTeX converter additions
186
+
187
+ To employ the converter additions such as automatic theorem numbering, use
188
+ ```
189
+ $ asciidoctor -r asciidoctor-latex -a stem=latexmath -b html foo.adoc
190
+ ```
191
+ or
192
+ ```
193
+ $ asciidoctor-latex -b html foo.adoc
194
+ ```
195
+
196
+
197
+ === LaTeX output
198
+
199
+ To render a file into LaTeX, use the `-r` (require rubygem) and `-b` (backend) option, e.g.:
200
+ ```
201
+ $ asciidoctor -r asciidoctor-latex -a stem=latexmath -b latex foo.adoc
202
+ ```
203
+ or simply with the wrapper script:
204
+ ```
205
+ $ asciidoctor-latex foo.adoc
206
+ ```
207
+
208
+
209
+ == Switches
210
+
211
+ Switch `:stem:` processing on by puttinng the text `:stem:`
212
+ in your file. To turn the switch on and set it to `latexmath`, say
213
+ instead of `stem:latexmth`.
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
3
+
4
+ require 'rake/clean'
5
+ require 'bundler/gem_tasks'
6
+
7
+ begin
8
+ require 'yard'
9
+ # options are defined in .yardopts
10
+ YARD::Rake::YardocTask.new
11
+
12
+ task :doc => :yard
13
+ rescue LoadError => e
14
+ warn "#{e.path} is not available"
15
+ end
16
+
17
+ begin
18
+ require 'asciidoctor-doctest'
19
+ require 'asciidoctor-latex'
20
+ require 'rake/testtask'
21
+
22
+ namespace :doctest do
23
+ Rake::TestTask.new(:latex) do |t|
24
+ t.description = 'Run integration tests for LaTeX output.'
25
+ t.pattern = 'test/latex_test.rb'
26
+ t.libs << 'test'
27
+ end
28
+
29
+ Rake::TestTask.new(:html) do |t|
30
+ t.description = 'Run integration tests for HTML output.'
31
+ t.pattern = 'test/html_test.rb'
32
+ t.libs << 'test'
33
+ end
34
+ end
35
+
36
+ task :doctest => [ 'doctest:latex', 'doctest:html' ]
37
+ task :test => :doctest
38
+ task :default => :test
39
+
40
+ namespace :generate do
41
+ DocTest::GeneratorTask.new(:latex) do |t|
42
+ t.converter_opts[:backend_name] = :latex
43
+ t.output_suite = DocTest::Latex::ExamplesSuite.new(examples_path: 'test/examples/tex')
44
+ t.examples_path.unshift 'test/examples/adoc' # extra input examples
45
+ end
46
+
47
+ DocTest::GeneratorTask.new(:html) do |t|
48
+ t.converter_opts[:backend_name] = :html
49
+ t.output_suite = DocTest::HTML::ExamplesSuite.new(examples_path: 'test/examples/html')
50
+ t.examples_path = ['test/examples/asciidoc-html'] # input examples
51
+ end
52
+ end
53
+ rescue LoadError => e
54
+ warn "#{e.path} is not available"
55
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ LIB_DIR = File.expand_path('../lib', __dir__)
4
+ $LOAD_PATH.unshift LIB_DIR unless $LOAD_PATH.include? LIB_DIR
5
+
6
+ require 'asciidoctor/latex'
7
+ require 'asciidoctor/cli'
8
+
9
+ DEFAULT_OPTS = {
10
+ backend: 'latex',
11
+ attributes: { 'stem' => 'latexmath' }
12
+ }
13
+ options = Asciidoctor::Cli::Options.new DEFAULT_OPTS
14
+ # FIXME This is a really bizarre API. Please make me simpler.
15
+ if (options.parse! ARGV) == 0
16
+ exit 0
17
+ else
18
+ invoker = Asciidoctor::Cli::Invoker.new options
19
+ GC.start
20
+ invoker.invoke!
21
+ exit invoker.code
22
+ end
@@ -0,0 +1,42 @@
1
+
2
+ % Needed for Asciidoc
3
+
4
+ \newcommand{\admonition}[2]{\textbf{#1}: {#2}}
5
+ \newcommand{\rolered}[1]{ \textcolor{red}{#1} }
6
+
7
+ \newtheorem{theorem}{Theorem}
8
+ \newtheorem{proposition}{Proposition}
9
+ \newtheorem{corollary}{Corollary}
10
+ \newtheorem{lemma}{Lemma}
11
+ \newtheorem{definition}{Definition}
12
+ \newtheorem{conjecture}{Conjecture}
13
+ \newtheorem{problem}{Problem}
14
+ \newtheorem{example}{Example}
15
+ \newtheorem{remark}{Remark}
16
+ \newtheorem{note}{Note}
17
+
18
+
19
+ %%%
20
+ % Extended quote environment with author
21
+ \def\signed#1{{\leavevmode\unskip\nobreak\hfil\penalty50\hskip2em
22
+ \hbox{}\nobreak\hfil\raise-3pt\hbox{(#1)}%
23
+ \parfillskip=0pt \finalhyphendemerits=0 \endgraf}}
24
+
25
+ \newsavebox\mybox
26
+ \newenvironment{aquote}[1]
27
+ {\savebox\mybox{#1}\begin{quotation}}
28
+ {\signed{\usebox\mybox}\end{quotation}}
29
+ %%%
30
+
31
+ \newenvironment{preamble}
32
+ {}
33
+ {}
34
+
35
+ %% http://tex.stackexchange.com/questions/99809/box-or-sidebar-for-additional-text
36
+ \newenvironment{sidebar}[1][r]
37
+ {\wrapfigure{#1}{0.5\textwidth}\tcolorbox}
38
+ {\endtcolorbox\endwrapfigure}
39
+
40
+ %% Style
41
+ \parindent0pt
42
+ \parskip8pt
@@ -0,0 +1,45 @@
1
+ %% A minimal LaTeX preamble
2
+
3
+ \documentclass[11pt]{amsart}
4
+ \usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
5
+ \geometry{letterpaper} % ... or a4paper or a5paper or ...
6
+ %\geometry{landscape} % Activate for for rotated page geometry
7
+ %\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
8
+ \usepackage{graphicx}
9
+ \graphicspath{ {images/} }
10
+ \usepackage{wrapfig}
11
+ \usepackage{tcolorbox}
12
+ \usepackage{lipsum}
13
+ \usepackage{amssymb}
14
+ \usepackage{epstopdf}
15
+ \usepackage{color}
16
+ \usepackage{alltt}
17
+ \usepackage[version=3]{mhchem}
18
+ \usepackage{amsmath}
19
+
20
+ % Needed to properly typeset
21
+ % standard unicode characters:
22
+ %
23
+ \RequirePackage{fix-cm}
24
+ \usepackage{fontspec}
25
+ \usepackage[Latin,Greek]{ucharclasses}
26
+ %
27
+ % NOTE: you must also use xelatex
28
+ % as the typesetting engine
29
+
30
+
31
+ % \usepackage{fontspec}
32
+ % \usepackage{polyglossia}
33
+ % \setmainlanguage{en}
34
+
35
+ \usepackage{hyperref}
36
+ \hypersetup{
37
+ colorlinks=true,
38
+ linkcolor=blue,
39
+ filecolor=magenta,
40
+ urlcolor=cyan,
41
+ }
42
+
43
+ \DeclareGraphicsExtensions{.png, .jpg, jpeg, .pdf}
44
+
45
+ %% \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
@@ -0,0 +1,44 @@
1
+ %% A minimal LaTeX preamble
2
+
3
+ \documentclass[11pt]{amsbook}
4
+ \usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
5
+ \geometry{letterpaper} % ... or a4paper or a5paper or ...
6
+ %\geometry{landscape} % Activate for for rotated page geometry
7
+ %\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
8
+ \usepackage{graphicx}
9
+ \graphicspath{ {images/} }
10
+ \usepackage{wrapfig}
11
+ \usepackage{tcolorbox}
12
+ \usepackage{lipsum}
13
+ \usepackage{amssymb}
14
+ \usepackage{epstopdf}
15
+ \usepackage{color}
16
+ \usepackage{alltt}
17
+ \usepackage[version=3]{mhchem}
18
+ \usepackage{amsmath}
19
+
20
+ % Needed to properly typeset
21
+ % standard unicode charaters:
22
+ %
23
+ \RequirePackage{fix-cm}
24
+ \usepackage{fontspec}
25
+ \usepackage[Latin,Greek]{ucharclasses}
26
+ %
27
+ % NOTE: you must also use xelatex
28
+ % as the typesetting engine
29
+
30
+
31
+ % \usepackage{fontspec}
32
+ %\usepackage{polyglossia}
33
+ %\setmainlanguage{en}
34
+ \usepackage{hyperref}
35
+ \hypersetup{
36
+ colorlinks=true,
37
+ linkcolor=blue,
38
+ filecolor=magenta,
39
+ urlcolor=cyan,
40
+ }
41
+
42
+ \DeclareGraphicsExtensions{.png, .jpg, jpeg, .pdf}
43
+
44
+ %% \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}