Page MenuHomePhabricator

D20327.diff
No OneTemporary

D20327.diff

diff --git a/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php b/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php
--- a/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php
+++ b/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php
@@ -21,6 +21,10 @@
list($input_remarkup, $expected_output, $expected_text) = $parts;
+ $input_remarkup = $this->unescapeTrailingWhitespace($input_remarkup);
+ $expected_output = $this->unescapeTrailingWhitespace($expected_output);
+ $expected_text = $this->unescapeTrailingWhitespace($expected_text);
+
$engine = $this->buildNewTestEngine();
switch ($file) {
@@ -118,4 +122,11 @@
return $engine;
}
+
+ private function unescapeTrailingWhitespace($input) {
+ // Remove up to one "~" at the end of each line so trailing whitespace may
+ // be written in tests as " ~".
+ return preg_replace('/~$/m', '', $input);
+ }
+
}
diff --git a/src/markup/engine/__tests__/remarkup/del.txt b/src/markup/engine/__tests__/remarkup/del.txt
--- a/src/markup/engine/__tests__/remarkup/del.txt
+++ b/src/markup/engine/__tests__/remarkup/del.txt
@@ -1,11 +1,11 @@
-omg~~ wtf~~~~~ bbq~~~ lol~~
-~~deleted text~~
+omg~~ wtf~~~~~ bbq~~~ lol~~~
+~~deleted text~~~
~~This is a great idea~~~ die forever please
-~~~~~~
+~~~~~~~
~~~~~~~~~~
-<p>omg~~ wtf~~~~~ bbq~~~ lol~~
+<p>omg~~ wtf~~~~~ bbq~~~ lol~~~
<del>deleted text</del>
<del>This is a great idea~</del> die forever please
~~~~~~</p>
~~~~~~~~~~
-omg~~ wtf~~~~~ bbq~~~ lol~~ ~~deleted text~~ ~~This is a great idea~~~ die forever please ~~~~~~
+omg~~ wtf~~~~~ bbq~~~ lol~~ ~~deleted text~~ ~~This is a great idea~~~ die forever please ~~~~~~~
diff --git a/src/markup/engine/__tests__/remarkup/link-with-tilde.txt b/src/markup/engine/__tests__/remarkup/link-with-tilde.txt
--- a/src/markup/engine/__tests__/remarkup/link-with-tilde.txt
+++ b/src/markup/engine/__tests__/remarkup/link-with-tilde.txt
@@ -1,5 +1,5 @@
-http://www.example.com/~
+http://www.example.com/~~
~~~~~~~~~~
<p><a href="http://www.example.com/~" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/~</a></p>
~~~~~~~~~~
-http://www.example.com/~
+http://www.example.com/~~
diff --git a/src/markup/engine/__tests__/remarkup/quoted-indent-block.txt b/src/markup/engine/__tests__/remarkup/quoted-indent-block.txt
new file mode 100644
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/quoted-indent-block.txt
@@ -0,0 +1,5 @@
+> xyz
+~~~~~~~~~~
+<blockquote><div class="remarkup-code-block" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code">xyz</pre></div></blockquote>
+~~~~~~~~~~
+> xyz
diff --git a/src/markup/engine/__tests__/remarkup/quoted-lists.txt b/src/markup/engine/__tests__/remarkup/quoted-lists.txt
new file mode 100644
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/quoted-lists.txt
@@ -0,0 +1,24 @@
+> # X
+> # Y
+>
+> B
+>
+> * C
+~~~~~~~~~~
+<blockquote><ol class="remarkup-list">
+<li class="remarkup-list-item">X</li>
+<li class="remarkup-list-item">Y</li>
+</ol>
+
+<p>B</p>
+
+<ul class="remarkup-list">
+<li class="remarkup-list-item">C</li>
+</ul></blockquote>
+~~~~~~~~~~
+> 1. X
+> 2. Y
+> ~
+> B
+> ~
+> - C
diff --git a/src/markup/engine/__tests__/remarkup/quotes.txt b/src/markup/engine/__tests__/remarkup/quotes.txt
--- a/src/markup/engine/__tests__/remarkup/quotes.txt
+++ b/src/markup/engine/__tests__/remarkup/quotes.txt
@@ -3,7 +3,7 @@
> of your inflight food service.
~~~~~~~~~~
<blockquote><p>Dear Sir,
- I am utterly disgusted with the quality
- of your inflight food service.</p></blockquote>
+I am utterly disgusted with the quality
+of your inflight food service.</p></blockquote>
~~~~~~~~~~
> Dear Sir, I am utterly disgusted with the quality of your inflight food service.
diff --git a/src/markup/engine/__tests__/remarkup/raw-escape.txt b/src/markup/engine/__tests__/remarkup/raw-escape.txt
--- a/src/markup/engine/__tests__/remarkup/raw-escape.txt
+++ b/src/markup/engine/__tests__/remarkup/raw-escape.txt
@@ -1,4 +1,4 @@
-~1~
+~1~~
~2Z
@@ -10,7 +10,7 @@
<p>~a</p>
~~~~~~~~~~
-~1~
+~1~~
~2Z
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupQuotesBlockRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupQuotesBlockRule.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupQuotesBlockRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupQuotesBlockRule.php
@@ -24,6 +24,47 @@
$text[$key] = substr($line, 1);
}
+ // If every line in the block is empty or begins with at least one leading
+ // space, strip the initial space off each line. When we quote text, we
+ // normally add "> " (with a space) to the beginning of each line, which
+ // can disrupt some other rules. If the block appears to have this space
+ // in front of each line, remove it.
+
+ $strip_space = true;
+ foreach ($text as $key => $line) {
+ $len = strlen($line);
+
+ if (!$len) {
+ // We'll still strip spaces if there are some completely empty
+ // lines, they may have just had trailing whitespace trimmed.
+ continue;
+ }
+
+ if ($line[0] == ' ' || $line[0] == "\n") {
+ continue;
+ }
+
+ // The first character of this line is something other than a space, so
+ // we can't strip spaces.
+ $strip_space = false;
+ break;
+ }
+
+ if ($strip_space) {
+ foreach ($text as $key => $line) {
+ $len = strlen($line);
+ if (!$len) {
+ continue;
+ }
+
+ if ($line[0] !== ' ') {
+ continue;
+ }
+
+ $text[$key] = substr($line, 1);
+ }
+ }
+
return array('', implode('', $text));
}

File Metadata

Mime Type
text/plain
Expires
Fri, May 10, 9:26 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6284145
Default Alt Text
D20327.diff (5 KB)

Event Timeline