prevent awk from replacing ampersand's with matched text

This commit is contained in:
nuex 2011-12-02 10:05:20 -05:00
parent f84c185a16
commit b07f9f4fe8

View File

@ -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
}