diff --git a/src/Extension/Attributes/Util/AttributesHelper.php b/src/Extension/Attributes/Util/AttributesHelper.php index db499a50bd..2a87d60391 100644 --- a/src/Extension/Attributes/Util/AttributesHelper.php +++ b/src/Extension/Attributes/Util/AttributesHelper.php @@ -75,6 +75,11 @@ public static function parseAttributes(Cursor $cursor): array /** @psalm-suppress PossiblyUndefinedArrayOffset */ [$name, $value] = \explode('=', $attribute, 2); + if ('true' === $value) { + $attributes[$name] = true; + continue; + } + $first = $value[0]; $last = \substr($value, -1); if (($first === '"' && $last === '"') || ($first === "'" && $last === "'") && \strlen($value) > 1) { diff --git a/tests/functional/Extension/Attributes/data/special_attributes.html b/tests/functional/Extension/Attributes/data/special_attributes.html index 4a2f60ebcd..be4efd48fb 100644 --- a/tests/functional/Extension/Attributes/data/special_attributes.html +++ b/tests/functional/Extension/Attributes/data/special_attributes.html @@ -22,7 +22,8 @@

The Site

c. Some.

d. Some{text}.

e. Some.

-

f. Some{{text}}.

+

f. Some.

+

g. Some{{text}}.

some

some

some

diff --git a/tests/functional/Extension/Attributes/data/special_attributes.md b/tests/functional/Extension/Attributes/data/special_attributes.md index 17d7b43897..83688fcddc 100644 --- a/tests/functional/Extension/Attributes/data/special_attributes.md +++ b/tests/functional/Extension/Attributes/data/special_attributes.md @@ -49,7 +49,9 @@ d. [Some{text}](https://example.com). e. [Some](https://example.com){text="text"}. -f. [Some{{text}}](https://example.com). +f. [Some](https://example.com){text=true}. + +g. [Some{{text}}](https://example.com). {hello="hello"} some diff --git a/tests/unit/Extension/Attributes/Util/AttributesHelperTest.php b/tests/unit/Extension/Attributes/Util/AttributesHelperTest.php index 500b270a4b..257621f910 100644 --- a/tests/unit/Extension/Attributes/Util/AttributesHelperTest.php +++ b/tests/unit/Extension/Attributes/Util/AttributesHelperTest.php @@ -53,12 +53,13 @@ public static function dataForTestParseAttributes(): iterable yield [new Cursor('{: #custom-id }'), ['id' => 'custom-id']]; yield [new Cursor('{: #custom-id #another-id }'), ['id' => 'another-id']]; yield [new Cursor('{: .class1 .class2 }'), ['class' => 'class1 class2']]; - yield [new Cursor('{: #custom-id .class1 .class2 title="My Title" disabled }'), ['id' => 'custom-id', 'class' => 'class1 class2', 'title' => 'My Title', 'disabled' => true]]; + yield [new Cursor('{: #custom-id .class1 .class2 title="My Title" disabled=true }'), ['id' => 'custom-id', 'class' => 'class1 class2', 'title' => 'My Title', 'disabled' => true]]; + yield [new Cursor('{: #custom-id .class1 .class2 title="My Title" disabled="disabled" }'), ['id' => 'custom-id', 'class' => 'class1 class2', 'title' => 'My Title', 'disabled' => 'disabled']]; yield [new Cursor('{:target=_blank}'), ['target' => '_blank']]; yield [new Cursor('{: target=_blank}'), ['target' => '_blank']]; yield [new Cursor('{: target=_blank }'), ['target' => '_blank']]; yield [new Cursor('{: target=_blank }'), ['target' => '_blank']]; - yield [new Cursor('{: disabled}'), ['disabled' => true]]; + yield [new Cursor('{: disabled=disabled}'), ['disabled' => 'disabled']]; // Examples without colons yield [new Cursor('{title="My Title"}'), ['title' => 'My Title']]; @@ -69,12 +70,13 @@ public static function dataForTestParseAttributes(): iterable yield [new Cursor('{ #custom-id }'), ['id' => 'custom-id']]; yield [new Cursor('{ #custom-id #another-id }'), ['id' => 'another-id']]; yield [new Cursor('{ .class1 .class2 }'), ['class' => 'class1 class2']]; - yield [new Cursor('{ #custom-id .class1 .class2 title="My Title" disabled }'), ['id' => 'custom-id', 'class' => 'class1 class2', 'title' => 'My Title', 'disabled' => true]]; + yield [new Cursor('{ #custom-id .class1 .class2 title="My Title" disabled=true }'), ['id' => 'custom-id', 'class' => 'class1 class2', 'title' => 'My Title', 'disabled' => true]]; + yield [new Cursor('{ #custom-id .class1 .class2 title="My Title" disabled="disabled" }'), ['id' => 'custom-id', 'class' => 'class1 class2', 'title' => 'My Title', 'disabled' => 'disabled']]; yield [new Cursor('{target=_blank}'), ['target' => '_blank']]; yield [new Cursor('{ target=_blank}'), ['target' => '_blank']]; yield [new Cursor('{target=_blank }'), ['target' => '_blank']]; yield [new Cursor('{ target=_blank }'), ['target' => '_blank']]; - yield [new Cursor('{disabled}'), ['disabled' => true]]; + yield [new Cursor('{disabled=disabled}'), ['disabled' => 'disabled']]; // Stuff at the beginning yield [new Cursor(' {: #custom-id }'), ['id' => 'custom-id']];