Skip to content

Commit

Permalink
Merge pull request #50 from jonom/p-tags
Browse files Browse the repository at this point in the history
P tags
  • Loading branch information
sheadawson authored Dec 1, 2016
2 parents 165ce3b + 00e47b8 commit e10afb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 3 additions & 2 deletions code/extensions/ShortcodableShortcodeParserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ class ShortcodableShortcodeParserExtension extends Extension
{
public function onBeforeParse(&$content)
{
$parser = $this->owner;
// Check the shortcode type and convert wrapper to div if block type
// Regex examples: https://regex101.com/r/bFtD9o/3
$content = preg_replace_callback(
'|<p( [^>]*?)?>\s*?\[((.*)([\s,].*)?)\]\s*?</p>|U',
function ($matches) {
function ($matches) use($parser) {
$shortcodeName = $matches[3];
// Since we're only concerned with shortcodable objects we know the
// shortcode name will be the class name so don't have to look it up
return ($shortcodeName && $this->owner->registered($shortcodeName)
return ($shortcodeName && $parser->registered($shortcodeName)
&& Config::inst()->get($shortcodeName, 'shortcodable_is_block'))
? "<div$matches[1]>[$matches[2]]</div>"
: $matches[0];
Expand Down
1 change: 0 additions & 1 deletion javascript/shortcodable.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
var ed = this.getEditor();
var newContent = shortcodable.replacePlaceholdersWithShortcodes($(this).val(), ed);
$(this).val(newContent);
ed.save();
}
},
});
Expand Down

0 comments on commit e10afb1

Please sign in to comment.