Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2658104
D25034.1732776103.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
D25034.1732776103.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D25034: support language highlighting for GFM-style code blocks
Attached
Detach File
Event Timeline
Log In to Comment