e7's pluggable text quoters in format strings
I just implemented this. :)
The idea is that a format escape like %'foo's
applies foo-quotation to the generated text.
(%r also supports this)
Here's a REPL session:
>>> (format "<h1>%'html's</h1>" "<<>>")
0 (format "<h1>%'html's</h1>" "<<>>") /dev/ttyp4:1
FormatError: unknown quoter name html at 6 "<h1>%'html's</h1>"
>>> (import strings)
>>> (import html)
>>> (setattr strings.format-quoters 'html html.escape)
#<EFunction (s) (begin (set s (replace "&" "&" s)) (set s (replace "<" "<
;" s)) (set s (replace ">" ">" s)) (set s (replace "'" "'" s)) (set s (
replace "\"" """ s)) s)>
>>> (format "<h1>%'html's</h1>" "<<>>")
"<h1><<>></h1>"