diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e484948..ad12866f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ## Unreleased +* Updated Hugo Bookshop's goldmark settings to allow rendering HTML through the `markdownify` function. + ## v3.13.0 (January 22, 2025) * Added support for Astro 5. diff --git a/javascript-modules/engines/hugo-engine/lib/engine.js b/javascript-modules/engines/hugo-engine/lib/engine.js index 4a8d864d..00bc7ec2 100644 --- a/javascript-modules/engines/hugo-engine/lib/engine.js +++ b/javascript-modules/engines/hugo-engine/lib/engine.js @@ -66,7 +66,7 @@ export class Engine { "layouts/partials/_bookshop/errors/err.html": (await import("../bookshop-hugo-templates/errors/err.html")).default, }; - templates["config.toml"] = "params.env_bookshop_live = true"; + templates["config.toml"] = "params.env_bookshop_live = true\nmarkup.goldmark.renderer.unsafe = true"; // When this script is run locally, the hugo wasm is loaded as binary rather than output as a file. if (compressedHugoWasm?.constructor === Uint8Array) { @@ -206,7 +206,8 @@ export class Engine { meta.baseurl ? `baseURL = ${meta.baseurl}` : "", meta.copyright ? `copyright = ${meta.copyright}` : "", meta.title ? `title = ${meta.title}` : "", - "params.env_bookshop_live = true" + "params.env_bookshop_live = true", + "markup.goldmark.renderer.unsafe = true" ].join('\n') })); const err = window.initHugoConfig(); diff --git a/javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_edge_cases.feature b/javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_edge_cases.feature index 943bb811..cf9c4d7f 100644 --- a/javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_edge_cases.feature +++ b/javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_edge_cases.feature @@ -130,3 +130,46 @@ Feature: Hugo Bookshop CloudCannon Live Editing Edge Cases * 🌐 The selector div:nth-of-type(1)>span:nth-of-type(2) should contain 'text: Hello' * 🌐 The selector div:nth-of-type(2)>span:nth-of-type(1) should contain '_bookshop_name: text' * 🌐 The selector div:nth-of-type(2)>span:nth-of-type(2) should contain 'text: Hooray' + + Scenario: Hugo Bookshop live renders unsafe Markdown + Given a component-lib/components/cont/cont.hugo.html file containing: + """ +
{{ .text | markdownify }}
+ """ + Given [front_matter]: + """ + content: + text: |- +

Heading

+ + normal markdown + """ + And a site/content/_index.md file containing: + """ + --- + [front_matter] + --- + """ + And a site/layouts/index.html file containing: + """ + + + {{ partial "bookshop_bindings" `.Params.content` }} + {{ partial "bookshop" (slice "cont" .Params.content) }} + + + """ + And 🌐 I have loaded my site in CloudCannon + When 🌐 CloudCannon pushes new yaml: + """ + content: + text: |- +

Bolder Heading

+ + normal markdown + """ + And 🌐 "window.bookshopLive?.renderCount === 2" evaluates + Then 🌐 There should be no errors + * 🌐 There should be no logs + * 🌐 The selector h3 should match '

Bolder Heading

' + * 🌐 The selector p should match '

normal markdown

'