Skip to content
Open
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
3 changes: 2 additions & 1 deletion Michelf/MarkdownExtra.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ protected function setup() {
$this->footnotes_assembled = null;

foreach ($this->predef_abbr as $abbr_word => $abbr_desc) {
$abbr_word = $this->encodeAmpsAndAngles($abbr_word);
if ($this->abbr_word_re)
$this->abbr_word_re .= '|';
$this->abbr_word_re .= preg_quote($abbr_word);
Expand Down Expand Up @@ -1827,7 +1828,7 @@ protected function stripAbbreviations($text) {
* @return string
*/
protected function _stripAbbreviations_callback($matches) {
$abbr_word = $matches[1];
$abbr_word = $this->encodeAmpsAndAngles($matches[1]);
$abbr_desc = $matches[2];
if ($this->abbr_word_re) {
$this->abbr_word_re .= '|';
Expand Down
35 changes: 35 additions & 0 deletions test/unit/MarkdownExtraTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,41 @@ public function testSetupOfMultiplePredefinedAttributes()
);
}

public function testAbbreviationsContainingAmpersands()
{
$obj = new \Michelf\MarkdownExtra();
$result = $obj->transform("AB&D and AB&Ds. `AB&D`\n\n*[AB&D]: Automated Build & Distribution");

$this->assertSame(
'<p><abbr title="Automated Build &amp; Distribution">AB&amp;D</abbr>' .
' and AB&amp;Ds. <code>AB&amp;D</code></p>',
trim($result)
);
}

public function testPredefinedAbbreviationsContainingAmpersands()
{
$obj = new \Michelf\MarkdownExtra();
$obj->predef_abbr = array('AB&D' => 'Automated Build & Distribution');

$this->assertSame(
'<p><abbr title="Automated Build &amp; Distribution">AB&amp;D</abbr></p>',
trim($obj->transform('AB&D'))
);
}

public function testAbbreviationsRespectNoEntities()
{
$obj = new \Michelf\MarkdownExtra();
$obj->no_entities = true;
$obj->predef_abbr = array('AB&amp;D' => 'Build & Distribution');

$this->assertSame(
'<p><abbr title="Build &amp; Distribution">AB&amp;amp;D</abbr></p>',
trim($obj->transform('AB&amp;D'))
);
}

public function testTransformWithNoMarkup()
{
$obj = new \Michelf\MarkdownExtra();
Expand Down