Skip to content

Commit 89c1814

Browse files
committed
📝 Small changes in docs
1 parent f076670 commit 89c1814

File tree

10 files changed

+64
-53
lines changed

10 files changed

+64
-53
lines changed

README.adoc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,25 @@ Putting LaTeX equations in other places than a TeX document is not so easy. Ther
5252

5353
* {mathjax}
5454
** It uses native browser fonts and a lot of Css to replicate {latex} in the browser.
55+
** It also has an svg output option!
5556
* {katex}
5657
** Similar to {mathjax}, built by Khan Academy.
58+
** Does not have svg output.
5759
5860
### 🔍 STEM
5961
STEM stands for Science, Technology, Engineering, Mathematics, basicaly {latex}. There are two sections in the {adoc} documentation on STEM:
6062

6163
* {adoc-stem}
6264
* {adoctor-pdf-stem}
6365
64-
TLDR:
66+
The TLDR is:
6567

66-
* In {adoctor} (i.e. Html output), you can include math with `stem:[x+y]`. In the browser, {mathjax} is used to render the math, and frankly, it looks beautiful.
68+
* In {adoctor} (i.e. Html output), you can include math with pass:n[``stem:[ x+y``]``]``. In the browser, {mathjax} is used to render the math, and frankly, it looks beautiful.
6769
* Since {mathjax} uses browser fonts and Css, it doesn't work in Pdfs. There is an official {adoctor-math} package that provides this support. However, it is extremely quirky, and the ouput doesn't look very good (see a comparison of {adoc-math} and {adoctor-math} in the {example})
6870
** Some more references:
6971
*** https://github.com/asciidoctor/asciidoctor-mathematical/issues/45
7072
71-
### 🔍 Architecture
73+
### 🔍 adoc-math
7274
7375
That's where `adoc-math` comes in! I decided for:
7476
@@ -106,6 +108,14 @@ For more examples, see the {example}.
106108
107109
I don't speak Ruby 😞 If you would like to translate this library to Ruby, or at least an AsciiDoc macro that can get replaced by an image, so we cant get rid of the extra metacompilation step, I'd be more than happy to help!
108110
111+
> Why aren't inline cells avaiable "in line", such as "Let $x$ be a integer."?
112+
113+
This decision was chosen very early during development. It makes the parsing logic easier, and reduces the change that a paragraph containing two dollar signs will get replaced by LaTeX. In theory, it would be possible to add this; however, the output will still have at least one linebreak, since we want to comment out the source math. We would probably be better off just making an Asciidoc macro (`stem[]`, `m[]`, or something similar), but we need a Ruby speaker!
114+
115+
> What are `ex` units?
116+
117+
An ex unit is equal to the font size (height) of the lowercase `x` character. So it's roughly one half of a line? It's used in Mathjax's svgs (as the `width`, `height` and `vertical-align`) and in `adoc-math` to adjust the `vertical-align`.
118+
109119
> What about Windows?
110120
111121
I tried to be conscious of non-Posix platforms, but haven't tested in on Windows. Any behavioral discrepancies would be considered valid issues.

adoc_math/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def parse_args():
2121

2222
p.add_argument(
2323
"target_files",
24-
help="List of files to run `adoc-math` on. Inline cells (lines such as `$x+y$ tex`) or block cells (lines such as [`$$ amath\n`, `x+y\n`, `$$\n`]) will be read for contents, parsed for options, passed into MathJax@3, and (optionally) the svg transformed. The svg will then be saved to the output directory, and the source file modified: the cell will be commented out and an image macro with a reference to the svg will be inserted. 🤟🚀",
24+
help="List of files to run `adoc-math` on. Inline cells (lines such as `$x+y$ tex`) or block cells (line ranges such as [`$$ amath\n`, `x+y\n`, `$$\n`]) will be read for contents, parsed for options, passed into MathJax@3, and (optionally) the svg transformed. The svg will then be saved to the output directory, and the source file modified: the cell will be commented out and an image macro with a reference to the svg will be inserted. 🤟🚀",
2525
**list_of_files,
2626
)
2727

@@ -39,7 +39,7 @@ def parse_args():
3939

4040
p.add_argument(
4141
"--default-lang",
42-
help="Default language. Can be TEX (LaTeX) or AMATH (AsciiMath). Default: amath.",
42+
help="Default language. Can be `TEX` (LaTeX) or `AMATH` (AsciiMath). Default: amath.",
4343
choices=("tex", "amath"),
4444
)
4545

@@ -50,7 +50,7 @@ def parse_args():
5050

