You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/using/intro.md
+33-7Lines changed: 33 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -224,20 +224,46 @@ To do so, use the keywords beginning `myst_`.
224
224
- `None`
225
225
- [URI schemes](https://en.wikipedia.org/wiki/List_of_URI_schemes) that will be recognised as external URLs in `[](scheme:loc)` syntax, or set `None` to recognise all.
226
226
Other links will be resolved as internal cross-references.
227
-
* - `myst_html_img`
227
+
* - `myst_html_img_enable`
228
228
- `False`
229
229
- Convert HTML `<img>` elements to sphinx image nodes, see the [image syntax](syntax/images) for details
230
-
* - `myst_math_delimiters`
231
-
- "dollars"
232
-
- Delimiters for parsing math, see the [Math syntax](syntax/math) for details
233
-
* - `myst_amsmath_enable`
234
-
- `False`
235
-
- Enable direct parsing of [amsmath LaTeX environments](https://ctan.org/pkg/amsmath), [see here](syntax/amsmath) for details.
236
230
* - `myst_admonition_enable`
237
231
- `False`
238
232
- Enable admonition style directives, [see here](syntax/admonitions) for details.
239
233
`````
240
234
235
+
Math specific, see the [Math syntax](syntax/math) for more details:
236
+
237
+
`````{list-table}
238
+
:header-rows: 1
239
+
240
+
* - Option
241
+
- Default
242
+
- Description
243
+
* - `myst_dmath_enable`
244
+
- `True`
245
+
- Enable parsing of dollar `$` and `$$` encapsulated math
- If False then inline math will only be parsed if there are no initial/final spaces,
252
+
e.g. `$a$` but not `$ a$` or `$a $`
253
+
* - `myst_dmath_allow_digits`
254
+
- `True`
255
+
- If False then inline math will only be parsed if there are no initial/final digits,
256
+
e.g. `$a$` but not `1$a$` or `$a$2` (this is useful for using `$` as currency)
257
+
* - `myst_amsmath_enable`
258
+
- `False`
259
+
- Enable direct parsing of [amsmath LaTeX environments](https://ctan.org/pkg/amsmath)
260
+
* - `myst_override_mathjax`
261
+
- `True`
262
+
- If using [sphinx.ext.mathjax](https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax) (the default) then `mathjax_config` will be overridden,
263
+
to ignore `$` delimiters and LaTeX environments, which should instead be handled by
264
+
`myst_dmath_enable` and `myst_amsmath_enable` respectively.
265
+
`````
266
+
241
267
### Disable markdown syntax for the parser
242
268
243
269
If you'd like to either enable or disable custom markdown syntax, use `myst_disable_syntax`.
Copy file name to clipboardExpand all lines: docs/using/syntax.md
+91-27Lines changed: 91 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -31,8 +31,8 @@ described in the [CommonMark Spec](https://spec.commonmark.org/0.29/), which the
31
31
32
32
Block tokens span multiple lines of content. They are broken down into two sections:
33
33
34
-
* {ref}`extended-block-tokens` contains *extra* tokens that are not in CommonMark.
35
-
* {ref}`commonmark-block-tokens` contains CommonMark tokens that also work, for reference.
34
+
- {ref}`extended-block-tokens` contains *extra* tokens that are not in CommonMark.
35
+
- {ref}`commonmark-block-tokens` contains CommonMark tokens that also work, for reference.
36
36
37
37
In addition to these summaries of block-level syntax, see {ref}`extra-markdown-syntax`.
38
38
@@ -181,8 +181,8 @@ we have shown equivalent rST syntax for many MyST markdown features below.
181
181
Span (or inline) tokens are defined on a single line of content. They are broken down into two
182
182
sections below:
183
183
184
-
* {ref}`extended-span-tokens` contains *extra* tokens that are not in CommonMark.
185
-
* {ref}`commonmark-span-tokens` contains CommonMark tokens that also work, for reference.
184
+
- {ref}`extended-span-tokens` contains *extra* tokens that are not in CommonMark.
185
+
- {ref}`commonmark-span-tokens` contains CommonMark tokens that also work, for reference.
186
186
187
187
In addition to these summaries of inline syntax, see {ref}`extra-markdown-syntax`.
188
188
@@ -648,19 +648,25 @@ header-rows: 1
648
648
649
649
(syntax/math)=
650
650
651
-
###Math shortcuts
651
+
## Math shortcuts
652
652
653
-
The style of math parsing is governed by the `myst_math_delimiters` option set in the sphinx `conf.py`[configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html).
654
-
The two common settings are:
653
+
Math is parsed by setting, in the sphinx `conf.py`[configuration file](https://www.sphinx-doc.org/en/master/usage/configuration.html) one or both of:
655
654
656
-
-`myst_math_delimiters = "dollars"` (default)
657
-
- inline: `$...$` or `$$...$$`
658
-
- display: `$$...$$`
659
-
- display + equation label: `$$...$$ (1)`
660
-
-`myst_math_delimiters = "brackets"`
661
-
- inline: `\(...\)`
662
-
- display: `\[...\]`
663
-
- display + equation label: `\[...\] (1)`
655
+
-`myst_dmath_enable=True` (the default) for parsing of dollar `$` and `$$` encapsulated math.
656
+
-`myst_amsmath_enable=True` (off by default) for direct parsing of [amsmath LaTeX environments](https://ctan.org/pkg/amsmath).
657
+
658
+
These options enable their respective Markdown parser plugins, as detailed in the [markdown-it plugin guide](markdown_it:md/plugins).
659
+
660
+
### Dollar delimited math
661
+
662
+
Enabling dollar math will parse the following syntax:
663
+
664
+
- Inline math: `$...$`
665
+
- Display (block) math: `$$...$$`
666
+
667
+
Additionally if `myst_dmath_allow_labels=True` is set (the default):
668
+
669
+
- Display (block) math with equation label: `$$...$$ (1)`
664
670
665
671
For example, `$x_{hey}=it+is^{math}$` renders as $x_{hey}=it+is^{math}$.
666
672
This is equivalent to writing:
@@ -669,11 +675,14 @@ This is equivalent to writing:
669
675
{math}`x_{hey}=it+is^{math}`
670
676
```
671
677
672
-
```{tip}
673
-
Math can be escaped (negated) by adding a `\` before the first symbol, e.g. `\$a$` renders as \$a$.
674
-
```
678
+
:::{admonition,tip} Escaping Dollars
679
+
Math can be escaped (negated) by adding a `\` before the first symbol, e.g. `\$a$` renders as \$a\$.
680
+
Escaping can also be used inside math, e.g. `$a=\$3$` renders as $a=\$3$.
675
681
676
-
Block-level math can then be provided with `$$` signs that wrap the math block you'd like to parse.
682
+
Conversely `\\` will negate the escaping, so `\\$a$` renders as \\$a$.
683
+
:::
684
+
685
+
Block-level math can be specified with `$$` signs that wrap the math block you'd like to parse.
677
686
For example:
678
687
679
688
```latex
@@ -721,9 +730,17 @@ $$ (eqn:best)
721
730
722
731
This is the best equation {eq}`eqn:best`
723
732
733
+
There are a few other options available to control dollar math parsing:
734
+
735
+
`myst_dmath_allow_space=False`, will cause inline math to only be parsed if there are no initial / final spaces, e.g. `$a$` but not `$ a$` or `$a $`.
736
+
737
+
`myst_dmath_allow_digits=False`, will cause inline math to only be parsed if there are no initial / final digits, e.g. `$a$` but not `1$a$` or `$a$2`.
738
+
739
+
These options can both be useful if you also wish to use `$` as a unit of currency.
740
+
724
741
(syntax/amsmath)=
725
742
726
-
### Direct LaTeX Math (optional)
743
+
### Direct LaTeX Math
727
744
728
745
You can enable direct parsing of [amsmath](https://ctan.org/pkg/amsmath) LaTeX equations by setting `myst_amsmath_enable = True` in your sphinx `conf.py`.
729
746
These top-level math environments will then be directly parsed:
@@ -763,9 +780,56 @@ a_{21}& =b_{21}&
763
780
We hope to implement this in a future update (see [executablebooks/MyST-Parser#202](https://github.com/executablebooks/MyST-Parser/issues/202))!
764
781
:::
765
782
783
+
### Math in other block elements
784
+
785
+
Math will also work when nested in other block elements, like lists or quotes:
786
+
787
+
```md
788
+
- $$ a = 1 $$
789
+
- \begin{gather*}
790
+
a_1=b_1+c_1\\a_2=b_2+c_2-d_2+e_2
791
+
\end{gather*}
792
+
793
+
> $$ a = 1 $$
794
+
> \begin{gather*}
795
+
a_1=b_1+c_1\\a_2=b_2+c_2-d_2+e_2
796
+
\end{gather*}
797
+
```
798
+
799
+
- $$ a = 1 $$
800
+
- \begin{gather*}
801
+
a_1=b_1+c_1\\a_2=b_2+c_2-d_2+e_2
802
+
\end{gather*}
803
+
804
+
> $$ a = 1 $$
805
+
> \begin{gather*}
806
+
a_1=b_1+c_1\\a_2=b_2+c_2-d_2+e_2
807
+
\end{gather*}
808
+
809
+
### Mathjax and math parsing
810
+
811
+
When building HTML using the [sphinx.ext.mathjax](https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax) extension (enabled by default), its default configuration is to also search for `$` delimiters and LaTeX environments (see [the tex2jax preprocessor](https://docs.mathjax.org/en/v2.7-latest/options/preprocessors/tex2jax.html#configure-tex2jax)).
812
+
813
+
Since such parsing is already covered by the plugins above, MyST-Parser disables this behaviour by overriding the `mathjax_config` option with:
814
+
815
+
```python
816
+
mathjax_config = {
817
+
"tex2jax": {
818
+
"inlineMath": [["\\(", "\\)"]],
819
+
"displayMath": [["\\[", "\\]"]],
820
+
"processRefs": False,
821
+
"processEnvironments": False,
822
+
}
823
+
}
824
+
```
825
+
826
+
Since these delimiters are how `sphinx.ext.mathjax` wraps the math content in the built HTML documents.
827
+
828
+
To inhibit this override, set `myst_override_mathjax=False`.
829
+
766
830
(syntax/frontmatter)=
767
831
768
-
### Front Matter
832
+
## Front Matter
769
833
770
834
This is a YAML block at the start of the document, as used for example in
771
835
[jekyll](https://jekyllrb.com/docs/front-matter/). Sphinx intercepts these data and
@@ -786,7 +850,7 @@ This is an orphan document, not specified in any toctrees.
786
850
787
851
(syntax/comments)=
788
852
789
-
### Comments
853
+
## Comments
790
854
791
855
You may add comments by putting the `%` character at the beginning of a line. This will
792
856
prevent the line from being parsed into the output document.
@@ -819,7 +883,7 @@ another line
819
883
820
884
(syntax/blockbreaks)=
821
885
822
-
### Block Breaks
886
+
## Block Breaks
823
887
824
888
You may add a block break by putting `+++` at the beginning of a line.
825
889
This constuct's intended use case is for mapping to cell based document formats,
@@ -839,7 +903,7 @@ Is below, but it won't be parsed into the document.
839
903
840
904
(syntax/targets)=
841
905
842
-
### Targets and Cross-Referencing
906
+
## Targets and Cross-Referencing
843
907
844
908
Targets are used to define custom anchors that you can refer to elsewhere in your
845
909
documentation. They generally go before section titles so that you can easily refer
@@ -897,7 +961,7 @@ markdown: `[](syntax.md)` will result in: [](syntax.md).
897
961
898
962
(syntax/images)=
899
963
900
-
### Images
964
+
## Images
901
965
902
966
MyST provides a few different syntaxes for including images in your documentation, as explained below.
903
967
@@ -935,7 +999,7 @@ The final option is directly using HTML, which is also parsed by MyST.
935
999
This is usually a bad option, because the HTML is treated as raw text during the build process and so sphinx will not recognise that the image file is to be copied, and will not output the HTML into non-HTML output formats.
936
1000
937
1001
HTML parsing to the rescue!
938
-
By setting `myst_html_img = True` in the sphinx `conf.py` configuration file, MySt-Parser will attempt to convert any isolated `img` tags (i.e. not wrapped in any other HTML) to the internal representation used in sphinx.
1002
+
By setting `myst_html_img_enable = True` in the sphinx `conf.py` configuration file, MySt-Parser will attempt to convert any isolated `img` tags (i.e. not wrapped in any other HTML) to the internal representation used in sphinx.
0 commit comments