Skip to content

Commit 3fb160e

Browse files
linawolfjaapio
authored andcommitted
Add tests for nested tables
I added both unit tests and functional tests. Turns out propper syntax is already working. resolves #450
1 parent b3a8056 commit 3fb160e

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
lines changed

packages/guides-restructured-text/tests/unit/Parser/Productions/ListRuleTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,36 @@ public function testListFistTekstOnNewLine(): void
173173
);
174174
}
175175

176+
public function testNestedList(): void
177+
{
178+
$input = <<<'INPUT'
179+
* This is an item with sub items
180+
181+
* A valid
182+
* subitem
183+
* list
184+
185+
INPUT;
186+
$context = $this->createContext($input);
187+
188+
$result = $this->rule->apply($context);
189+
190+
self::assertEquals(
191+
new ListNode(
192+
[
193+
new ListItemNode('*', false, [
194+
new RawNode('This is an item with sub items
195+
196+
* A valid
197+
* subitem
198+
* list'),
199+
]),
200+
],
201+
),
202+
$result,
203+
);
204+
}
205+
176206
public function testListWithOddIndenting(): void
177207
{
178208
$input = <<<'INPUT'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<p>To create a bullet list:</p>
2+
<ul>
3+
<li>add a blank line before and after the list</li>
4+
<li>indent the list item text by 4 spaces - including the item sign</li>
5+
<li>
6+
<p>to create a nested list:</p>
7+
<ul>
8+
<li>indent the items by 4 spaces (left-align with parent item text)</li>
9+
<li>apply rules of parent list (blank lines, item text indentation, ..)</li>
10+
</ul>
11+
</li>
12+
</ul>
13+
<p>More text.</p>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
To create a bullet list:
2+
3+
* add a blank line before and after the list
4+
* indent the list item text by 4 spaces - including the item sign
5+
* to create a nested list:
6+
7+
* indent the items by 4 spaces (left-align with parent item text)
8+
* apply rules of parent list (blank lines, item text indentation, ..)
9+
10+
More text.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<p>To create a numbered list:</p>
2+
<ol>
3+
<li>add a blank line before and after the list</li>
4+
<li>indent the list item text by 4 spaces - including the item sign</li>
5+
<li>
6+
<p>to create a nested list:</p>
7+
<ol>
8+
<li>indent the items by 4 spaces (left-align with parent item text)</li>
9+
<li>apply rules of parent list (blank lines, item text indentation, ..)</li>
10+
</ol>
11+
</li>
12+
</ol>
13+
<p>More text.</p>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
To create a numbered list:
2+
3+
#. add a blank line before and after the list
4+
#. indent the list item text by 4 spaces - including the item sign
5+
#. to create a nested list:
6+
7+
#. indent the items by 4 spaces (left-align with parent item text)
8+
#. apply rules of parent list (blank lines, item text indentation, ..)
9+
10+
More text.

0 commit comments

Comments
 (0)