Interpret '%%' as literal '%' in format

This commit is contained in:
Benedikt Heine 2017-09-06 21:38:43 +02:00
parent ab9bf55892
commit 4b7f656f6e
3 changed files with 10 additions and 0 deletions

View File

@ -324,6 +324,8 @@ equivalent notification attribute.
=item B<%n> progress value without any extra characters =item B<%n> progress value without any extra characters
=item B<%%> Literal %
=back =back
If any of these exists in the format but hasn't been specified in the If any of these exists in the format but hasn't been specified in the

View File

@ -123,6 +123,7 @@
# %I iconname (without its path) # %I iconname (without its path)
# %p progress value if set ([ 0%] to [100%]) or nothing # %p progress value if set ([ 0%] to [100%]) or nothing
# %n progress value if set without any extra characters # %n progress value if set without any extra characters
# %% Literal %
# Markup is allowed # Markup is allowed
format = "<b>%s</b>\n%b" format = "<b>%s</b>\n%b"

View File

@ -387,6 +387,13 @@ int notification_init(notification *n, int id)
n->progress ? pg : "", n->progress ? pg : "",
MARKUP_NO); MARKUP_NO);
break; break;
case '%':
n->msg = notification_replace_single_field(
n->msg,
&substr,
"%",
MARKUP_NO);
break;
case '\0': case '\0':
fprintf(stderr, "WARNING: format_string has trailing %% character." fprintf(stderr, "WARNING: format_string has trailing %% character."
"To escape it use %%%%."); "To escape it use %%%%.");