Skip to content

Commit 4f3f609

Browse files
authored
Merge pull request #3 from Moxio/tilde
Add support for tilde as a definition marker
2 parents cc74faf + 5b57b92 commit 4f3f609

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Since there are subtle differences between the syntaxes understood by these
5959
libraries and there is no formally defined standard, 100% compatibility
6060
with any of the aforementioned libraries cannot be guaranteed. The use
6161
of the tilde (`~`) as a definition list marker (as understood by Pandoc)
62-
is not supported yet.
62+
is also supported.
6363

6464
A simple example:
6565
```markdown

src/DefinitionListParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function parse(ContextInterface $context, Cursor $cursor): bool
1515
return false;
1616
}
1717

18-
if ($cursor->getNextNonSpacePosition() > 2 || $cursor->getNextNonSpaceCharacter() !== ":") {
18+
if ($cursor->getNextNonSpacePosition() > 2 || !in_array($cursor->getNextNonSpaceCharacter(), [":", "~"], true)) {
1919
return false;
2020
}
2121

test/IntegrationTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,30 @@ public function testSupportsOtherBlockAfterDefinitionList(): void
436436
$this->assertMarkdownIsConvertedTo($expectedHtml, $markdown);
437437
}
438438

439+
// Example from https://pandoc.org/MANUAL.html#definition-lists
440+
public function testSupportsTildeAsListMarker(): void
441+
{
442+
$markdown = <<<MD
443+
Term 1
444+
~ Definition 1
445+
446+
Term 2
447+
~ Definition 2a
448+
~ Definition 2b
449+
MD;
450+
$expectedHtml = <<<HTML
451+
<dl>
452+
<dt>Term 1</dt>
453+
<dd>Definition 1</dd>
454+
<dt>Term 2</dt>
455+
<dd>Definition 2a</dd>
456+
<dd>Definition 2b</dd>
457+
</dl>
458+
HTML;
459+
460+
$this->assertMarkdownIsConvertedTo($expectedHtml, $markdown);
461+
}
462+
439463
public function assertMarkdownIsConvertedTo($expectedHtml, $markdown): void
440464
{
441465
$environment = Environment::createCommonMarkEnvironment();

0 commit comments

Comments
 (0)