Last active
December 15, 2015 15:09
-
-
Save zmax/5279571 to your computer and use it in GitHub Desktop.
Parsing Github Fenced code blocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('/regtest', function(){ | |
$test = ' | |
```php | |
use Namespace1\Namespace2\Namespace3; | |
class Article extends Model | |
{ | |
public function identifiableName() | |
{ | |
return $this->title; | |
} | |
} | |
``` | |
```javascript | |
use Namespace1\Namespace2\Namespace3; | |
class Article extends Model | |
{ | |
public function identifiableName() | |
{ | |
return $this->title; | |
} | |
} | |
``` | |
'; | |
$test = addslashes($test); | |
// Added by Starck Lin - parsing Github Fenced code blocks | |
$test = preg_replace("/\n```([A-z :]+)([^```]+?)\n```/", '<pre class="lang:$1">$2</pre>', $content ); | |
$test = preg_replace("/\n```([^```]+?)\n```/", '<pre>$1</pre>;', $content ); | |
return $test; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment