| 277 | return theme |
| 278 | |
| 279 | def __init__( |
| 280 | self, |
| 281 | code: str, |
| 282 | lexer: Union[Lexer, str], |
| 283 | *, |
| 284 | theme: Union[str, SyntaxTheme] = DEFAULT_THEME, |
| 285 | dedent: bool = False, |
| 286 | line_numbers: bool = False, |
| 287 | start_line: int = 1, |
| 288 | line_range: Optional[Tuple[Optional[int], Optional[int]]] = None, |
| 289 | highlight_lines: Optional[Set[int]] = None, |
| 290 | code_width: Optional[int] = None, |
| 291 | tab_size: int = 4, |
| 292 | word_wrap: bool = False, |
| 293 | background_color: Optional[str] = None, |
| 294 | indent_guides: bool = False, |
| 295 | padding: PaddingDimensions = 0, |
| 296 | ) -> None: |
| 297 | self.code = code |
| 298 | self._lexer = lexer |
| 299 | self.dedent = dedent |
| 300 | self.line_numbers = line_numbers |
| 301 | self.start_line = start_line |
| 302 | self.line_range = line_range |
| 303 | self.highlight_lines = highlight_lines or set() |
| 304 | self.code_width = code_width |
| 305 | self.tab_size = tab_size |
| 306 | self.word_wrap = word_wrap |
| 307 | self.background_color = background_color |
| 308 | self.background_style = ( |
| 309 | Style(bgcolor=background_color) if background_color else Style() |
| 310 | ) |
| 311 | self.indent_guides = indent_guides |
| 312 | self._padding = Padding.unpack(padding) |
| 313 | |
| 314 | self._theme = self.get_theme(theme) |
| 315 | self._stylized_ranges: List[_SyntaxHighlightRange] = [] |
| 316 | |
| 317 | padding = PaddingProperty() |
| 318 | |