diff --git a/packages/pv-stylemark/tasks/lsg/buildLsgExamples.js b/packages/pv-stylemark/tasks/lsg/buildLsgExamples.js
index f57a526..49c53f9 100644
--- a/packages/pv-stylemark/tasks/lsg/buildLsgExamples.js
+++ b/packages/pv-stylemark/tasks/lsg/buildLsgExamples.js
@@ -12,19 +12,43 @@ const loadTemplate = async hbsInst => {
return hbsInst.compile(templateContent);
};
+/**
+ * @param {Object} config
+ * @param {import("./getLsgData.js").StyleMarkLSGData} lsgData
+ * @param {import("./getLsgData.js").StyleMarkExampleData} exampleData
+ * @param {Function} template
+ */
const buildComponentExample = async (config, lsgData, exampleData, template) => {
const { destPath } = getAppConfig();
- const componentPath = resolveApp(join(destPath, "components", lsgData.componentPath, exampleData.examplePath));
try {
- let componentMarkup = await readFile(componentPath, { encoding: "utf-8" });
+ let componentMarkup = "";
+ if (exampleData.exampleMarkup.examplePath) {
+ const componentPath = resolveApp(join(destPath, "components", lsgData.componentPath, exampleData.exampleMarkup.examplePath));
+ componentMarkup = await readFile(componentPath, { encoding: "utf-8" });
+ } else {
+ componentMarkup = exampleData.exampleMarkup.content;
+ }
const configBodyHtml = config.examples?.bodyHtml ?? "{html}";
componentMarkup = configBodyHtml.replace(/{html}/g, componentMarkup);
- const markup = template({
- lsgData,
- componentMarkup,
- exampleStyles: exampleData.exampleStyles,
- lsgConfig: config,
- });
+ // when the `raw` parameter is set in stylemark config, or the markdowns frontmatter or via the parameters of the code block in the markdown,
+ // the markup will be used as it is and not wrapped by stylemark generated markup
+ const useMarkupRaw = Object.assign({}, config.examples, lsgData.options, exampleData.exampleMarkup.params).raw;
+ let markup = "";
+ if (useMarkupRaw) {
+ const styles = exampleData.exampleStyles.map(style => ``).join("\n");
+ const scripts = exampleData.exampleScripts.map(script => ``).join("\n");
+ markup = componentMarkup
+ .replace("", `${styles}\n`)
+ .replace("