<?php

final class PhutilRemarkupDefaultBlockRule extends PhutilRemarkupBlockRule {

  public function getPriority() {
    return 750;
  }

  public function getMatchingLineCount(array $lines, $cursor) {
    return 1;
  }

  public function markupText($text, $children) {
    $text = trim($text);
    $text = $this->applyRules($text);

    if ($this->getEngine()->isTextMode()) {
      if (!$this->getEngine()->getConfig('preserve-linebreaks')) {
        $text = preg_replace('/ *\n */', ' ', $text);
      }
      return $text;
    }

    if ($this->getEngine()->getConfig('preserve-linebreaks')) {
      $text = phutil_escape_html_newlines($text);
    }

    if (!strlen($text)) {
      return null;
    }

    return phutil_tag('p', array(), $text);
  }

}

<?php

final class PhutilRemarkupDefaultBlockRule extends PhutilRemarkupBlockRule {

  public function getPriority() {
    return 750;
  }

  public function getMatchingLineCount(array $lines, $cursor) {
    return 1;
  }

  public function markupText($text, $children) {
    $engine = $this->getEngine();

    $text = trim($text);
    $text = $this->applyRules($text);

    if ($engine->isTextMode()) {
      if (!$this->getEngine()->getConfig('preserve-linebreaks')) {
        $text = preg_replace('/ *\n */', ' ', $text);
      }
      return $text;
    }

    if ($engine->getConfig('preserve-linebreaks')) {
      $text = phutil_escape_html_newlines($text);
    }

    if (!strlen($text)) {
      return null;
    }

    $default_attributes = $engine->getConfig('default.p.attributes');
    if ($default_attributes) {
      $attributes = $default_attributes;
    } else {
      $attributes = array();
    }

    return phutil_tag('p', $attributes, $text);
  }

}

Allow the default Remarkup <p> tag to be inline-styled for mail
Allow the default Remarkup <p> tag to be inline-styled for mail

Summary: Ref T10694. Browsers / mail clients have default `<p>` rules, particularly margin/padding. This allows the inline stuff to turn them off with explicit `"padding: 0; margin: 0;"` so it can control spacing more precisely.

Test Plan: See D15857.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10694

Differential Revision: https://secure.phabricator.com/D15858
