Encoding reserved characters in URI query strings
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. TIA, Michael ________________________________ This e-mail message (including any attachments) is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message (including any attachments) is strictly prohibited. If you have received this message in error, please contact the sender by reply e-mail message and destroy all copies of the original message (including attachments).
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
On Feb 5, 2017, at 12:09 PM, Aditya Mahajan
wrote: 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
Thanks! I figured there must be a function like that. Michael ________________________________ This e-mail message (including any attachments) is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message (including any attachments) is strictly prohibited. If you have received this message in error, please contact the sender by reply e-mail message and destroy all copies of the original message (including attachments).
Dear list, Thanks to the list and to Hans and Alan's manual "mkiv-publications", I has achieved some footnotes with bibliographical dataset. All is fine and I success to manage what I want. But I don't understand why the word 'Author' is printed at the end of each line as the following minimal sample below shows it, e.g. : Aristote (n.d.). Les Politiques. Author. Cicéron (n.d.). Tusculanes, V, 8. Author. (see the sample's printed page 2) Is there a question of language (english), or anything else ? How to avoid this 'Author' ? I use the APA style with \usebtxdefinitions, and maybe one can use some other style ? Anyway, many thanks for your help ! JP \startbuffer[biblio] @book{Cicéron1, author = {Cicéron}, title = {Tusculanes, V, 8}, } @book{Aristote2, author = {Aristote}, title = {Les Politiques}, } \stopbuffer \usebtxdataset[philosophie ancienne][biblio.buffer] \usebtxdefinitions[apa] \definebtxrendering[philosophie ancienne][apa][dataset=philosophie ancienne] \setupbtxrendering[continue =yes] \starttext \startchapter[title={Introduction à la Philosophie}] Dans les notes qui suivent, on s’intéressera à la pensée philosophique comme philosophie politique. Aristote, le philosophe grec qui publia et commenta les Constitutions des anciennes cités grecques, commence son ouvrage {\it les Politiques} par la thèse selon laquelle \quotation {l’homme est un animal politique}\footnote{\cite[alternative=entry][philosophie ancienne::Aristote2]}. \blank Cicéron, ce grand homme politique et cet écrivain savant, a eu la formule bien connue, selon laquelle \quotation{Socrate fit descendre la philosophie du ciel sur la terre.}\footnote{\cite[alternative=entry][philosophie ancienne::Cicéron1]}, qui désigne la question fondamentale de l’intérêt nourri par la philosophie pour les {\it choses humaines}. \stopchapter \starttext \startbackmatter \startchapter[title={Bibliographie}] \startsection[title={Philosophie ancienne}] \placelistofpublications[philosophie ancienne][method=local] \stopsection \stopchapter \stopbackmatter \stoptext ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Tue, 7 Feb 2017 13:24:07 +0100
Jean-Pierre Delange
But I don't understand why the word 'Author' is printed at the end of each line as the following minimal sample below shows it, e.g. : Aristote (n.d.). Les Politiques. Author. Cicéron (n.d.). Tusculanes, V, 8. Author.
According to the APA style manual, a book without a publisher is self-published, and one is directed to use the word "Author". To avoid this, you need to complete the dataset entry, or else choose a category other than @book such as @unpublished. Alan
participants (4)
-
Aditya Mahajan
-
Alan Braslau
-
Jean-Pierre Delange
-
Rogers, Michael K