Skip to content

Commit

Permalink
allow for multiple nested spoilers
Browse files Browse the repository at this point in the history
  • Loading branch information
Regaez committed Aug 15, 2017
1 parent 1c486a4 commit 4203820
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ With the plugin's included CSS, `Mild` will render as green and `Moderate` as ye
>! [Moderate] This is a moderate spoiler
```

### Nested Spoilers

You can also put _inline_ spoilers within `block` spoilers, if desired. Perhaps you want to have a `Mild` spoiler block, which contains several `Severe` or `Moderate` spoilers inside it? Simple!

```markdown
>? [Mild] This is a block spoiler with a ??[Moderate] nested inline spoiler!?? You can have multiple nested inline spoilers within a single block.
>?
>? ??[Severe] They can even be on different lines.?? Therefore, you can hide greater spoilers within lesser spoilers!
```
> **NOTE:** You cannot nest `inline` spoilers within other `inline` spoilers.

## Extending CSS

You can easily extend the default CSS implementation to provide different types of spoilers. By utilising the attribute selector, you can style the spoiler based on a keyword given as one part of the label.
Expand Down
2 changes: 1 addition & 1 deletion markdown-spoilers.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function onMarkdownInitialized(Event $event)
$markdown->inlineSpoilers = function($Excerpt) {
// Matches spoiler syntax:
// ??[optional label] some spoiler message??
if (preg_match('/^(\?{2})(?:\[([^\]]*)\]\s*)?(\S.*\S)(\?{2})/', $Excerpt['text'], $matches))
if (preg_match('/^(\?{2})(?:\[([^\]]*)\]\s*)?(\S[^\?]*\S)(\?{2})/', $Excerpt['text'], $matches))
{
$extent = strlen($matches[0]);
$label = ltrim($matches[2]);
Expand Down

0 comments on commit 4203820

Please sign in to comment.