Skip to content

Commit a1c004b

Browse files
committed
enable hugo shortcodes to pass through
1 parent 97f52c7 commit a1c004b

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/format/formats.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,19 @@ function hugoFormat(): Format {
216216
[kHtmlMathMethod]: "webtex",
217217
[kWrap]: "preserve",
218218
},
219+
formatExtras: () => {
220+
return {
221+
postprocessors: [(output: string) => {
222+
// unescape shortcodes
223+
Deno.writeTextFileSync(
224+
output,
225+
Deno.readTextFileSync(output)
226+
.replaceAll("{{\\<", "{{<")
227+
.replaceAll("\\>}}", ">}}"),
228+
);
229+
}],
230+
};
231+
},
219232
});
220233
}
221234

src/resources/filters/quarto-pre/shortcodes.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ function transformShortcodeBlocks(blocks)
9898
local onlyShortcode = onlyShortcode(block.content)
9999
if onlyShortcode ~= nil then
100100
-- there is a shortcode here, process it and return the blocks
101-
local shortCode = processShortCode(onlyShortcode)
102-
local handler = handlerForShortcode(shortCode)
103-
if handler ~= nil then
104-
local transformedShortcode = callShortcodeHandler(handler, shortCode)
105-
if transformedShortcode ~= nil then
106-
tappend(scannedBlocks, shortcodeResultAsBlocks(transformedShortcode, shortCode.name))
107-
transformed = true
108-
end
109-
else
110-
warn("Shortcode " .. shortCode.name .. " is not recognized.")
101+
local shortCode = processShortCode(onlyShortcode)
102+
local handler = handlerForShortcode(shortCode)
103+
if handler ~= nil then
104+
local transformedShortcode = callShortcodeHandler(handler, shortCode)
105+
if transformedShortcode ~= nil then
106+
tappend(scannedBlocks, shortcodeResultAsBlocks(transformedShortcode, shortCode.name))
107+
transformed = true
111108
end
109+
else
110+
scannedBlocks:insert(block)
111+
end
112112
else
113113
scannedBlocks:insert(block)
114114
end

0 commit comments

Comments
 (0)