From 2327578adc946eefb1864ea6ebe0522b5290d6a0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 6 Feb 2020 14:48:08 -0800 Subject: [PATCH] Respect linebreaks in full HTML tables in Remarkup Summary: Fixes T5427. See PHI1630. See also T13160 and D20568. In the full HTML table syntax with "", respect linebreaks as literals inside "
" cells. Test Plan: Previewed some full-HTML tables with and without linebreaks, saw what seemed like sensible rendering behavior. Maniphest Tasks: T5427 Differential Revision: https://secure.phabricator.com/D20971 --- .../blockrule/PhutilRemarkupTableBlockRule.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php b/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php index 57f2fe1f1d..72e61881ce 100644 --- a/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php +++ b/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php @@ -121,8 +121,19 @@ final class PhutilRemarkupTableBlockRule extends PhutilRemarkupBlockRule { return $table->newRawString(); } + // Respect newlines in table cells as literal linebreaks. + $content = $cell->newRawContentString(); - $content = $this->applyRules($content); + $content = trim($content, "\r\n"); + + $lines = phutil_split_lines($content, $retain_endings = false); + foreach ($lines as $key => $line) { + $lines[$key] = $this->applyRules($line); + } + + $content = phutil_implode_html( + phutil_tag('br'), + $lines); $cell_specs[] = array( 'type' => $cell->getTagName(),