Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13981546
D8052.id18219.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D8052.id18219.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -242,6 +242,7 @@
'PhutilRemarkupBlockStorage' => 'markup/engine/remarkup/PhutilRemarkupBlockStorage.php',
'PhutilRemarkupEngine' => 'markup/engine/PhutilRemarkupEngine.php',
'PhutilRemarkupEngineBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineBlockRule.php',
+ 'PhutilRemarkupEngineRemarkupBubbleBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupBubbleBlockRule.php',
'PhutilRemarkupEngineRemarkupCodeBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupCodeBlockRule.php',
'PhutilRemarkupEngineRemarkupDefaultBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupDefaultBlockRule.php',
'PhutilRemarkupEngineRemarkupHeaderBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupHeaderBlockRule.php',
@@ -602,6 +603,7 @@
'PhutilReadableSerializerTestCase' => 'PhutilTestCase',
'PhutilRealnameContextFreeGrammar' => 'PhutilContextFreeGrammar',
'PhutilRemarkupEngine' => 'PhutilMarkupEngine',
+ 'PhutilRemarkupEngineRemarkupBubbleBlockRule' => 'PhutilRemarkupEngineBlockRule',
'PhutilRemarkupEngineRemarkupCodeBlockRule' => 'PhutilRemarkupEngineBlockRule',
'PhutilRemarkupEngineRemarkupDefaultBlockRule' => 'PhutilRemarkupEngineBlockRule',
'PhutilRemarkupEngineRemarkupHeaderBlockRule' => 'PhutilRemarkupEngineBlockRule',
Index: src/markup/engine/__tests__/remarkup/important.txt
===================================================================
--- /dev/null
+++ src/markup/engine/__tests__/remarkup/important.txt
@@ -0,0 +1,15 @@
+IMPORTANT: interesting **stuff**
+
+(IMPORTANT) interesting **stuff**
+~~~~~~~~~~
+<div class="remarkup-important">IMPORTANT: interesting <strong>stuff</strong></div>
+
+
+
+<div class="remarkup-important">interesting <strong>stuff</strong></div>
+~~~~~~~~~~
+IMPORTANT: interesting **stuff**
+
+
+
+(IMPORTANT) interesting **stuff**
Index: src/markup/engine/__tests__/remarkup/note.txt
===================================================================
--- src/markup/engine/__tests__/remarkup/note.txt
+++ src/markup/engine/__tests__/remarkup/note.txt
@@ -1,5 +1,15 @@
NOTE: interesting **stuff**
+
+(NOTE) interesting **stuff**
~~~~~~~~~~
<div class="remarkup-note">NOTE: interesting <strong>stuff</strong></div>
+
+
+
+<div class="remarkup-note">interesting <strong>stuff</strong></div>
~~~~~~~~~~
NOTE: interesting **stuff**
+
+
+
+(NOTE) interesting **stuff**
Index: src/markup/engine/__tests__/remarkup/warning.txt
===================================================================
--- /dev/null
+++ src/markup/engine/__tests__/remarkup/warning.txt
@@ -0,0 +1,15 @@
+WARNING: interesting **stuff**
+
+(WARNING) interesting **stuff**
+~~~~~~~~~~
+<div class="remarkup-warning">WARNING: interesting <strong>stuff</strong></div>
+
+
+
+<div class="remarkup-warning">interesting <strong>stuff</strong></div>
+~~~~~~~~~~
+WARNING: interesting **stuff**
+
+
+
+(WARNING) interesting **stuff**
Index: src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupNoteBlockRule.php
===================================================================
--- src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupNoteBlockRule.php
+++ src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupNoteBlockRule.php
@@ -9,7 +9,7 @@
public function getMatchingLineCount(array $lines, $cursor) {
$num_lines = 0;
- if (preg_match("/^NOTE: /", $lines[$cursor])) {
+ if (preg_match($this->getRegEx(), $lines[$cursor])) {
$num_lines++;
$cursor++;
@@ -27,17 +27,54 @@
}
public function markupText($text) {
+ $matches = array();
+ preg_match($this->getRegEx(), $text, $matches);
+ switch ($matches[0]) {
+ case 'NOTE: ':
+ $class_suffix = 'note';
+ $truncate = 0;
+ break;
+ case '(NOTE) ':
+ $class_suffix = 'note';
+ $truncate = 7;
+ break;
+ case 'IMPORTANT: ':
+ $class_suffix = 'important';
+ $truncate = 0;
+ break;
+ case '(IMPORTANT) ':
+ $class_suffix = 'important';
+ $truncate = 12;
+ break;
+ case 'WARNING: ':
+ $class_suffix = 'warning';
+ $truncate = 0;
+ break;
+ case '(WARNING) ':
+ $class_suffix = 'warning';
+ $truncate = 10;
+ break;
+ }
+ $text_mode = $this->getEngine()->isTextMode();
+ if ($truncate && !$text_mode) {
+ $text = substr($text, $truncate);
+ }
$text = $this->applyRules(rtrim($text));
- if ($this->getEngine()->isTextMode()) {
+ if ($text_mode) {
return $text;
}
return phutil_tag(
'div',
array(
- 'class' => 'remarkup-note',
+ 'class' => 'remarkup-'.$class_suffix
),
$text);
}
+
+ private function getRegEx() {
+ return "/^(NOTE: |IMPORTANT: |WARNING: |".
+ "\(NOTE\) |\(WARNING\) |\(IMPORTANT\) )/";
+ }
}
Index: src/parser/xhpast/parser_nodes.php
===================================================================
--- src/parser/xhpast/parser_nodes.php
+++ src/parser/xhpast/parser_nodes.php
@@ -117,5 +117,6 @@
9110 => 'n_TRAIT_METHOD_REFERENCE',
9111 => 'n_TRAIT_AS',
9112 => 'n_YIELD',
+ 9113 => 'n_FINALLY',
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 20, 5:16 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6737035
Default Alt Text
D8052.id18219.diff (5 KB)
Attached To
Mode
D8052: Add WARNING and IMPORTANT to remarkup
Attached
Detach File
Event Timeline
Log In to Comment