You are here

protected function W3CLogController::highlightExtract in W3C Validator 8

Highlight the given string, enclosing it in a span.

Parameters

string $str: String to highlight.

int $start: Start index of substring to highlight.

int $length: Length of substring to highlight.

Return value

string The highlighted string output.

1 call to W3CLogController::highlightExtract()
W3CLogController::buildValidationDetailDisplay in src/Controller/W3CLogController.php
Builds the details of validation results for the current row.

File

src/Controller/W3CLogController.php, line 396

Class

W3CLogController
Controller routines for w3c_validator module validation log routes.

Namespace

Drupal\w3c_validator\Controller

Code

protected function highlightExtract($str, $start, $length) {
  $parts = [
    substr($str, 0, $start),
    substr($str, $start, $length),
    substr($str, $start + $length),
  ];
  $parts = array_map('htmlentities', $parts);
  $highlighted = $parts[0] . '<b>';
  $highlighted .= $parts[1] . '</b>' . $parts[2];
  return trim($highlighted);
}