# No substitutions
abcd abcd
# Lone specials
ab%cd ab%cd
ab{cd ab{cd
ab%{cd ab%{cd
ab}cd ab}cd
ab\cd ab\cd
ab|cd ab|cd
ab\{cd ab\{cd
ab\}cd ab\}cd
ab\|cd ab\|cd
ab\%cd ab\%cd
ab\\cd ab\\cd
ab\&cd ab\&cd
abc\ abc\
# Variable
ab%{head}def abyesdef
ab%{head}def%{head}xy abyesdefyesxy
%{head}def yesdef
%{h}def Zdef
# Subtitute the value
X%{head}Y XyesY
X%{head=yes}Y XY
X%{head=no}Y XY
# No value is empty string
X%{headx}Y XY
# Subtitute the 'true' part
X%{head|}Y XY
X%{head|foo}Y XfooY
X%{head|fo\|o}Y Xfo|oY
# %{} refers to the value of the key.
X%{head|This is %{}!}Y XThis is yes!Y
X%{head=yes|This is %{}!}Y XThis is yes!Y
X%{head=no|This is %{}!}Y XY
X%{capo=1|%{} capo|%{} capoes}Y X1 capoY
X%{capo=0|%{} capoes|%{} capo}Y X1 capoY
# But only within a %{ ... }.
X%{}Y X%{}Y
# Subtitute the 'false' part
X%{head=no|foo|bar}Y XbarY
X%{hexd|foo|bar}Y XbarY
X%{hexd=yes|foo|bar}Y XbarY
X%{hexd=no|foo|bar}Y XbarY
X%{hexd=|foo|bar}Y XfooY
X%{hexd|foo}Y XY
X|%{hexd|fo\|o}|Y X||Y
X%{h|foo|bar}Y XfooY
X%{h=Z|foo|bar}Y XfooY
# Nested.
X%{head|x%{foo}z|bar}Y XxzY
X%{hexd|x%{foo}z|bar}Y XbarY
X%{head|x%{h|\\\|}z|bar}Y Xx|zY
X%{head|x%{foo||\\\|}z|bar}Y Xx|zY
# Note that %{} is the value of foo (inner), not head (outer)
X%{head|x%{foo|ab|f%{}g}z}Y XxfgzY
# Recursive substitution.
%{subtitle} CAPO 1
# Transpose.
%{key} G
# Formatting
%{capo:%02d} 01
%{capo=1|%{capo:%02d}|no} 01
%{capo:%02d=01|yes%{}|no} yes01
[%{capo:%6.2s}] [ 1]
# Case changers
%{title:uc} HI THERE!
%{title:lc} hi there!
%{title:ic} Hi There!
%{title:lc:ic} Hi There!
%{title:sc} Hi There!
%{title:lc:sc} Hi there!
# Formatting doesn't interfere with definedness
X%{1:%02d}Y XY
X%{hexd:sc}Y XY
# Padding
X%{key:lpad(0)}Y XGY
X%{key:lpad(4)}Y X GY
X%{key:lpad(4,-)}Y X---GY
X%{key:lpad(4,xy)}Y XxyxGY
X%{head:lpad(2)}Y XyesY
X%{head:lpad(3)}Y XyesY
X%{key:rpad(4)}Y XG Y
X%{key:rpad(4,-)}Y XG---Y
X%{key:rpad(4,xy)}Y XGxyxY
X%{head:rpad(2)}Y XyesY
X%{head:rpad(3)}Y XyesY
# Replace
%{title:replace( ,_)} Hi_There!
%{title:replace( ,,)} Hi,There!
%{title:replace( ,,):replace(,, )} Hi There!
%{title:replace( ,\:):replace(\:, )} Hi There!
%{title:replace(!,)} Hi There
%{title:replace(!,\})} Hi There}