From 07e83ba3d394ce119a87c160b6867ccfa99c5ce7 Mon Sep 17 00:00:00 2001 From: Nils Enevoldsen Date: Thu, 19 Apr 2018 12:29:53 -0400 Subject: [PATCH] Allow spaces and dashes in section titles Fizes #24 --- src/Hooks.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Hooks.php b/src/Hooks.php index 9ff6a04..2094906 100644 --- a/src/Hooks.php +++ b/src/Hooks.php @@ -52,10 +52,11 @@ public static function renderScryfallDeck( $input, array $args, $parser, $frame // Split at the first whitespace following numerals $line = preg_split( '/^\s*(?:(\d+)\s+)?/', $string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); - if ( count( $line ) == 1 ) { - $thissection = preg_replace( '/[^A-Za-z]/', '', $line[0] ); + // This line is a section title + $thissection = preg_replace( '/[^A-Za-z- ]/', '', $line[0] ); } else { + // This line is a card name with a quantity $cards[$key]['quantity'] = $line[0]; $cards[$key]['name'] = $line[1]; $cards[$key]['section'] = $thissection;