From 5367b69a6be86615cf34dc5fd8acc0b2d8c83665 Mon Sep 17 00:00:00 2001 From: Martin Lindhe Date: Fri, 27 Nov 2015 22:40:20 +0100 Subject: [PATCH] fix regex to skip html tags, makes testShouldNotTouchHtmlTags() pass --- src/Generator.php | 2 +- tests/GenerateTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index 440df55..7e76a82 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -80,7 +80,7 @@ private function adjustString($s) } return preg_replace_callback( - '/:\w*/', + '/(<[^>]*>(*SKIP)(*FAIL)|:\w*)/', function ($matches) { return '{' . mb_substr($matches[0], 1) . '}'; }, diff --git a/tests/GenerateTest.php b/tests/GenerateTest.php index 6a9366b..d2fa62b 100644 --- a/tests/GenerateTest.php +++ b/tests/GenerateTest.php @@ -119,7 +119,7 @@ function testNamed() $this->destroyLocaleFilesFrom($arr, $root); } - function testLeaveHtmlTags() + function testShouldNotTouchHtmlTags() { $arr = [ 'en' => [ @@ -135,7 +135,7 @@ function testLeaveHtmlTags() 'export default {' . PHP_EOL . ' "en": {' . PHP_EOL . ' "help": {' . PHP_EOL - . ' "yes": "see ",' . PHP_EOL + . ' "yes": "see "' . PHP_EOL . ' }' . PHP_EOL . ' }' . PHP_EOL . '}' . PHP_EOL,