Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F74057
D7331.diff
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7331.diff
View Options
diff --git a/src/markup/engine/__tests__/remarkup/interpreter-test.txt b/src/markup/engine/__tests__/remarkup/interpreter-test.txt
--- a/src/markup/engine/__tests__/remarkup/interpreter-test.txt
+++ b/src/markup/engine/__tests__/remarkup/interpreter-test.txt
@@ -1,45 +1,45 @@
phutil_test_block_interpreter (foo=bar) {{{
content
}}}
-
+
phutil_test_block_interpreter {{{ content
content }}}
phutil_test_block_interpreter {{{ content }}}
phutil_fake_test_block_interpreter {{{ content }}}
~~~~~~~~~~
-Content: content
-Argv: foo=bar
+Content: (content)
+Argv: (foo=bar)
-Content: content
-content
-Argv:
+Content: ( content
+content )
+Argv: ()
-Content: content
-Argv:
+Content: ( content )
+Argv: ()
-<div style="color: red;">No interpreter found: phutil_fake_test_block_interpreter</div>
+<div class="remarkup-interpreter-error">No interpreter found: phutil_fake_test_block_interpreter</div>
~~~~~~~~~~
-Content: content
-Argv: foo=bar
+Content: (content)
+Argv: (foo=bar)
-Content: content
-content
-Argv:
+Content: ( content
+content )
+Argv: ()
-Content: content
-Argv:
+Content: ( content )
+Argv: ()
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockInterpreter.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockInterpreter.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockInterpreter.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupBlockInterpreter.php
@@ -6,11 +6,35 @@
*/
abstract class PhutilRemarkupBlockInterpreter {
+ private $engine;
+
+ final public function setEngine($engine) {
+ $this->engine = $engine;
+ return $this;
+ }
+
+ final public function getEngine() {
+ return $this->engine;
+ }
+
/**
* @return string
*/
abstract public function getInterpreterName();
abstract public function markupContent($content, array $argv);
+ protected function markupError($string) {
+ if ($this->getEngine()->isTextMode()) {
+ return '('.$string.')';
+ } else {
+ return phutil_tag(
+ 'div',
+ array(
+ 'class' => 'remarkup-interpreter-error',
+ ),
+ $string);
+ }
+ }
+
}
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupInterpreterRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupInterpreterRule.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupInterpreterRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupInterpreterRule.php
@@ -49,6 +49,10 @@
->setAncestorClass('PhutilRemarkupBlockInterpreter')
->loadObjects();
+ foreach ($interpreters as $interpreter) {
+ $interpreter->setEngine($this->getEngine());
+ }
+
$lines[$first_key] = preg_replace(
self::START_BLOCK_PATTERN,
"",
@@ -73,13 +77,18 @@
return $interpreters[$matches[1]]->markupContent($content, $argv);
}
- $message = sprintf('No interpreter found: %s', $matches[1]);
+ $message = pht('No interpreter found: %s', $matches[1]);
if ($this->getEngine()->isTextMode()) {
return '('.$message.')';
}
- return hsprintf('<div style="color: red;">%s</div>', $message);
+ return phutil_tag(
+ 'div',
+ array(
+ 'class' => 'remarkup-interpreter-error',
+ ),
+ $message);
}
}
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupTestInterpreterRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupTestInterpreterRule.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupTestInterpreterRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupTestInterpreterRule.php
@@ -12,7 +12,7 @@
public function markupContent($content, array $argv) {
return sprintf(
- "Content: %s\nArgv: %s",
+ "Content: (%s)\nArgv: (%s)",
$content,
http_build_query($argv));
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/rz/ys/riiipmqphpzmxfx3
Default Alt Text
D7331.diff (3 KB)
Attached To
Mode
D7331: Expand Remarkup interpreter block capabilities a little bit
Attached
Detach File
Event Timeline
Log In to Comment