On Sun, 5 Feb 2017, Rogers, Michael K wrote:
Let's say I want a link to plot x+2 in Wolfram|Alpha. I need to catenate "http://www.wolframalpha.com/input/?i=" and "plot+x%2B2". Is there any way already available in ConTeXt to translate reserved characters like "+" to the percent-hexcode "%2B"?
Something like
\encode[plot x+2]
would become
plot+x%2B2
Or more generally, some languages have a query constructor like this
\queryURI [http://www.wolframalpha.com/input] [i=plot x+2]
which would construct the URI
http://www.wolframalpha.com/input/?i=plot+x%2B2
I could write my own, of course. But no need to reinvent the wheel.
url.escape does exactly that. \startluacode local base="http://www.wolframalpha.com/input" local query="i=plot x+2" local fullname = base .. query print(url.escape(fullname)) \stopluacode gives http%3A//www.wolframalpha.com/inputi%3Dplot%20x%2B2 Also look at l-url.lua for other helper functions for parsing and escaping/unescaping urls. Aditya