Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Format Markdown Using mdformat Python APIs

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

import mdformat
text = """
# My Title
```{admonition} Note
This is a MyST directive.
```

:::{list-table}
- - name
  - age
- - Jean Doe
  - 40
:::
"""
print(text)

# My Title
```{admonition} Note
This is a MyST directive.
```

:::{list-table}
- - name
  - age
- - Jean Doe
  - 40
:::

print(
    mdformat.text(
        text,
        extensions={"myst"},
        #codeformatters={"python", "rust"},
    )
)
# My Title

```{admonition} Note
This is a MyST directive.
```

:::\{list-table}

- - name
  - age
- - Jean Doe
  - 40
    :::