League\CommonMark\Util\RegexHelper::getHtmlBlockCloseRegex PHP Method

getHtmlBlockCloseRegex() public static method

public static getHtmlBlockCloseRegex ( integer $type ) : string | null
$type integer HTML block type
return string | null
    public static function getHtmlBlockCloseRegex($type)
    {
        switch ($type) {
            case HtmlBlock::TYPE_1_CODE_CONTAINER:
                return '%<\\/(?:script|pre|style)>%i';
            case HtmlBlock::TYPE_2_COMMENT:
                return '/-->/';
            case HtmlBlock::TYPE_3:
                return '/\\?>/';
            case HtmlBlock::TYPE_4:
                return '/>/';
            case HtmlBlock::TYPE_5_CDATA:
                return '/\\]\\]>/';
        }
    }

Usage Example

 /**
  * @param ContextInterface $context
  * @param Cursor           $cursor
  */
 public function handleRemainingContents(ContextInterface $context, Cursor $cursor)
 {
     $context->getTip()->addLine($cursor->getRemainder());
     // Check for end condition
     if ($this->type >= self::TYPE_1_CODE_CONTAINER && $this->type <= self::TYPE_5_CDATA) {
         if ($cursor->match(RegexHelper::getHtmlBlockCloseRegex($this->type)) !== null) {
             $this->finalize($context, $context->getLineNumber());
         }
     }
 }