diff --git a/core/src/config.js b/core/src/config.js index 6144e946..d0c2a7e9 100644 --- a/core/src/config.js +++ b/core/src/config.js @@ -70,6 +70,7 @@ for (const [TYPE] of TYPES) { let config, type, + parser, pyElement, pyConfigs = $$(`${TYPE}-config`), attrConfigs = $$( @@ -92,9 +93,11 @@ for (const [TYPE] of TYPES) { [pyElement] = pyConfigs; config = pyElement.getAttribute("src") || pyElement.textContent; type = pyElement.getAttribute("type"); + parser = pyElement.getAttribute("config-parser"); } else if (attrConfigs.length) { [pyElement, ...attrConfigs] = attrConfigs; config = pyElement.getAttribute("config"); + parser = pyElement.getAttribute("config-parser"); // throw an error if dirrent scripts use different configs if ( attrConfigs.some((el) => el.getAttribute("config") !== config) @@ -120,9 +123,12 @@ for (const [TYPE] of TYPES) { } } else if (toml || type === "toml") { try { - const { parse } = await import( - /* webpackIgnore: true */ "./3rd-party/toml.js" - ); + const module = parser + ? await import(parser) + : await import( + /* webpackIgnore: true */ "./3rd-party/toml.js" + ); + const parse = module.parse || module.default; parsed = parse(text); } catch (e) { error = syntaxError("TOML", url, e); diff --git a/core/tests/index.html b/core/tests/index.html index 03b64beb..92284850 100644 --- a/core/tests/index.html +++ b/core/tests/index.html @@ -14,5 +14,5 @@ a:hover { opacity: 1; } -