Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Getting a "text: invalid markup in text (Vips::Error)" error when adding a simple "&" to the annotate example #342

Answered by jcupitt
luctus asked this question in Q&A
Discussion options

Hey there!

I'm new here. I've been playing around with vips to generate images and I'm having super fun to be honest. I've ported all I had from imagemagick and it's loading way faster, so I'm pretty happy with that.

However, I'm getting this error when trying this annotate example if I change the text left corner by left & corner, in the 7th line.:

/Users/tavo/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/ruby-vips-2.1.4/lib/vips/operation.rb:228:in `build': text: invalid markup in text (Vips::Error)
	from /Users/tavo/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/ruby-vips-2.1.4/lib/vips/operation.rb:483:in `call'
	from /Users/tavo/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/ruby-vips-2.1.4/lib/vips/image.rb:234:in `method_missing'
	from test.rb:7:in `<main>'

As you can see in those logs, I'm running ruby 3.1.2 and ruby-vips 2.1.4 (vips-8.12.2)

Do I need to scape or encode or something that parameter?

Thanks in advance!

You must be logged in to vote

Hi @luctus,

The text operator supports pango markup, so yes, you need eg. &amp;. You'll need to escape < and > as well.

https://docs.gtk.org/Pango/pango_markup.html

https://www.libvips.org/2021/06/04/What's-new-in-8.11.html#full-colour-text-rendering

Replies: 2 comments

Comment options

Hi @luctus,

The text operator supports pango markup, so yes, you need eg. &amp;. You'll need to escape < and > as well.

https://docs.gtk.org/Pango/pango_markup.html

https://www.libvips.org/2021/06/04/What's-new-in-8.11.html#full-colour-text-rendering

You must be logged in to vote
0 replies
Answer selected by luctus
Comment options

Thanks a lot, @jcupitt !

So, just to confirm... instead of this:

left_text = Vips::Image.text "left & corner", dpi: 300

I should be using this:

left_text = Vips::Image.text CGI.escapeHTML("left & corner"), dpi: 300

I just tested it and it worked ;)

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /