class SmartPunctuationExtension in Markdown 8.2
Smart Punctuation extension.
Plugin annotation
@MarkdownExtension(
id = "commonmark-smart-punctuation",
label = @Translation("Smart Punctuation"),
description = @Translation("Intelligently converts ASCII quotes, dashes, and ellipses to their Unicode equivalents."),
libraries = {
@ComposerPackage(
id = "league/commonmark",
object = "\League\CommonMark\Extension\SmartPunct\SmartPunctExtension",
customLabel = "commonmark-smart-punctuation",
url = "https://commonmark.thephpleague.com/extensions/smart-punctuation/",
requirements = {
@InstallableRequirement(
id = "parser:commonmark",
callback = "::getVersion",
constraints = {"Version" = "^1.3 || ^2.0"},
),
},
),
@ComposerPackage(
id = "league/commonmark-ext-smartpunct",
deprecated = @Translation("Support for this library was deprecated in markdown:8.x-2.0 and will be removed from markdown:3.0.0."),
object = "\League\CommonMark\Ext\SmartPunct\SmartPunctExtension",
url = "https://github.com/thephpleague/commonmark-ext-smartpunct",
requirements = {
@InstallableRequirement(
id = "parser:commonmark",
callback = "::getVersion",
constraints = {"Version" = ">=0.13 <1.0.0 || ^1.0"},
),
},
),
},
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\markdown\Plugin\Markdown\AnnotatedPluginBase implements AnnotatedPluginInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\markdown\Plugin\Markdown\InstallablePluginBase implements InstallablePluginInterface uses PluginDependencyTrait, MoreInfoTrait
- class \Drupal\markdown\Plugin\Markdown\BaseExtension implements ExtensionInterface uses EnabledPluginTrait
- class \Drupal\markdown\Plugin\Markdown\CommonMark\BaseExtension implements ExtensionInterface uses ParserAwareTrait
- class \Drupal\markdown\Plugin\Markdown\CommonMark\Extension\SmartPunctuationExtension implements PluginFormInterface, SettingsInterface uses FeatureDetectionTrait, SettingsTrait
- class \Drupal\markdown\Plugin\Markdown\CommonMark\BaseExtension implements ExtensionInterface uses ParserAwareTrait
- class \Drupal\markdown\Plugin\Markdown\BaseExtension implements ExtensionInterface uses EnabledPluginTrait
- class \Drupal\markdown\Plugin\Markdown\InstallablePluginBase implements InstallablePluginInterface uses PluginDependencyTrait, MoreInfoTrait
- class \Drupal\markdown\Plugin\Markdown\AnnotatedPluginBase implements AnnotatedPluginInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of SmartPunctuationExtension
File
- src/
Plugin/ Markdown/ CommonMark/ Extension/ SmartPunctuationExtension.php, line 49
Namespace
Drupal\markdown\Plugin\Markdown\CommonMark\ExtensionView source
class SmartPunctuationExtension extends BaseExtension implements PluginFormInterface, SettingsInterface {
use FeatureDetectionTrait;
use SettingsTrait;
/**
* {@inheritdoc}
*/
public static function defaultSettings($pluginDefinition) {
/* @var \Drupal\markdown\Annotation\InstallablePlugin $pluginDefinition */
// Older versions of the deprecated extension didn't have settings.
if (!static::featureExists('settings')) {
return [];
}
return [
'double_quote_opener' => '“',
'double_quote_closer' => '”',
'single_quote_opener' => '‘',
'single_quote_closer' => '’',
];
}
/**
* Feature detection for settings.
*
* @return bool
* TRUE or FALSE
*/
public static function featureSettings() {
return class_exists('\\League\\CommonMark\\Ext\\SmartPunct\\SmartPunctExtension') && defined('\\League\\CommonMark\\Ext\\SmartPunct\\Quote::DOUBLE_QUOTE_OPENER') || class_exists('\\League\\CommonMark\\Extension\\SmartPunct\\SmartPunctExtension');
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $element, FormStateInterface $form_state) {
/** @var \Drupal\markdown\Form\SubformStateInterface $form_state */
// Immediately return if extension doesn't support settings.
if (!static::featureExists('settings')) {
return $element;
}
$element += $this
->createSettingElement('double_quote_opener', [
'#type' => 'textfield',
'#title' => $this
->t('Double Quote Opener'),
], $form_state);
$element += $this
->createSettingElement('double_quote_closer', [
'#type' => 'textfield',
'#title' => $this
->t('Double Quote Closer'),
], $form_state);
$element += $this
->createSettingElement('single_quote_opener', [
'#type' => 'textfield',
'#title' => $this
->t('Single Quote Opener'),
], $form_state);
$element += $this
->createSettingElement('single_quote_closer', [
'#type' => 'textfield',
'#title' => $this
->t('Single Quote Closer'),
], $form_state);
return $element;
}
/**
* {@inheritdoc}
*/
public function settingsKey() {
return static::featureExists('settings') ? 'smartpunct' : FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AnnotatedPluginBase:: |
protected | property | The original plugin_id that was called, not a fallback identifier. | |
AnnotatedPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Retrieves the configuration overrides for the plugin. Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Retrieves the description of the plugin, if set. Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Retrieves the original plugin identifier. Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Returns the provider (extension name) of the plugin. Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Returns the weight of the plugin (used for sorting). Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
AnnotatedPluginBase:: |
public | function | ||
BaseExtension:: |
public | function |
Indicates the default "enabled" state. Overrides EnabledPluginTrait:: |
|
BaseExtension:: |
public | function |
Gets this plugin's configuration. Overrides InstallablePluginBase:: |
1 |
BaseExtension:: |
public | function |
Indicates whether the extension is automatically installed with the parser. Overrides ExtensionInterface:: |
|
BaseExtension:: |
public | function |
Allows the extension to register itself with the CommonMark Environment. Overrides ExtensionInterface:: |
4 |
BaseExtension:: |
public | function |
Retrieves identifiers of extensions that are required by this extension. Overrides ExtensionInterface:: |
|
BaseExtension:: |
public | function |
Retrieves identifiers of extensions that this extension requires. Overrides ExtensionInterface:: |
|
BaseExtension:: |
public static | function | Validates extension settings. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
DependencyTrait:: |
protected | property | The object's dependencies. | |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. | |
EnabledPluginTrait:: |
public | function | ||
FeatureDetectionTrait:: |
protected static | property | An array of test features. | |
FeatureDetectionTrait:: |
protected static | function | Determines whether a feature exists. | |
InstallablePluginBase:: |
protected | property | The config for this plugin. | |
InstallablePluginBase:: |
public | function |
Builds a display for a library. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Builds a display status based on the current state of the plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the config instance for this plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
protected static | function | ||
InstallablePluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides AnnotatedPluginBase:: |
1 |
InstallablePluginBase:: |
public | function | Retrieves available installs. | |
InstallablePluginBase:: |
protected | function | Returns the configuration name for the plugin. | |
InstallablePluginBase:: |
protected | function | Determines the configuration sort order by weight. | 1 |
InstallablePluginBase:: |
public | function | Retrieves the container. | |
InstallablePluginBase:: |
public | function |
Retrieves the deprecation message, if any. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the experimental message. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the composer package name of the installable library, if any. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the installed library used by the plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Displays the human-readable label of the plugin. Overrides AnnotatedPluginBase:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the plugin as a link using its label and URL. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
@TODO: Refactor to use variadic parameters. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the class name of the object defined by the installed library. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
protected | function | 1 | |
InstallablePluginBase:: |
public | function |
Retrieves the preferred library of the plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the configuration for the plugin, but sorted. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the URL of the plugin, if set. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
The current version of the plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function | ||
InstallablePluginBase:: |
public | function |
Indicates whether plugin has multiple installs to check. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Indicates whether the plugin is installed. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Indicates whether the plugin is using the preferred library. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Indicates whether the preferred library is installed. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides AnnotatedPluginBase:: |
3 |
InstallablePluginBase:: |
public | function |
Indicates whether the plugin should be shown in the UI. Overrides InstallablePluginInterface:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
MoreInfoTrait:: |
protected | function | Appends existing content with a "More Info" link. | |
ParserAwareTrait:: |
protected | property | A Markdown Parser instance. | |
ParserAwareTrait:: |
public | function | 1 | |
ParserAwareTrait:: |
public | function | ||
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginDependencyTrait:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. | |
PluginDependencyTrait:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. Aliased as: getPluginDependenciesTrait | |
PluginDependencyTrait:: |
protected | function | Wraps the module handler. | |
PluginDependencyTrait:: |
protected | function | Wraps the theme handler. | |
RendererTrait:: |
protected static | property | The Renderer service. | |
RendererTrait:: |
protected | function | Retrieves the Renderer service. | |
SettingsTrait:: |
protected | function | Creates a setting element. | |
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | 2 | |
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | 2 | |
SmartPunctuationExtension:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
SmartPunctuationExtension:: |
public static | function |
Provides the default settings for the plugin. Overrides SettingsTrait:: |
|
SmartPunctuationExtension:: |
public static | function | Feature detection for settings. | |
SmartPunctuationExtension:: |
public | function |
The array key name to use when the settings are nested in another array. Overrides SettingsTrait:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |