--- jupytext: formats: md:myst text_representation: extension: .md format_name: myst kernelspec: display_name: Python 3 language: python name: python3 --- (myst_cheatsheet)= # MyST cheat sheet ```{warning} Not written by [me (Lilian Besson)](https://besson.link/) ``` ## Headers ``````{list-table} :header-rows: 1 :widths: 20 15 15 * - Syntax - Example - Note * - ```md # Heading level 1 ## Heading level 2 ### Heading level 3 #### Heading level 4 ##### Heading level 5 ###### Heading level 6 ``` - ```md # MyST Cheat Sheet ``` - Level 1-6 headings, denoted by number of `#` `````` ## Target headers ``````{list-table} :header-rows: 1 :widths: 20 15 15 * - Syntax - Example - Note * - ```md (target_header)= ``` - ```md (myst_cheatsheet)= # MyST Cheat Sheet ``` - See {ref}`below ` how to reference target headers. `````` (ref/target_headers)= ### Referencing target headers Targets can be referenced with the [ref inline role](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref) which uses the section title by default: ```md {ref}`myst_cheatsheet` ``` You can specify the text of the target: ```md {ref}`MyST syntax lecture ` ``` Another alternative is to use Markdown syntax: ```md [MyST syntax lecture](myst_cheatsheet) ``` ## Quote ``````{list-table} :header-rows: 1 :widths: 20 20 10 * - Syntax - Example - Note * - ```md > text ``` - ```md > this is a quote ``` - quoted text `````` ## Thematic break ``````{list-table} :header-rows: 1 :widths: 20 15 15 * - Syntax - Example - Note * - ```md --- ``` - ```md This is the end of some text. --- ## New Header ``` - Creates a horizontal line in the output `````` ## Line comment ``````{list-table} :header-rows: 1 :widths: 20 15 15 * - Syntax - Example - Note * - ```md % text ``` - ```md a line % a comment another line ``` - See [Comments](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#syntax-comments) for more information. `````` ## Block break ``````{list-table} :header-rows: 1 :widths: 20 15 15 * - Syntax - Example - Result * - ```md +++ ``` - ```md This is an example of +++ {"meta": "data"} a block break ``` - This is an example of +++ {"meta": "data"} a block break `````` ## HTML block ``````{list-table} :header-rows: 1 :widths: 20 15 15 * - Syntax - Example - Result * - ```html text ``` - ```html

This is a paragraph

``` -

This is a paragraph

`````` ## Links ``````{list-table} :header-rows: 1 :widths: 20 20 10 * - Syntax - Example - Result * - ```md [text](target) ``` - ```md [Jupyter Book](https://jupyterbook.org) ``` - [Jupyter Book](https://jupyterbook.org) * - ```md [text](relative_path) ``` - ```md [PDF documentation](../advanced/pdf) ``` - [PDF documentation](../advanced/pdf) * - ```md [text](target "title") ``` - ```md [Jupyter Book](https://jupyterbook.org "JB Homepage") ``` - [Jupyter Book](https://jupyterbook.org "JB Homepage") * - ```md ``` - ```md ``` - * - ```md [text][key] ``` - ```md [Jupyter Book][intro_page] [intro_page]: https://jupyterbook.org ``` - [Jupyter Book][intro_page] [intro_page]: https://jupyterbook.org `````` ## Lists ### Ordered list ``````{list-table} :header-rows: 1 :widths: 20 20 * - Example - Result * - ```md 1. First item 2. Second item 1. First sub-item ``` - 1. First item 2. Second item 1. First sub-item * - ```md 1. First item 2. Second item * First sub-item ``` - 1. First item 2. Second item * First subitem `````` ### Unordered list ``````{list-table} :header-rows: 1 :widths: 20 20 * - Example - Result * - ```md * First item * Second item * First subitem ``` - * First item * Second item * First subitem * - ```md * First item 1. First subitem 2. Second subitem ``` - * First item 1. First subitem 2. Second subitem `````` ## Tables ``````{list-table} :header-rows: 1 :widths: 20 20 20 * - Syntax - Example - Result * - ```md | a | b | | :--- | ---: | | c | d | ``` - ```md | Training | Validation | | :------------ | -------------: | | 0 | 5 | | 13720 | 2744 | ``` - | Training | Validation | | :------------ | -------------: | | 0 | 5 | | 13720 | 2744 | * - ````md ```{list-table} :header-rows: 1 * - Col1 - Col2 * - Row1 under Col1 - Row1 under Col2 * - Row2 under Col1 - Row2 under Col2 ``` ```` - ````md ```{list-table} :header-rows: 1 :name: example-table * - Training - Validation * - 0 - 5 * - 13720 - 2744 ``` ```` - ```{list-table} My table title :header-rows: 1 :name: example-table * - Training - Validation * - 0 - 5 * - 13720 - 2744 ``` * - ````md ```{list-table} Table title :header-rows: 1 * - Col1 - Col2 * - Row1 under Col1 - Row1 under Col2 * - Row2 under Col1 - Row2 under Col2 ``` ```` - ````md ```{list-table} This table title :header-rows: 1 * - Training - Validation * - 0 - 5 * - 13720 - 2744 ``` ```` - ```{list-table} This table title :header-rows: 1 * - Training - Validation * - 0 - 5 * - 13720 - 2744 ``` `````` ### Referencing tables ```{note} In order to [reference a table](figures:referencing) you must add a label to it. To add a label to your table simply include a `:name:` parameter followed by the label of your table. In order to add a [numbered reference](figures:numref), you must also include a table title. See example above. ``` ``````{list-table} :header-rows: 1 :widths: 10 20 20 * - Syntax - Example - Result * - ```md {numref}`label` ``` - ```md {numref}`example-table` is an example. ``` - {numref}`example-table` is an example. * - ```md {ref}`text