Skip to content

No "wrong ticks" instruction for one or more identical code blocks with the wrong ticks #3547

Description

@roli2py

Description

When a user have sent one or more identical code block with ticks other than backticks with or without any language specifier, the bot says to "add a py after the three backticks", even when the language specifier is py, and don't mention about the wrong ticks.

Reasons

The PR #3517 replaced the _RE_CODE_BLOCK pattern to _REGEX_CODE_BLOCK and set a overlapped flag to True on the line 94. As a result, a new bug (#3522) occurred: when a user had used the quotes that were placed in the formatted code block, the bot anyway considered it as the wrong-formatted code block. The bug was fixed then by the PR #3527 by doing a following check:

  1. If there are code blocks with bad ticks, start to compare it with the other wrong code blocks
  2. Consider the first found code with the wrong ticks block when comparing with other wrong code blocks as a valid one when:
    1. They're not the same
    2. They're have different content
    3. The comparable blocks doesn't contain the content of the block with the wrong ticks

Therefore, when a user have sent one code block with the wrong ticks, the bot sets block to None and the condition leads to the block with getting of the instruction for the missing language.

Examples

Without the language specifier

An example of the processing of a code block without the language specifier

With the py language specifier

An example of the processing of a code block with the py language specifier

With the c language specifier

An example of the processing of a code block without the c language specifier

When two code blocks are identical

An example of the processing of identical code blocks

Expected behavior

An example of the expected processing of a code block

Possible Solution

The solution I have found is to remove the overlapped flag and PR #3527's check. I'm not sure about the purpose of the overlapped flag, but seems it breaks nothing. The only case that depends of this is the test_should_recognize_contained_codeblock_even_if_that_breaks_formatting unit test created in the PR #3517. When I removed the overlapped flag, all still worked and no issues weren't noticed. After I removed the PR #3527's check, the instruction becomes correct: the bot says about the wrong ticks and the missing language specifier.

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