Skip to content

(Python) Wrong coloring in python while wrongly using just one quote to include multiple lines string.Β #4331

@Locked-chess-official

Description

@Locked-chess-official

Describe the issue

Which language seems to have the issue?

Are you using highlight or highlightAuto?

...

Sample Code to Reproduce

Expected behavior

Additional context

Image

The invalid string's second line was wrongly drawn as string.

Here is the code to show this issue:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Highlight.js Python test for quote</title>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/python.min.js"></script>

<script>
hljs.highlightAll();
</script>
</head>

<body>
<h2>Highlight.js Python</h2>

<pre><code class="language-python">
# 1. valid string
a = 'abc'
print(a)

# 2. invalid string
b = 'abc
def'
print(b)
</code></pre>

</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions