You are here

function _amp_convert_markup_to_amp in Accelerated Mobile Pages (AMP) 7

Use AMP class from library for conversion of text to AMP HTML.

Parameters

string $markup: The markup to be converted.

Return value

array $amp_content An array containing the following:

  • amp_markup: The AMP HTML.
  • amp_warnings: The AMP warning messages.
  • amp_components: An array of AMP JS components.
1 call to _amp_convert_markup_to_amp()
amp_field_formatter_view in ./amp.module
Implements hook_field_formatter_view().

File

./amp.module, line 1269

Code

function _amp_convert_markup_to_amp($markup) {
  $amp = _amp_create_amp_converter();
  $amp
    ->loadHtml($markup);
  $amp_content = array(
    'amp_markup' => $amp
      ->convertToAmpHtml(),
    'amp_warnings' => $amp
      ->warningsHumanHtml(),
    'amp_components' => $amp
      ->getComponentJs(),
  );
  return $amp_content;
}