implement syntax_highlighting.enabled
This commit is contained in:
parent
c1e377c94d
commit
0940472410
3 changed files with 9 additions and 15 deletions
|
@ -96,7 +96,9 @@ class ZonaBuilder:
|
|||
self.item_map = {
|
||||
item.source.resolve(): item for item in self.items
|
||||
}
|
||||
|
||||
# write code highlighting stylesheet
|
||||
if self.config.markdown.syntax_highlighting.enabled:
|
||||
pygments_style = zmd.get_style_defs(self.config)
|
||||
(self.layout.content / "static" / "pygments.css").write_text(
|
||||
pygments_style
|
||||
|
|
|
@ -37,11 +37,6 @@ class MarkdownConfig:
|
|||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ThemeConfig:
|
||||
name: str = "default"
|
||||
|
||||
|
||||
@dataclass
|
||||
class BuildConfig:
|
||||
clean_output_dir: bool = True
|
||||
|
@ -53,15 +48,12 @@ IGNORELIST = [".git", ".env", "*/.marksman.toml"]
|
|||
|
||||
@dataclass
|
||||
class ZonaConfig:
|
||||
title: str = "Zona Blog"
|
||||
base_url: str = "https://example.com"
|
||||
language: str = "en"
|
||||
base_url: str = "/"
|
||||
# dictionary where key is name, value is url
|
||||
sitemap: SitemapConfig = field(default_factory=lambda: {"Home": "/"})
|
||||
# list of globs relative to content that should be ignored
|
||||
ignore: list[str] = field(default_factory=lambda: IGNORELIST)
|
||||
markdown: MarkdownConfig = field(default_factory=MarkdownConfig)
|
||||
theme: ThemeConfig = field(default_factory=ThemeConfig)
|
||||
build: BuildConfig = field(default_factory=BuildConfig)
|
||||
blog: BlogConfig = field(default_factory=BlogConfig)
|
||||
|
||||
|
|
|
@ -87,10 +87,10 @@ class ZonaRenderer(HTMLRenderer):
|
|||
def render_fenced_code(self, element: FencedCode):
|
||||
assert self.config
|
||||
config = self.config.markdown.syntax_highlighting
|
||||
if not config.enabled:
|
||||
return super().render_fenced_code(element)
|
||||
code = "".join(child.children for child in element.children) # type: ignore
|
||||
lang = element.lang or "text"
|
||||
if not config.enabled:
|
||||
return f"<pre><code>{code}</code></pre>"
|
||||
|
||||
try:
|
||||
lexer = get_lexer_by_name(lang, stripall=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue