File: test_markdown_lexer.py

package info (click to toggle)
pygments 2.3.1%2Bdfsg-1%2Bdeb10u2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,996 kB
  • sloc: python: 70,971; makefile: 221; sh: 117
file content (31 lines) | stat: -rw-r--r-- 893 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
"""
    Pygments regex lexer tests
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""
import unittest

from pygments.lexers.markup import MarkdownLexer


class SameTextTests(unittest.TestCase):

    lexer = MarkdownLexer()

    def assert_same_text(self, text):
        """Show that lexed markdown does not remove any content. """
        tokens = list(self.lexer.get_tokens_unprocessed(text))
        output = ''.join(t[2] for t in tokens)
        self.assertEqual(text, output)

    def test_code_fence(self):
        self.assert_same_text(r'```\nfoo\n```\n')

    def test_code_fence_gsm(self):
        self.assert_same_text(r'```markdown\nfoo\n```\n')

    def test_code_fence_gsm_with_no_lexer(self):
        self.assert_same_text(r'```invalid-lexer\nfoo\n```\n')