3 namespace Drupal\filter\Plugin\Filter;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\filter\FilterProcessResult;
7 use Drupal\filter\Plugin\FilterBase;
10 * Provides a filter to convert URLs into links.
14 * title = @Translation("Convert URLs into links"),
15 * type = Drupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE,
17 * "filter_url_length" = 72
21 class FilterUrl extends FilterBase {
26 public function settingsForm(array $form, FormStateInterface $form_state) {
27 $form['filter_url_length'] = [
29 '#title' => $this->t('Maximum link text length'),
30 '#default_value' => $this->settings['filter_url_length'],
32 '#field_suffix' => $this->t('characters'),
33 '#description' => $this->t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'),
41 public function process($text, $langcode) {
42 return new FilterProcessResult(_filter_url($text, $this));
48 public function tips($long = FALSE) {
49 return $this->t('Web page addresses and email addresses turn into links automatically.');