Request for a newline in a table (T5427)


#1

I saw the following https://secure.phabricator.com/T5427

I needed the same last week…

Its probably not the best idea but my solution was to add a {newline} remarkup extension in src/extensions

<?php

final class RemarkupNewLineRule extends PhabricatorRemarkupCustomInlineRule
{
  public function getPriority() {
    return 300.0;
  }

  public function apply($text) {
        return preg_replace_callback(
        '@{newline}@m',
        array($this, 'markupNewLine'),
        $text);
  }

  public function markupNewLine($matches) {
    $engine = $this->getEngine();
    if ($engine->isTextMode()) {
      return "\n";
    }
    if ($engine->isHTMLMailMode()) {
      return phutil_safe_html('<br>');
    }
    // Normal mode, return parsed text
    return $this->getEngine()->storeText(phutil_safe_html('<br>'));

   }
}

Then I used this in the remarkup

This is a {newline} test

    <table>
           <tr>
           <td>People</td>
           <td>Places</td>
           </tr>
           <tr>
           <td>Tom {newline} and John</td>
           <td>New York and {newline} Paris</td>
          </tr>
    </table>

And it shows like this…

image


#2

Sweet, thanks for sharing! I needed this too.