<?php

/**
 * @group markup
 */
final class PhutilRemarkupEngineRemarkupNoteBlockRule
  extends PhutilRemarkupEngineBlockRule {

  public function getMatchingLineCount(array $lines, $cursor) {
    $num_lines = 0;

    if (preg_match("/^NOTE: /", $lines[$cursor])) {
      $num_lines++;
      $cursor++;

      while(isset($lines[$cursor])) {
        if (trim($lines[$cursor])) {
          $num_lines++;
          $cursor++;
          continue;
        }
        break;
      }
    }

    return $num_lines;
  }

  public function markupText($text) {
    $text = rtrim($this->applyRules($text));

    if ($this->getEngine()->isTextMode()) {
      return $text;
    }

    return hsprintf('<div class="remarkup-note">%s</div>', $text);
  }
}

<?php

/**
 * @group markup
 */
final class PhutilRemarkupEngineRemarkupNoteBlockRule
  extends PhutilRemarkupEngineBlockRule {

  public function getMatchingLineCount(array $lines, $cursor) {
    $num_lines = 0;

    if (preg_match("/^NOTE: /", $lines[$cursor])) {
      $num_lines++;
      $cursor++;

      while(isset($lines[$cursor])) {
        if (trim($lines[$cursor])) {
          $num_lines++;
          $cursor++;
          continue;
        }
        break;
      }
    }

    return $num_lines;
  }

  public function markupText($text) {
    $text = $this->applyRules(rtrim($text));

    if ($this->getEngine()->isTextMode()) {
      return $text;
    }

    return phutil_tag(
      'div',
      array(
        'class' => 'remarkup-note',
      ),
      $text);
  }
}

Fix remarkup "NOTE" block syntax
Fix remarkup "NOTE" block syntax

Summary: Currently, HTML in NOTE blocks gets escaped, because the "rtrim()" applies to a PhutilSafeHTML object and implicitly converts it to (unsafe) string. Instead, trim first.

Test Plan: Typed `NOTE: **x**` into remarkup, saw bold "x".

Reviewers: btrahan, garoevans, vrana

Reviewed By: btrahan

CC: aran

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