Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Comment.php

function Comment::getRawText

Returns the comment raw text

Return value

string

File

vendor/mck89/peast/lib/Peast/Syntax/Node/Comment.php, line 120

Class

Comment
A node that represents a comment.

Namespace

Peast\Syntax\Node

Code

public function getRawText() {
    $text = $this->getText();
    $kind = $this->getKind();
    if ($kind === self::KIND_MULTILINE) {
        $sanitize = "*/";
    }
    else {
        $sanitize = array(
            "\n",
            "\r",
        );
    }
    $text = str_replace($sanitize, "", $text);
    if ($kind === self::KIND_INLINE) {
        return "//" . $text;
    }
    elseif ($kind === self::KIND_HASHBANG) {
        return "#!" . $text;
    }
    elseif ($kind === self::KIND_HTML_OPEN) {
        return "<!--" . $text;
    }
    elseif ($kind === self::KIND_HTML_CLOSE) {
        return "-->" . $text;
    }
    else {
        return "/*" . $text . "*/";
    }
}
RSS feed
Powered by Drupal