Skip to content

Validate html config #2984

@ehuss

Description

@ehuss

Problem

Currently if there is an error in the HTML config, mdbook prints an error, but does not fail the build.

Steps

Create a book.toml with an invalid HTML config:

[book]
title = "foo"

[output.html]
foo = 123

With the current output:

 INFO Book building has started
 INFO Running the html backend
ERROR Failed to deserialize `output.html`
	Caused by: unknown field `foo`, expected one of `theme`, `default-theme`, `preferred-dark-theme`, `smart-punctuation`, `definition-lists`, `admonitions`, `mathjax-support`, `additional-css`, `additional-js`, `fold`, `playground`, `playpen`, `code`, `print`, `no-section-label`, `search`, `git-repository-url`, `git-repository-icon`, `input-404`, `site-url`, `cname`, `edit-url-template`, `live-reload-endpoint`, `redirect`, `hash-files`, `sidebar-header-nav`

 INFO HTML book written to `/Users/eric/Temp/foo/book`

Possible Solution(s)

I think the solution should be to change Config.html_config to return a Result. This can be a little awkward in some places, but I think is probably the best solution. Since this is an "internal" function (doc-hidden), I think it should be OK to make a breaking change to it.

Notes

No response

Version

mdbook v0.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ConfigurationArea: ConfigurationC-bugCategory: A bug, incorrect or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions