Skip to content

Commit

Permalink
Add more information about changing the shortcode parser
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrossi committed Nov 29, 2018
1 parent 3cd3e80 commit ca15fb3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,21 @@ If you are using Laravel, we suggest adding your shortcodes handlers in `App\Pro

Shortcodes are parsed with the [*thunderer/shortcode*](https://github.com/thunderer/Shortcode) library.

Several different parsers are provided. `RegularParser` is the most technically correct and is provided by default. This is suitable for most cases. However if you encounter some irregularities in your shortcode parsing, you may need to configure Corcel to use the `WordpressParser`, which more faithfully matches Wordpress' shortcode regex. To do this, edit the `config/corcel.php` file, and uncomment your preferred parser. Alternatively, you can replace this with a parser of your own.
Several different parsers are provided. `RegularParser` is the most technically correct and is provided by default. This is suitable for most cases. However if you encounter some irregularities in your shortcode parsing, you may need to configure Corcel to use the `WordpressParser`, which more faithfully matches WordPress' shortcode regex. To do this, if you are using Laravel, edit the `config/corcel.php` file, and uncomment your preferred parser. Alternatively, you can replace this with a parser of your own.

```php
'shortcode_parser' => Thunder\Shortcode\Parser\RegularParser::class,
// 'shortcode_parser' => Thunder\Shortcode\Parser\WordpressParser::class,
```

If you need to do this in runtime, you can call the `setShortcodeParser()` method from any class which uses the `Shortcodes` trait (such as `Post`).
If you are not using Laravel, you can to do this in runtime, calling the `setShortcodeParser()` method from any class which uses the `Shortcodes` trait, such as `Post`, for example.

For more information, [click here](https://github.com/thunderer/Shortcode).
```php
$post->setShortcodeParser(new WordpressParser());
echo $post->content; // content parsed with "WordpressParser" class
```

For more information about the shortcode package, [click here](https://github.com/thunderer/Shortcode).

## <a id="taxonomies"></a>Taxonomies

Expand Down

0 comments on commit ca15fb3

Please sign in to comment.