diff --git a/lib/render.awk b/lib/render.awk index dca80ce..0035d47 100644 --- a/lib/render.awk +++ b/lib/render.awk @@ -58,7 +58,7 @@ action == "layout" { # replace yield with rendered content if (match($0, /{{{yield}}}/)) { - sub(/{{{yield}}}/, render_content(main)) + sub(/{{{yield}}}/, escape_special_chars(render_content(main))) } if (layout == "") { @@ -129,3 +129,9 @@ function run_filter(cmd, txt, rand_date, tmpfile, rendered_txt, date_cmd, filt return rendered_txt } + +# Prevent awk from replacing ampersand's with matched text +function escape_special_chars( txt) { + gsub(/&/, "\\\\&", txt) + return txt +}