Skip to content

Commit dd33d8c

Browse files
authored
Merge pull request #63 from thunderer/allow-asterisk-shortcode-name
Allow asterisk (*) as shortcode name
2 parents a699886 + 515b48b commit dd33d8c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Utility/RegexBuilderUtility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class RegexBuilderUtility
1010
{
1111
public static function buildNameRegex()
1212
{
13-
return '[a-zA-Z0-9-_]+';
13+
return '[a-zA-Z0-9-_\\*]+';
1414
}
1515

1616
public static function buildShortcodeRegex(SyntaxInterface $syntax)

tests/ParserTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function provideShortcodes()
114114

115115
// multiple shortcodes
116116
array($s, 'Lorem [ipsum] random [code-code arg=val] which is here', array(
117-
new ParsedShortcode(new Shortcode('ipsum', array(), null), '[ipsum]', 6, array('name' => 1)),
117+
new ParsedShortcode(new Shortcode('ipsum', array(), null), '[ipsum]', 6),
118118
new ParsedShortcode(new Shortcode('code-code', array('arg' => 'val'), null), '[code-code arg=val]', 21),
119119
)),
120120
array($s, 'x [aa] x [aa] x', array(
@@ -213,6 +213,13 @@ public function provideShortcodes()
213213
array($s, '[x=#F00 one=#F00 two="#F00"]', array(
214214
new ParsedShortcode(new Shortcode('x', array('one' => '#F00', 'two' => '#F00'), null, '#F00'), '[x=#F00 one=#F00 two="#F00"]', 0),
215215
)),
216+
array($s, '[*] [* xyz arg=val]', array(
217+
new ParsedShortcode(new Shortcode('*', array(), null, null), '[*]', 0),
218+
new ParsedShortcode(new Shortcode('*', array('xyz' => null, 'arg' => 'val'), null, null), '[* xyz arg=val]', 4),
219+
)),
220+
array($s, '[*=bb x=y]cnt[/*]', array(
221+
new ParsedShortcode(new Shortcode('*', array('x' => 'y'), 'cnt', 'bb'), '[*=bb x=y]cnt[/*]', 0),
222+
)),
216223
array($s, '[ [] ] [x] [ ] [/x] ] [] [ [y] ] [] [ [z] [/#] [/z] [ [] ] [/] [/y] ] [z] [ [/ [/] /] ] [/z]', array(
217224
new ParsedShortcode(new Shortcode('x', array(), ' [ ] ', null), '[x] [ ] [/x]', 7),
218225
new ParsedShortcode(new Shortcode('y', array(), ' ] [] [ [z] [/#] [/z] [ [] ] [/] ', null), '[y] ] [] [ [z] [/#] [/z] [ [] ] [/] [/y]', 27),
@@ -232,14 +239,14 @@ public function provideShortcodes()
232239
*
233240
* Tests cases from array above with identifiers in the array below must be skipped.
234241
*/
235-
$wordpressSkip = array(3, 6, 16, 21, 22, 23, 25, 32, 33, 34, 46, 47);
242+
$wordpressSkip = array(3, 6, 16, 21, 22, 23, 25, 32, 33, 34, 46, 47, 49);
236243
$result = array();
237244
foreach($tests as $key => $test) {
238245
$syntax = array_shift($test);
239246

240247
$result[] = array_merge(array(new RegexParser($syntax)), $test);
241248
$result[] = array_merge(array(new RegularParser($syntax)), $test);
242-
if(!in_array($key, $wordpressSkip)) {
249+
if(!in_array($key, $wordpressSkip, true)) {
243250
$result[] = array_merge(array(new WordpressParser()), $test);
244251
}
245252
}

0 commit comments

Comments
 (0)