Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template helper function for pango markup escaping #133

Closed
un-def opened this issue Apr 23, 2019 · 3 comments
Closed

Add template helper function for pango markup escaping #133

un-def opened this issue Apr 23, 2019 · 3 comments

Comments

@un-def
Copy link

un-def commented Apr 23, 2019

I use playerctl metadata with i3bar and forced to use none markup mode because any special char (<, >, &, etc.) in metadata field breaks pango markup.

It would be convenient to have some helper function to encode special chars to corresponding entities (e.g., <&lt;). This would allow to use pango markup safely, for example:

playerctl --follow metadata --format '<b>pango_escape({{artist}})</b> — pango_escape({{title}})'

I guess this can be done quite easily with g_markup_escape_text().

@acrisci
Copy link
Member

acrisci commented Apr 24, 2019

Yeah seems like a good feature. I also use playerctl with i3bar so I would use this.

Instead of pango_escape, I would call it markup_escape or maybe xml_escape and the format string would look like this:

'<b>{{markup_escape(artist)}}</b> — {{markup_escape(title)}}'

jklotz77 added a commit to jklotz77/playerctl that referenced this issue Jun 3, 2019
acrisci added a commit that referenced this issue Jun 4, 2019
#133 Add markup_escape formatter helper function
@acrisci
Copy link
Member

acrisci commented Jun 16, 2019

It's in latest and has tests but needs documentation.

@un-def
Copy link
Author

un-def commented Jun 18, 2019

It's great! I just did a quick check, the new helper works well.

@acrisci acrisci closed this as completed Jun 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants