Nett icon indicating copy to clipboard operation
Nett copied to clipboard

Add support for parse less strict ordering Toml file

Open qianz2 opened this issue 5 years ago • 0 comments

Currently while we use Toml.ReadString(tomlContent), it will throw an exception if the toml file content has a less strict ordering. For example, here will throw an exception since params.plugins come before params .

baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
theme = "ananke"

[params.plugins]
  # CSS Plugins
  [[params.plugins.css]]
  URL = "plugins/bootstrap/bootstrap.min.css"

[params]
home = "Home"

I agree that logically it has no problem, params should come before params.plugins. However, in some cases, we try to detect a Hugo app, we still want to identify this file as a valid toml file and get TomlTable from it, because it contains valid configurations for a Hugo app. The ordering is a user mistakes, not necessary to fail the build.

So wondering if it's possible to support it? Add a setting option for us to parse Toml file less strictly.

qianz2 avatar Oct 16 '20 23:10 qianz2