5151
p.add_argument(
5252
"--default-positioning",
53-
help='The raw svg, placed in the asciidoc document, usually gets rendered slightly above the line base (the baseline that characters which don\'t have lower parts (like "y" or "j" are above). Fortunately, Mathjax provides a "style" attribute in the svg (in the form of CSS), which is normally used by browsers to vertically align the math characters. I figured out a way to read this, process it, and achieve a similar effect in pdfs. The idea is that for simple symbols, like $x$, you usually want to position it. However, when you have a fraction ($\frac{a}{b}$), it usually looks better unpositioned. This option controls the default positioning for cells. Default: position.',
53+
help=r'The raw svg, placed in the asciidoc document, usually gets rendered slightly above the line base (the baseline that characters which don\'t have lower parts (like "y" or "j" are above). Fortunately, Mathjax provides a "style" attribute in the svg (in the form of CSS), which is normally used by browsers to vertically align the math characters. I figured out a way to read this, process it, and achieve a similar effect in pdfs. The idea is that for simple symbols, like $x$, you usually want to position it. However, when you have a fraction ($\frac{a}{b}$), it usually looks better unpositioned. This option controls the default positioning for cells. Default: position.',
5454
choices=("position", "dont_position"),
5555
)
5656

@@ -61,13 +61,13 @@ def parse_args():
6161

6262
p.add_argument(
6363
"--default-alignment",
64-
help="This option controls the default *horizontal* alignment of *block* cells. In particuar, it uses Asciidoc's image:...[align=(left|center|right)] API. Default: center.",
64+
help="This option controls the default *horizontal* alignment of *block* cells. In particuar, it uses Asciidoc's `image:...[align=(left|center|right)]` API. Default: center.",
6565
choices=("left", "center", "right"),
6666
)
6767

6868
p.add_argument(
6969
"--default-max-lines",
70-
help="To ensure that you don't forget to close a cell, there is an option to set the maximum number of lines that a cell can have. This option sets the default value, but it can be overridden: as `$$max_lines=10\nx\n$$`. Max lines option (either through CLI or through a cell attribute) has no effect on inline cells, since they span just one line. Default: 6.",
70+
help=r"If you forget to close a cell, it can be difficult to find the culprit. To prevent this, there is an option to set the maximum number of lines that a cell can have. This option sets the default value, but it can be overridden: as `$$max_lines=10\nx\n$$`. The `max_lines` option (set either through CLI or through a cell attribute) has no effect on inline cells, since they span just one line. Default: 6.",
7171
)
7272

