Skip to content

Missing error when using extra_grammar instead of extra_grammars in highlighting configuration #3127

@mekkoska

Description

@mekkoska

Description

When configuring syntax highlighting with a custom grammar, I accidentally used the incorrect field name extra_grammar (singular) instead of the correct extra_grammars (plural). Instead of getting an error about an unknown configuration field, Zola silently ignored the grammar and later reported that the language wasn't found, which was misleading and made debugging difficult.

Environment

· Zola version: 0.22.1
· OS: Arch Linux

Steps to reproduce

  1. Create a new Zola site:
    zola init test-site
    cd test-site
  2. Add a custom grammar file (e.g., pillar.json). For testing, you can use any valid syntax definition or even an empty file:
    mkdir -p static/grammar
    touch static/grammar/pillar.json
  3. Edit zola.toml with incorrect field name:
    [markdown.highlighting]
    error_on_missing_language = true
    style = "inline"
    theme = "tokyo-night"
    extra_grammar = [ "./static/grammar/pillar.json" ]  #  NOTE: Singular `extra_grammar`
  4. Create a content file with a code block using the custom language:
cat > content/test.md <<EOF
+++
title = "Test"
+++
   
\`\`\`pillar
some code
\`\`\`
EOF
  1. Run zola build

Expected behaviour

Either:

  • An error/warning about unknown configuration key extra_grammar, OR
  • An error that file coundn't be loaded due to invalid configuration

Actual Behavior

Building site...
ERROR Failed to build the site
ERROR Failed to render content of /workspace/test-site/content/test.md
ERROR Reason: Language `pillar` not found for syntax highlighting in "test.md".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions