Page MenuHomePhorge

D25034.1732776103.diff
No OneTemporary

D25034.1732776103.diff

diff --git a/src/infrastructure/markup/blockrule/PhutilRemarkupCodeBlockRule.php b/src/infrastructure/markup/blockrule/PhutilRemarkupCodeBlockRule.php
--- a/src/infrastructure/markup/blockrule/PhutilRemarkupCodeBlockRule.php
+++ b/src/infrastructure/markup/blockrule/PhutilRemarkupCodeBlockRule.php
@@ -44,7 +44,14 @@
}
public function markupText($text, $children) {
+ $default_lang = null;
+
if (preg_match('/^\s*```/', $text)) {
+ // Look for GFM-style ```langname blocks and handle them
+ if (preg_match('/^\s*``` *([a-z]+)\n/', $text, $matches)) {
+ $default_lang = $matches[1];
+ $text = preg_replace('/^\s*``` *([a-z]+)\n/', '', $text);
+ }
// If this is a ```-style block, trim off the backticks and any leading
// blank line.
$text = preg_replace('/^\s*```(\s*\n)?/', '', $text);
@@ -58,7 +65,7 @@
$options = array(
'counterexample' => false,
- 'lang' => null,
+ 'lang' => $default_lang,
'name' => null,
'lines' => null,
);

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 06:41 (21 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
998876
Default Alt Text
D25034.1732776103.diff (1 KB)

Event Timeline