7373
p.add_argument(

adoc_math/_common/b_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .c_constants import *
1+
from .a_imports import *
22

33
OptionsRaw = NewType("OptionsRaw", str)
44
OptionRaw = NewType("OptionRaw", str)

adoc_math/_common/c_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .a_imports import *
1+
from .b_types import *
22

33
LOGGING_LEVEL = logging.DEBUG
44

adoc_math/_common/d_exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .b_types import *
1+
from .c_constants import *
22

33

44
class AdocMathException(Exception):

example/adoc-math-example.pdf

1.31 KB
Binary file not shown.

example/post.adoc

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Header
22
# Example
3-
:pdf-page-size: 9in x 17in
3+
:pdf-page-size: 9in x 17.5in
44
:pdf-theme: pdf-theme.yml
55
:stem:
66

@@ -20,19 +20,24 @@ The purpose of this example is to compare {adoc-math} and {adoctor-math}, and to
2020
We are about to discuss the famous <<cauchy-schwarz-ineq>>.
2121

2222
*Theorem {counter:counter-thms} (Cauchy-Schwarz Inequality)* Let
23-
$n$ vertical_align_offset = -0.4ex
23+
// $n$ vertical_align_offset = -0.4ex
24+
image:imgs/adoc-math/a_inline_amath_n_f5d15920.svg[]
2425
be a non-negative integer, and let
25-
$a_0, a_1, ..., a_n,$ vertical_align_offset = -0.7ex
26-
$b_0, b_1, ..., b_n in bbb "R"$
26+
// $a_0, a_1, ..., a_n,$ vertical_align_offset = -0.7ex
27+
image:imgs/adoc-math/a_inline_amath_a_0a_7458f93c.svg[]
28+
// $b_0, b_1, ..., b_n in bbb "R"$
29+
image:imgs/adoc-math/a_inline_amath_b_0b_986ceb00.svg[]
2730
where
28-
$bbb "R"$
31+
// $bbb "R"$
32+
image:imgs/adoc-math/a_inline_amath_bbbR_34f68880.svg[]
2933
is the set of real numbers. It follows that:
3034

3135
[#cauchy-schwarz-ineq]
3236
.Cauchy-Schwarz Inequality
33-
$$
34-
(a_0^2 + a_1^2 + ... + a_n^2)(b_0^2 + b_1^2 + ... + b_n^2) ≥ (a_0b_0 + a_1b_1 + ... + a_nb_n)^2
35-
$$
37+
// $$
38+
// (a_0^2 + a_1^2 + ... + a_n^2)(b_0^2 + b_1^2 + ... + b_n^2) ≥ (a_0b_0 + a_1b_1 + ... + a_nb_n)^2
39+
// $$
40+
image::imgs/adoc-math/b_block_amath_(a_0_6354bc50.svg[align=center]
3641

3742
### `asciidoctor-mathematical`
3843

@@ -66,7 +71,8 @@ a|
6671
----
6772
a|
6873
[.text-center]
69-
$a/b$
74+
// $a/b$
75+
image:imgs/adoc-math/a_inline_amath_ab_dd460eca.svg[]
7076
a|
7177
* The default language is {amath}.
7278
* Inline cells start with a `$`, and end with a `$`.
@@ -79,7 +85,8 @@ a|
7985
----
8086
a|
8187
[.text-center]
82-
$a/b$ amath
88+
// $a/b$ amath
89+
image:imgs/adoc-math/a_inline_amath_ab_bbcbf77a.svg[]
8390
.2+a|
8491
* Options come after the last `$` in inline cells.
8592
* You can override the default language with
@@ -99,7 +106,8 @@ a|
99106
----
100107
a|
101108
[.text-center]
102-
$\dfrac{a}{b}$ tex
109+
// $\dfrac{a}{b}$ tex
110+
image:imgs/adoc-math/a_inline_tex_dfra_c0bb0f86.svg[]
103111

104112
// Row
105113
a|
@@ -109,7 +117,8 @@ a|
109117
----
110118
a|
111119
[.text-center]
112-
$a/b$ scale = 150%
120+
// $a/b$ scale = 150%
121+
image:imgs/adoc-math/a_inline_amath_ab_3888804f.svg[]
113122
a|
114123
* You can scale your math.
115124

@@ -121,7 +130,8 @@ a|
121130
----
122131
a|
123132
[.text-center]
124-
$a/b$ vertical_align_offset = 1ex
133+
// $a/b$ vertical_align_offset = 1ex
134+
image:imgs/adoc-math/a_inline_amath_ab_db32d819.svg[]
125135
a|
126136
* You can move your math up or down.
127137

@@ -134,9 +144,10 @@ sum_(i=1)^n i^3=((n(n+1))/2)^2
134144
{empty}$$
135145
----
136146
a|
137-
$$ amath
138-
sum_(i=1)^n i^3=((n(n+1))/2)^2
139-
$$
147+
// $$ amath
148+
// sum_(i=1)^n i^3=((n(n+1))/2)^2
149+
// $$
150+
image::imgs/adoc-math/b_block_amath_sum__57ebec07.svg[align=center]
140151
a|
141152
* Block cells are written between lines of `$$`; the options will be on the first line.
142153

@@ -149,9 +160,10 @@ a^2 + b^2 = c^2
149160
{empty}$$
150161
----
151162
a|
152-
$$ amath, right
153-
a^2 + b^2 = c^2
154-
$$
163+
// $$ amath, right
164+
// a^2 + b^2 = c^2
165+
// $$
166+
image::imgs/adoc-math/b_block_amath_a2+b_c62fc84c.svg[align=right]
155167
a|
156168
* You can horizontally align block cells.
157169

@@ -170,21 +182,16 @@ a|
170182
{empty}$$
171183
----
172184
a|
173-
$$ amath, max_lines = 8
174-
1 +
175-
2 +
176-
3 +
177-
4 +
178-
5 +
179-
6 =
180-
21
181-
$$
185+
// $$ amath, max_lines = 8
186+
// 1 +
187+
// 2 +
188+
// 3 +
189+
// 4 +
190+
// 5 +
191+
// 6 =
192+
// 21
193+
// $$
194+
image::imgs/adoc-math/b_block_amath_1+2+_9f90f2f1.svg[align=center]
182195
a|
183196
* If you forget to close a cell, it can be difficult to find the culprit. To prevent this, block cells have a `max_lines` parameter (by default 6). You can override this with `max_lines=X`.
184-
185-
186-
// Row
187-
| sum_(i=1)^n i^3=((n(n+1))/2)^2
188-
a|
189-
// $sum_(i=1)^n i^3=((n(n+1))/2)^2$
190-
|===
197+
|===

example/pre.adoc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Header
22
# Example
3-
:pdf-page-size: 9in x 17in
3+
:pdf-page-size: 9in x 17.5in
44
:pdf-theme: pdf-theme.yml
55
:stem:
66

@@ -181,10 +181,4 @@ $$ amath, max_lines = 8
181181
$$
182182
a|
183183
* If you forget to close a cell, it can be difficult to find the culprit. To prevent this, block cells have a `max_lines` parameter (by default 6). You can override this with `max_lines=X`.
184-
185-
186-
// Row
187-
| sum_(i=1)^n i^3=((n(n+1))/2)^2
188-
a|
189-
// $sum_(i=1)^n i^3=((n(n+1))/2)^2$
190184
|===
10.8 KB
Loading
6.16 KB
Loading

0 commit comments

Comments
 (0)