Skip to content

Markdown Lexer doesn't recognize strong/emph at the very beginning of the text #1492

@PowerSnail

Description

@PowerSnail

Reproduce:

from pygments.lexers.markup import MarkdownLexer

l = MarkdownLexer()

print(list(l.get_tokens("*bolded text*")))
# OUT: [(Token.Text, '*bolded'), (Token.Text, ' '), (Token.Text, 'text*'), (Token.Text, '\n')]

print(list(l.get_tokens(" *bolded text*")))
# OUT: [(Token.Text, ' '), (Token.Generic.Emph, '*bolded text*'), (Token.Text, '\n')]

print(list(l.get_tokens("**bolded text**")))
# OUT: [(Token.Text, '**bolded'), (Token.Text, ' '), (Token.Text, 'text**'), (Token.Text, '\n')]

print(list(l.get_tokens(" **bolded text**")))
# OUT: [(Token.Text, ' '), (Token.Generic.Strong, '**bolded text**'), (Token.Text, '\n')]

As shown in the code, if I add a space before the bold-ed/emph-ed text, the lexer outputs Token.Generic.Strong for the entire bold-ed/emph-ed phrase.

If nothing precedes the bold-ed/emph-ed phrase, the lexer sees the phrase as regulart text and breaks down the phrase into parts.

Environment

Python: Python 3.8.3
Pygments: 2.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions