Page MenuHomePhabricator

D9388.id22387.diff
No OneTemporary

D9388.id22387.diff

diff --git a/.editorconfig b/.editorconfig
--- a/.editorconfig
+++ b/.editorconfig
@@ -6,3 +6,7 @@
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
+
+[src/markup/engine/__tests__/remarkup/*.txt]
+trim_trailing_whitespace = false
+insert_final_newline = false
diff --git a/src/markup/engine/__tests__/remarkup/quoted-code-block.txt b/src/markup/engine/__tests__/remarkup/quoted-code-block.txt
new file mode 100644
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/quoted-code-block.txt
@@ -0,0 +1,22 @@
+> This should be a code block:
+>
+> ```lang=php
+> <?php
+> $foo = 'bar';
+> ```
+~~~~~~~~~~
+<blockquote><p>This should be a code block:</p>
+
+<div class="remarkup-code-block" data-code-lang="php" data-sigil="remarkup-code-block"><pre class="remarkup-code"><span class="o">&lt;?php
+</span><span class="nv">$foo</span> <span class="k">=</span> <span class="s">&#039;bar&#039;</span><span class="k">;</span></pre></div></blockquote>
+~~~~~~~~~~
+> This should be a code block:
+
+>
+
+> <?php
+
+> $foo = 'bar';
+
+>
+
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupCodeBlockRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupCodeBlockRule.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupCodeBlockRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupCodeBlockRule.php
@@ -11,7 +11,7 @@
$match_ticks = null;
if (preg_match('/^(\s{2,}).+/', $lines[$cursor])) {
$match_ticks = false;
- } else if (preg_match('/^(```)/', $lines[$cursor])) {
+ } else if (preg_match('/^\s*(```)/', $lines[$cursor])) {
$match_ticks = true;
} else {
return $num_lines;
@@ -19,7 +19,8 @@
$num_lines++;
- if ($match_ticks && preg_match('/^(```)(.*)(```)\s*$/', $lines[$cursor])) {
+ if ($match_ticks &&
+ preg_match('/^\s*(```)(.*)(```)\s*$/', $lines[$cursor])) {
return $num_lines;
}
@@ -47,10 +48,10 @@
}
public function markupText($text, $children) {
- if (preg_match('/^```/', $text)) {
+ if (preg_match('/^\s*```/', $text)) {
// If this is a ```-style block, trim off the backticks and any leading
// blank line.
- $text = preg_replace('/^```(\s*\n)?/', '', $text);
+ $text = preg_replace('/^\s*```(\s*\n)?/', '', $text);
$text = preg_replace('/```\s*$/', '', $text);
}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 5:55 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706190
Default Alt Text
D9388.id22387.diff (2 KB)

Event Timeline