Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13983965
D10045.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D10045.id.diff
View Options
diff --git a/src/markup/engine/__tests__/remarkup/list-header-last.txt b/src/markup/engine/__tests__/remarkup/list-header-last.txt
new file mode 100644
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/list-header-last.txt
@@ -0,0 +1,7 @@
+# At the end of a block, this should be a list.
+~~~~~~~~~~
+<ol class="remarkup-list">
+<li class="remarkup-list-item">At the end of a block, this should be a list.</li>
+</ol>
+~~~~~~~~~~
+1. At the end of a block, this should be a list.
diff --git a/src/markup/engine/__tests__/remarkup/list-header.txt b/src/markup/engine/__tests__/remarkup/list-header.txt
new file mode 100644
--- /dev/null
+++ b/src/markup/engine/__tests__/remarkup/list-header.txt
@@ -0,0 +1,12 @@
+## Small Header
+
+This should be a small header.
+~~~~~~~~~~
+<h3 class="remarkup-header">Small Header</h3>
+
+<p>This should be a small header.</p>
+~~~~~~~~~~
+Small Header
+------------
+
+This should be a small header.
diff --git a/src/markup/engine/__tests__/remarkup/list-then-a-list.txt b/src/markup/engine/__tests__/remarkup/list-then-a-list.txt
--- a/src/markup/engine/__tests__/remarkup/list-then-a-list.txt
+++ b/src/markup/engine/__tests__/remarkup/list-then-a-list.txt
@@ -1,4 +1,4 @@
-# one
+1) one
- a
~~~~~~~~~~
diff --git a/src/markup/engine/__tests__/remarkup/monospaced-in-monospaced.txt b/src/markup/engine/__tests__/remarkup/monospaced-in-monospaced.txt
--- a/src/markup/engine/__tests__/remarkup/monospaced-in-monospaced.txt
+++ b/src/markup/engine/__tests__/remarkup/monospaced-in-monospaced.txt
@@ -1,17 +1,17 @@
-##SELECT * FROM `table`##
+query ##SELECT * FROM `table`##
`SELECT * FROM ##table##`
`**x**`
~~~~~~~~~~
-<p><tt class="remarkup-monospaced">SELECT * FROM `table`</tt></p>
+<p>query <tt class="remarkup-monospaced">SELECT * FROM `table`</tt></p>
<p><tt class="remarkup-monospaced">SELECT * FROM ##table##</tt></p>
<p><tt class="remarkup-monospaced">**x**</tt></p>
~~~~~~~~~~
-##SELECT * FROM `table`##
+query ##SELECT * FROM `table`##
`SELECT * FROM ##table##`
diff --git a/src/markup/engine/__tests__/remarkup/monospaced.txt b/src/markup/engine/__tests__/remarkup/monospaced.txt
--- a/src/markup/engine/__tests__/remarkup/monospaced.txt
+++ b/src/markup/engine/__tests__/remarkup/monospaced.txt
@@ -1,5 +1,5 @@
-##ls --color > /dev/null##
+cmd ##ls --color > /dev/null##
~~~~~~~~~~
-<p><tt class="remarkup-monospaced">ls --color > /dev/null</tt></p>
+<p>cmd <tt class="remarkup-monospaced">ls --color > /dev/null</tt></p>
~~~~~~~~~~
-##ls --color > /dev/null##
+cmd ##ls --color > /dev/null##
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupHeaderBlockRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupHeaderBlockRule.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupHeaderBlockRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupHeaderBlockRule.php
@@ -5,7 +5,7 @@
public function getMatchingLineCount(array $lines, $cursor) {
$num_lines = 0;
- if (preg_match('/^(={1,5}).*+$/', $lines[$cursor])) {
+ if (preg_match('/^([=|#]{1,5}).*+$/', $lines[$cursor])) {
$num_lines = 1;
} else {
if (isset($lines[$cursor + 1])) {
@@ -40,13 +40,13 @@
} else {
$level = 0;
for ($ii = 0; $ii < min(5, strlen($text)); $ii++) {
- if ($text[$ii] == '=') {
+ if ($text[$ii] == '=' || $text[$ii] == '#') {
++$level;
} else {
break;
}
}
- $text = trim($text, ' =');
+ $text = trim($text, ' =#');
}
$engine = $this->getEngine();
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupListBlockRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupListBlockRule.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupListBlockRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupListBlockRule.php
@@ -14,17 +14,21 @@
public function getMatchingLineCount(array $lines, $cursor) {
$num_lines = 0;
+ $first_line = $cursor;
+ $is_one_line = false;
while (isset($lines[$cursor])) {
if (!$num_lines) {
if (preg_match(self::START_BLOCK_PATTERN, $lines[$cursor])) {
$num_lines++;
$cursor++;
+ $is_one_line = true;
continue;
}
} else {
if (preg_match(self::CONT_BLOCK_PATTERN, $lines[$cursor])) {
$num_lines++;
$cursor++;
+ $is_one_line = false;
continue;
}
@@ -43,6 +47,18 @@
break;
}
+ // If this list only has one item in it, and the list marker is "#", and
+ // it's not the last line in the input, parse it as a header instead of a
+ // list. This produces better behavior for alternate Markdown headers.
+
+ if ($is_one_line) {
+ if (($first_line + $num_lines) < count($lines)) {
+ if (strncmp($lines[$first_line], '#', 1) === 0) {
+ return 0;
+ }
+ }
+ }
+
return $num_lines;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 21, 10:00 AM (2 w, 19 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6739024
Default Alt Text
D10045.id.diff (4 KB)
Attached To
Mode
D10045: Interpret "## text"-style Markdown headers
Attached
Detach File
Event Timeline
Log In to Comment