Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mdformat_myst/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import re
import textwrap

from markdown_it import MarkdownIt
import mdformat.plugins
Expand Down Expand Up @@ -78,11 +79,14 @@ def _math_inline_renderer(node: RenderTreeNode, context: RenderContext) -> str:


def _math_block_renderer(node: RenderTreeNode, context: RenderContext) -> str:
indent_width = context.env.get("indent_width", 0)
if indent_width > 0:
return f"$${textwrap.dedent(node.content)}$$"
return f"$${node.content}$$"


def _math_block_label_renderer(node: RenderTreeNode, context: RenderContext) -> str:
return f"$${node.content}$$ ({node.info})"
return f"{_math_block_renderer(node, context)} ({node.info})"


def _math_block_safe_blockquote_renderer(
Expand Down
30 changes: 30 additions & 0 deletions tests/data/fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,36 @@ $$ (eq1)
> Some more words
.

Indented dollarmath block
.
1. Indented math block

$$
a=1
$$
.
1. Indented math block

$$
a=1
$$
.

Indented dollarmath block labeled
.
1. Indented labeled math block

$$
a=1
$$ (eq1)
.
1. Indented labeled math block

$$
a=1
$$ (eq1)
.

Frontmatter
.
---
Expand Down
Loading