You are here

public static function GeshiFilterCss::generateLanguagesCssRules in GeSHi Filter for syntax highlighting 8

Same name and namespace in other branches
  1. 8.2 src/GeshiFilterCss.php \Drupal\geshifilter\GeshiFilterCss::generateLanguagesCssRules()

Helper function for generating the CSS rules.

Return value

string String with the CSS rules.

2 calls to GeshiFilterCss::generateLanguagesCssRules()
GeshiFilterCss::generateCss in src/GeshiFilterCss.php
Create the page that show the css in use.
GeshiFilterCss::generateLanguagesCssFile in src/GeshiFilterCss.php
Function for generating the external stylesheet.

File

src/GeshiFilterCss.php, line 66

Class

GeshiFilterCss
Helper functions to work with css.

Namespace

Drupal\geshifilter

Code

public static function generateLanguagesCssRules() {
  $output = '';
  $geshi_library = GeshiFilter::loadGeshi();
  if ($geshi_library['loaded']) {
    $languages = GeshiFilter::getEnabledLanguages();
    foreach ($languages as $langcode => $language_full_name) {

      // Create GeSHi object.
      $geshi = GeshiFilterProcess::geshiFactory('', $langcode);
      GeshiFilterProcess::overrideGeshiDefaults($geshi, $langcode);

      // Add CSS rules for current language.
      $output .= $geshi
        ->get_stylesheet(FALSE) . "\n";

      // Release GeSHi object.
      unset($geshi);
    }
  }
  else {
    drupal_set_message($this
      ->t('Error while generating CSS rules: could not load GeSHi library.'), 'error');
  }
  return $output;
}