Skip to content

Commit

Permalink
🧪 Add tests for indenting with code block enabled/disabled (#87)
Browse files Browse the repository at this point in the history
To test that #83 was correctly applied
  • Loading branch information
chrisjsewell authored Jun 5, 2023
1 parent 6f1a77e commit 9e5aff8
Show file tree
Hide file tree
Showing 23 changed files with 303 additions and 9 deletions.
21 changes: 21 additions & 0 deletions tests/fixtures/admon.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,24 @@ MKdocs Open Collapsible Sections
<p>content</p>
</div>
.

Indented by 4 spaces
.
??? note
content
.
<pre><code>??? note
content
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
??? note
content
.
<div class="admonition note is-collapsible collapsible-closed">
<p class="admonition-title">Note</p>
<p>content</p>
</div>
.
27 changes: 26 additions & 1 deletion tests/fixtures/amsmath.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,29 @@ equation environment, in list:
&amp; x_0 \quad &amp;&amp; \text{valor inicial} \quad &amp;&amp; 0\leq x_0 &lt;m
\end{alignat*}
</div>
.
.

Indented by 4 spaces
.
\begin{equation}
a = 1
\end{equation}
.
<pre><code>\begin{equation}
a = 1
\end{equation}
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
\begin{equation}
a = 1
\end{equation}
.
<div class="math amsmath">
\begin{equation}
a = 1
\end{equation}
</div>
.
26 changes: 18 additions & 8 deletions tests/fixtures/attrs.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
block indented * 4 is not a block
.
{#a .a b=c}
.
<pre><code>{#a .a b=c}
</code></pre>
.

block with preceding text is not a block
.
{#a .a b=c} a
Expand Down Expand Up @@ -248,3 +240,21 @@ spans: merge attributes
.
<p><span id="b" class="a b" other="d">a</span></p>
.

Indented by 4 spaces
.
{#a .a b=c}
# head
.
<pre><code>{#a .a b=c}
# head
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
{#a .a b=c}
# head
.
<h1 id="a" b="c" class="a">head</h1>
.
23 changes: 23 additions & 0 deletions tests/fixtures/colon_fence.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,26 @@ yyy
yyy
</code></pre>
.


Indented by 4 spaces
.
:::name
foo
:::
.
<pre><code>:::name
foo
:::
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
:::name
foo
:::
.
<pre><code class="block-name" >foo
</code></pre>
.
24 changes: 24 additions & 0 deletions tests/fixtures/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,27 @@ yyy</p>
<p>yyy
:::</p>
.


Indented by 4 spaces
.
::: name
content
:::
.
<pre><code>::: name
content
:::
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
::: name
content
:::
.
<div class="name">
<p>content</p>
</div>
.
24 changes: 24 additions & 0 deletions tests/fixtures/deflist.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,27 @@ test
.
<p>test</p>
.

Indented by 4 spaces
.
Term 1

: Definition 1
.
<pre><code>Term 1

: Definition 1
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
Term 1

: Definition 1
.
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
</dl>
.
18 changes: 18 additions & 0 deletions tests/fixtures/dollar_math.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,21 @@ $$1+1=2$$ (a b)
1+1=2
</div>
.


Indented by 4 spaces
.
$$a$$
.
<pre><code>$$a$$
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
$$a$$
.
<div class="math block">
a
</div>
.
25 changes: 25 additions & 0 deletions tests/fixtures/field_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,28 @@ other</p>
</dl>
</blockquote>
.


Indented by 4 spaces
.
:name: text
indented
.
<pre><code>:name: text
indented
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
:name: text
indented
.
<dl class="field-list">
<dt>name</dt>
<dd>
<p>text
indented</p>
</dd>
</dl>
.
28 changes: 28 additions & 0 deletions tests/fixtures/footnote.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,31 @@ b
</ol>
</section>
.

Indented by 4 spaces
.
[^1]

[^1]: footnote
.
<pre><code>[^1]

[^1]: footnote
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
[^1]

[^1]: footnote
.
<p><sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup></p>
<hr class="footnotes-sep">
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p>footnote <a href="#fnref1" class="footnote-backref">↩︎</a></p>
</li>
</ol>
</section>
.
29 changes: 29 additions & 0 deletions tests/fixtures/myst_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,32 @@ def --><blockquote>
def -->
.


Indented by 4 spaces
.
+++

% abc

(a)=
.
<pre><code>+++

% abc

(a)=
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
+++

% abc

(a)=
.
<hr class="myst-block">
<!-- abc --><div class="myst-target"><a href="#a">(a)=</a></div>
.
25 changes: 25 additions & 0 deletions tests/fixtures/texmath_bracket.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,28 @@ display equation in blockquote. (valid=True)
<p>in blockquote.</p>
</blockquote>
.

Indented by 4 spaces
.
\[
a = 1
\]
.
<pre><code>\[
a = 1
\]
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
\[
a = 1
\]
.
<section>
<eqn>
a = 1
</eqn>
</section>
.
18 changes: 18 additions & 0 deletions tests/fixtures/texmath_dollar.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,21 @@ $x $
$ x$
$x $</p>
.
Indented by 4 spaces
.
$$a$$
.
<pre><code>$$a$$
</code></pre>
.

Indented by 4 spaces, DISABLE-CODEBLOCKS
.
$$a$$
.
<section>
<eqn>a</eqn>
</section>
.
2 changes: 2 additions & 0 deletions tests/test_admon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
)
def test_all(line, title, input, expected):
md = MarkdownIt("commonmark").use(admon_plugin)
if "DISABLE-CODEBLOCKS" in title:
md.disable("code")
md.options["xhtmlOut"] = False
text = md.render(input)
print(text)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_amsmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def test_custom_renderer(data_regression):
)
def test_fixtures(line, title, input, expected):
md = MarkdownIt("commonmark").use(amsmath_plugin)
if "DISABLE-CODEBLOCKS" in title:
md.disable("code")
md.options["xhtmlOut"] = False
text = md.render(input)
print(text)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
)
def test_attrs(line, title, input, expected):
md = MarkdownIt("commonmark").use(attrs_plugin, spans=True).use(attrs_block_plugin)
if "DISABLE-CODEBLOCKS" in title:
md.disable("code")
md.options["xhtmlOut"] = False
text = md.render(input)
print(text)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_colon_fence.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH))
def test_fixtures(line, title, input, expected):
md = MarkdownIt("commonmark").use(colon_fence_plugin)
if "DISABLE-CODEBLOCKS" in title:
md.disable("code")
md.options["xhtmlOut"] = False
text = md.render(input)
try:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def test_no_new_line_issue(data_regression):
@pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH))
def test_all(line, title, input, expected):
md = MarkdownIt("commonmark").use(container_plugin, "name")
if "DISABLE-CODEBLOCKS" in title:
md.disable("code")
md.options["xhtmlOut"] = False
text = md.render(input)
print(text)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_deflist.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def test_plugin_parse(data_regression):
@pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH))
def test_all(line, title, input, expected):
md = MarkdownIt("commonmark").use(deflist_plugin)
if "DISABLE-CODEBLOCKS" in title:
md.disable("code")
md.options["xhtmlOut"] = False
text = md.render(input)
print(text)
Expand Down
Loading

0 comments on commit 9e5aff8

Please sign in to comment.