Skip to content

Syntax highlighting in dark mode #1525

@benhorsburgh

Description

@benhorsburgh

Have you already looked into this bug?

  • I've reviewed the release notes for relevant migration steps
  • I've searched through existing issues for similar reports
  • I've already searched online (e.g. Dash documentation) but couldn't find anything relevant

Which package?

vizro

Package version

Latest

Description

The default highlight.js code syntax highlighting is not readable in Virzo dark mode.

How to Reproduce

Add a vm.Text element to any dashboard as follows:

vm.Text(text="""```python
\"\"\"Module Docstring\"\"\"

import time as vizro_time
from typing import Optional

import regex


class MyClass(object):
    def __init__(self, arg: int, *, kwarg=1, **kwargs):
        # a comment
        self._arg = arg
        self._kwargs = dict(kw1=kwarg)
        self._kwargs.update({k: w for k, w in kwargs.items() if k.startswith("kw")})

    @property
    def bad_arg(self) -> Optional[int]:
        if vizro_time.time() % 2 == 0:
            return self._arg >> 5
        return None

    @bad_arg.setter
    def bad_arg(self, value: str):
    \"\"\"
    Sets bad_arg if the value is a string representing an integer.

    Args:
        value (str): The string to set as bad_arg.
    \"\"\"
        match = regex.match(r"^\d+$", value)
        if match:
            self._arg = int(value)
        else:
            raise ValueError("bad_arg must be a string representing an integer")

""")

Output

Image

Code of Conduct

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