Indentation issue when using code in a markdown slide

For example this markdown slide :
    
    ```php
    public function foo()
    {
        $foo = array(
            'bar' => 'bar'
        )
    }
    ```

Would input

```php
public function foo()
{
    $foo = array(
'bar' => 'bar'
    )
}
```

Removing global flag in regexp solves this issue, and still remove the first white space, please double check if there is no other regressions.