You are here

public function CommonMark::getConfiguration in Markdown 8.2

Gets this plugin's configuration.

Return value

array An array of this plugin's configuration.

Overrides BaseExtensibleParser::getConfiguration

File

src/Plugin/Markdown/CommonMark/CommonMark.php, line 346

Class

CommonMark
Support for CommonMark by The League of Extraordinary Packages.

Namespace

Drupal\markdown\Plugin\Markdown\CommonMark

Code

public function getConfiguration() {
  $configuration = parent::getConfiguration();

  // Unless the render strategy is set to "none", force the following
  // settings so the parser doesn't attempt to filter things.
  if ($this
    ->getRenderStrategy() !== static::NONE) {
    $configuration['settings']['allow_unsafe_links'] = TRUE;
    $configuration['settings']['html_input'] = 'allow';
  }

  // Escape newlines.
  if (isset($configuration['settings']['renderer']) && is_array($configuration['settings']['renderer'])) {
    foreach ($configuration['settings']['renderer'] as &$setting) {
      $setting = addcslashes($setting, "\n\r\t");
    }
  }

  // Set infinite max nesting level to 0.
  if (isset($configuration['settings']['max_nesting_level']) && $configuration['settings']['max_nesting_level'] === INF) {
    $configuration['settings']['max_nesting_level'] = 0;
  }

  // Normalize settings from a key|value string into an associative array.
  foreach ([
    'unordered_list_markers',
  ] as $name) {
    if (isset($configuration['settings'][$name])) {
      $configuration['settings'][$name] = KeyValuePipeConverter::normalize($configuration['settings'][$name]);
    }
  }
  return $configuration;
}