You are here

public function GeshiFilterTest::testMarkdown in GeSHi Filter for syntax highlighting 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/GeshiFilterTest.php \Drupal\Tests\geshifilter\Functional\GeshiFilterTest::testMarkdown()

Test with markdown sintax.

File

tests/src/Functional/GeshiFilterTest.php, line 321

Class

GeshiFilterTest
Tests for GeshiFilter in node content.

Namespace

Drupal\Tests\geshifilter\Functional

Code

public function testMarkdown() {
  $this->config
    ->set('tags', 'code');
  $this->config
    ->set('language.cpp.enabled', TRUE);
  $source_code = "//C++ source code\nfor (int i=0; i<10; ++i) {\n  fun(i);\n  bar.foo(x, y);\n server->start(&pool); \n}";

  // Enable only double square brackets.
  $this->config
    ->set('tag_styles', [
    GeshiFilter::BRACKETS_MARKDOWNBLOCK => GeshiFilter::BRACKETS_MARKDOWNBLOCK,
  ]);
  $this->config
    ->save();

  // This should be filtered.
  $this
    ->assertGeshiFilterHighlighting("```cpp\n" . $source_code . "\n```", [
    [
      $source_code,
      'cpp',
      0,
      1,
      FALSE,
    ],
  ], t('Checking [[foo]] brackets style in GeshiFilter::BRACKETS_DOUBLESQUARE mode'));

  // This should not be filtered.
  $this
    ->assertGeshiFilterHighlighting('<code language="cpp">' . $source_code . '</code>', [
    [
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ],
  ], t('Checking angle brackets style in GeshiFilter::BRACKETS_DOUBLESQUARE mode'));
  $this
    ->assertGeshiFilterHighlighting('[code language="cpp"]' . $source_code . '[/code]', [
    [
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ],
  ], t('Checking [foo] brackets style in GeshiFilter::BRACKETS_DOUBLESQUARE mode'));
  $this
    ->assertGeshiFilterHighlighting('<?php' . $source_code . '?>', [
    [
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ],
  ], t('Checking php code blocks in GeshiFilter::BRACKETS_DOUBLESQUARE mode'));
}