You are here

private function GeshiFilterSettingsForm::generalHighlightTagsSettings in GeSHi Filter for syntax highlighting 8.2

Same name and namespace in other branches
  1. 8 src/Form/GeshiFilterSettingsForm.php \Drupal\geshifilter\Form\GeshiFilterSettingsForm::generalHighlightTagsSettings()

Helper function for some settings form fields usable as general/specific.

Return value

array The form elements to choose tag settings.

1 call to GeshiFilterSettingsForm::generalHighlightTagsSettings()
GeshiFilterSettingsForm::buildForm in src/Form/GeshiFilterSettingsForm.php
Form constructor.

File

src/Form/GeshiFilterSettingsForm.php, line 314

Class

GeshiFilterSettingsForm
Form with the settings for the module.

Namespace

Drupal\geshifilter\Form

Code

private function generalHighlightTagsSettings() {
  $form = [];

  // Generic tags.
  $form["tags"] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Generic syntax highlighting tags'),
    '#default_value' => $this
      ->tags(),
    '#description' => $this
      ->t('Tags that should activate the GeSHi syntax highlighting. Specify a space-separated list of tagnames.'),
  ];

  // Container tag styles.
  $form["tag_styles"] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Container tag style'),
    '#options' => [
      GeshiFilter::BRACKETS_ANGLE => '<code>' . htmlentities('<foo> ... </foo>') . '</code>',
      GeshiFilter::BRACKETS_SQUARE => '<code>[foo] ... [/foo]</code>',
      GeshiFilter::BRACKETS_DOUBLESQUARE => '<code>[[foo]] ... [[/foo]]</code>',
      GeshiFilter::BRACKETS_PHPBLOCK => $this
        ->t('PHP style source code blocks: <code>@php</code> and <code>@percent</code>', [
        '@php' => '<?php ... ?>',
        '@percent' => '<% ... %>',
      ]),
      GeshiFilter::BRACKETS_MARKDOWNBLOCK => '<code>' . htmlentities('```foo ... ```') . '</code>',
    ],
    '#default_value' => $this
      ->tagStyles(),
    '#description' => $this
      ->t('Select the container tag styles that should trigger GeSHi syntax highlighting.'),
  ];

  // Setting to decode entities, see https://www.drupal.org/node/2047021.
  $config = $this
    ->config('geshifilter.settings');
  $form["decode_entities"] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Decode entities'),
    '#default_value' => $config
      ->get('decode_entities'),
    '#description' => $this
      ->t('Decode entities, for example, if the code has been typed in a WYSIWYG editor.'),
  ];
  return $form;
}