0
# Theme Builder
1
2
Custom HTML builder that extends Sphinx's StandaloneHTMLBuilder with enhanced Pygments highlighting and dark mode CSS support. The AwesomeHTMLBuilder provides advanced code highlighting features and proper handling of dual-mode (light/dark) Pygments styles.
3
4
```python
5
from sphinxawesome_theme.builder import AwesomeHTMLBuilder
6
```
7
8
## Capabilities
9
10
### HTML Builder
11
12
Custom HTML builder that overrides Pygments CSS handling to support both light and dark mode styles in a single CSS file.
13
14
```python { .api }
15
class AwesomeHTMLBuilder(StandaloneHTMLBuilder):
16
"""HTML builder that overrides methods related to handling CSS for Pygments."""
17
18
def init_highlighter(self) -> None:
19
"""
20
Initialize Pygments highlighters for both light and dark modes.
21
22
Sets up the main highlighter based on pygments_style configuration
23
and optionally creates a dark mode highlighter if pygments_style_dark
24
is configured.
25
"""
26
27
def create_pygments_style_file(self) -> None:
28
"""
29
Create CSS file for Pygments that includes both light and dark mode styles.
30
31
Generates a single pygments.css file that contains the main stylesheet
32
plus dark mode styles prefixed with '.dark' selector.
33
"""
34
```
35
36
## Types
37
38
```python { .api }
39
# Attributes set by init_highlighter
40
highlighter: AwesomePygmentsBridge # Main highlighter instance
41
dark_highlighter: AwesomePygmentsBridge | None # Dark mode highlighter if configured
42
```