You are here

public function CommonMark::setConfiguration in Markdown 8.2

Sets the configuration for this plugin instance.

Parameters

array $configuration: An associative array containing the plugin's configuration.

Overrides InstallablePluginBase::setConfiguration

File

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

Class

CommonMark
Support for CommonMark by The League of Extraordinary Packages.

Namespace

Drupal\markdown\Plugin\Markdown\CommonMark

Code

public function setConfiguration(array $configuration) {

  // Convert newlines to actual newlines.
  if (isset($configuration['settings']['renderer'])) {
    foreach ($configuration['settings']['renderer'] as &$setting) {
      $setting = stripcslashes($setting);
    }
  }

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

  // 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 parent::setConfiguration($configuration);
}