Page MenuHomePhorge

D25559.1737444776.diff
No OneTemporary

D25559.1737444776.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
@@ -153,6 +153,11 @@
return implode("\n", $out);
}
+ // The name is usually a sufficient source of information for file ext.
+ if (empty($options['lang']) && isset($options['name'])) {
+ $options['lang'] = $this->guessFilenameExtension($options['name']);
+ }
+
if (empty($options['lang'])) {
// If the user hasn't specified "lang=..." explicitly, try to guess the
// language. If we fail, fall back to configured defaults.
@@ -343,4 +348,18 @@
return $map;
}
+ /**
+ * Get the extension from a filename.
+ * @param string "/path/to/something.name"
+ * @return null|string ".name"
+ */
+ private function guessFilenameExtension($name) {
+ $name = basename($name);
+ $pos = strrpos($name, '.');
+ if ($pos !== false) {
+ return substr($name, $pos + 1);
+ }
+ return null;
+ }
+
}
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/interpreter-test.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/interpreter-test.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/interpreter-test.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/interpreter-test.txt
@@ -30,9 +30,7 @@
Content: (content)
Argv: (x=y)
-
-
-<div class="remarkup-interpreter-error">No interpreter found: phutil_fake_test_block_interpreter</div>
+<p>phutil_fake_test_block_interpreter {{{ content }}}</p>
~~~~~~~~~~
Content: (content)
Argv: (foo=bar)
@@ -53,6 +51,4 @@
Content: (content)
Argv: (x=y)
-
-
-(No interpreter found: phutil_fake_test_block_interpreter)
+phutil_fake_test_block_interpreter {{{ content }}}

File Metadata

Mime Type
text/plain
Expires
Tue, Jan 21, 07:32 (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1134255
Default Alt Text
D25559.1737444776.diff (1 KB)

Event Timeline