Re: [NTG-context] Modes in Lua
Thank you all! Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD Am 2017-05-31 um 18:57 schrieb Hans Hagen : > On 5/31/2017 4:51 PM, Pablo Rodriguez wrote: >> This is the way to detect system modes, but I don’t know how to do it >> for \mainlanguage (**en). >> \mainlanguage[es] >> \starttext >> \en\startlua >> if tex.systemmodes['en'] then >> context('Language is English.') >> else >> context('Language is not English.') >> end >> context('\\par') >> if tex.modes['es'] then >> context('Main language is Spanish.') >> else >> context('Main language is not Spanish.') >> end >> \stoplua >> \stoptext >> Just in case it help, > tex.modes['*en'] > tex.modes['**en'] > > tex.systemmodes['en'] > tex.systemmodes['*en'] > ___ 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 ___
[NTG-context] slashes in paths (Lua code)
Directories are a problem here. I mean, \shatwo{Desktop/i-context.pdf} cannot work in Windows. Here both of your example and an example by Hans worked fine on Windows. Note that \shatwo{Desktop/i-context.pdf} works only if the current directory is your %USERPROFILE%. Best, Akira ___ 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 ___
[NTG-context] Fw: APA Bibliographic refs. | Hyphenated first names | Lower case first letter of Title
Dear Readers, Following up on this post ... I've recently updated to `ConTeXt ver: 2017.05.28 19:30 MKIV beta' and have found that the APA code base seems to have changed a little. Previously (BibTeX ---> ConTeXt output): Hans-Georg Gadamer and H.-G. Gadamer &c. ---> H. -G. Gadamer but now I'm getting: ditto ---> HG. Gadamer Is this possible instead? Hans-Georg Gadamer and H.-G. Gadamer &c. ---> H.-G. Gadamer Best, Richard Begin forwarded message: Date: Mon, 22 May 2017 11:41:57 +1200 From: Richard Mahoney | Indica et Buddhica To: Mailing list for ConTeXt users Cc: r.maho...@indica-et-buddhica.org Subject: [NTG-context] APA Bibliographic refs. | Hyphenated first names | Lower case first letter of Title Dear list, I have been cleaning up the following proof-of-concept edition set with ConTeXt ver: 2017.05.15 21:48 MKIV beta: http://indica-et-buddhica.org/siksasamuccaya-progresse-bodhisattva-concept.pdf On the whole I'm very pleased but I'm noticing something odd with the APA typesetting. This can be seen on concept:226 & 229. Here is my set up followed by the BibTeX refs.: % Bibliographic referencing \usebtxdataset[thesis-clean-k-final.bib] \setupbtx[default:cite][alternative=num] \setupbtx[apa:cite][alternative=authoryear,compress=yes] \usebtxdefinitions[apa] \definebtxrendering[apa][specification=apa,sorttype=authoryear,numbering=no] \setupbtxlist[apa][alternative=paragraph,width=325pt,maxwidth=325pt,distance=.5em,margin=3em,align={hz,hanging}] 1.) For Hans-Georg and Jens-Uwe I'm getting H. -G. & J. -U. not H.-G. & J.-U.: @Book{gadamer:truth, author = "Hans-Georg Gadamer", title ="Truth and Method", publisher ="Seabury Press", shorttitle = "Truth", year = 1975, address = "New York", key = "gadamer:75", } @InCollection{klaus:einige, author = "K. Klaus", title ="Einige {t}extkritische {u}nd {e}xegetische {B}emerkungen {z}u {Ś}ānti\-devas “{Ś}ikṣāsamuccaya” (Kapitel {XII} {u}nd {XIII})", booktitle ="Bauddhaviyāsudhākaraḥ\,: Studies in Honour of Heinz Bec\-hert on the Occasion of His 65th Birthday", shorttitle = "\,‘{Ś}ikṣāsamuccaya’\,", key = "klaus:97a", pages ="397--406", publisher ="Indica et Tibetica", year = 1997, editor = "P. Kieffer-Pülz and Jens-Uwe Hartmann", volume = 30, address = "Swisttal-Odendorf", } 2.) And for the initial letter of the title, SGam.po.pa not sGgam.po.pa: @Book{guenther:sgam, title ="{s}{G}am.{p}o.{p}a, The Jewel Ornament of Liberation\,: {D}am.\-{c}hos {y}id.{b}žin.{g}yi {n}or.{b}u {t}har.{p}a {r}in.{p}o {c}he'i {r}gyan {ž}es.{b}ya.{b}a {t}heg.{p}a {c}hen.\-{p}o'{i} {l}am.{r}im.{g}yi {b}śad.{p}a", publisher ="Rider \& Co.", shorttitle = "{s}{G}am.{p}o.{p}a", year = 1970, key = "guenther:70a", address = "London", author = "H. V. Guenther", } I've also tried surrounding the hyphenated names, and their initials, with curly brackets, though without success. Does anyone know how I might be able to correct this? Best, Richard -- Richard Mahoney | INDICA ET BUDDHICA Littledene Bay Road Oxford New Zealand T: +64-3-312-1699 | www.indica-et-buddhica.org ___ 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 ___ -- Richard Mahoney | INDICA ET BUDDHICA Littledene Bay Road Oxford New Zealand T: +64-3-312-1699 | www.indica-et-buddhica.org ___ 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 ___
Re: [NTG-context] slashes in paths (Lua code)
On 5/31/2017 8:51 PM, Pablo Rodriguez wrote: Dear list, I need to add checksums to files I attach to PDF documents. Following the suggestion from https://stackoverflow.com/a/326715, I wrote: \starttext \startluacode function document.capture(cmd, raw) local f = assert(io.popen(cmd, 'r')) local s = assert(f:read('*a')) f:close() if raw then return s end s = string.gsub(s, '^%s+', '') s = string.gsub(s, '%s+$', '') s = string.gsub(s, '[\n\r]+', ' ') return s end function document.sha256(file) command_output= document.capture("sha256sum -b " .. file) context(command_output:sub(0,64)) end function document.sha512(file) command_output= document.capture("sha512sum -b " .. file) context(command_output:sub(0,128)) end \stopluacode \def\shatwo#1% {\ctxlua{document.sha256("#1")}} \def\shafive#1% {\ctxlua{document.sha512("#1")}} \shatwo{Desktop/i-context.pdf} \shafive{i-context.pdf} \stoptext Directories are a problem here. I mean, \shatwo{Desktop/i-context.pdf} cannot work in Windows. Which would be the way to make it work in Windows? \starttext \startluacode local function sha(cmd,name) local f = io.popen(string.format("%s -b %q",cmd,name),"rb") if f then local s = f:read("*a") f:close() -- s = string.longtostring(s) return string.match(s,"%s*([A-Fa-f0-9]+)") end end function document.sha256(name) local ok = sha("sha256sum",name) if ok then context(ok) end end function document.sha512(name) local ok = sha("sha512sum",name) if ok then context(ok) end end \stopluacode \def\shatwo #1{\ctxlua{document.sha256("#1")}} \def\shafive#1{\ctxlua{document.sha512("#1")}} \shafive{fd.pdf} \shafive{foo/fd.pdf} \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ 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 ___
[NTG-context] slashes in paths (Lua code)
Dear list, I need to add checksums to files I attach to PDF documents. Following the suggestion from https://stackoverflow.com/a/326715, I wrote: \starttext \startluacode function document.capture(cmd, raw) local f = assert(io.popen(cmd, 'r')) local s = assert(f:read('*a')) f:close() if raw then return s end s = string.gsub(s, '^%s+', '') s = string.gsub(s, '%s+$', '') s = string.gsub(s, '[\n\r]+', ' ') return s end function document.sha256(file) command_output= document.capture("sha256sum -b " .. file) context(command_output:sub(0,64)) end function document.sha512(file) command_output= document.capture("sha512sum -b " .. file) context(command_output:sub(0,128)) end \stopluacode \def\shatwo#1% {\ctxlua{document.sha256("#1")}} \def\shafive#1% {\ctxlua{document.sha512("#1")}} \shatwo{Desktop/i-context.pdf} \shafive{i-context.pdf} \stoptext Directories are a problem here. I mean, \shatwo{Desktop/i-context.pdf} cannot work in Windows. Which would be the way to make it work in Windows? Many thanks for your help, Pablo -- http://www.ousia.tk ___ 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 ___
Re: [NTG-context] Modes in Lua
On 5/31/2017 4:51 PM, Pablo Rodriguez wrote: On 05/31/2017 11:03 AM, MF wrote: if tex.modes['specialmode'] then context('I’m special.') end Best greetings, Massi Hi, this should be easy: How can I access ConTeXt’s modes in Lua? Is it any different with language modes (*en)? This is the way to detect system modes, but I don’t know how to do it for \mainlanguage (**en). \mainlanguage[es] \starttext \en\startlua if tex.systemmodes['en'] then context('Language is English.') else context('Language is not English.') end context('\\par') if tex.modes['es'] then context('Main language is Spanish.') else context('Main language is not Spanish.') end \stoplua \stoptext Just in case it help, tex.modes['*en'] tex.modes['**en'] tex.systemmodes['en'] tex.systemmodes['*en'] - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ 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 ___
Re: [NTG-context] Modes in Lua
On 05/31/2017 04:51 PM, Pablo Rodriguez wrote: > [...] > This is the way to detect system modes, but I don’t know how to do it > for \mainlanguage (**en). It was simple (not even using tex.systemmodes): \mainlanguage[es] \starttext \en\startlua if tex.modes['*en'] then context('Language is English.') else context('Language is not English.') end context('\\par') if tex.modes['**es'] then context('Main language is Spanish.') else context('Main language is not Spanish.') end \stoplua \stoptext Just in case it helps, Pablo -- http://www.ousia.tk ___ 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 ___
Re: [NTG-context] Modes in Lua
On 05/31/2017 11:03 AM, MF wrote: > if tex.modes['specialmode'] then > context('I’m special.') > end > > Best greetings, > Massi > >> Hi, this should be easy: >> >> How can I access ConTeXt’s modes in Lua? Is it any different with >> language modes (*en)? This is the way to detect system modes, but I don’t know how to do it for \mainlanguage (**en). \mainlanguage[es] \starttext \en\startlua if tex.systemmodes['en'] then context('Language is English.') else context('Language is not English.') end context('\\par') if tex.modes['es'] then context('Main language is Spanish.') else context('Main language is not Spanish.') end \stoplua \stoptext Just in case it help, Pablo -- http://www.ousia.tk ___ 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 ___
Re: [NTG-context] Modes in Lua
if tex.modes['specialmode'] then context('I’m special.') end Best greetings, Massi > Hi, this should be easy: > > How can I access ConTeXt’s modes in Lua? Is it any different with > language modes (*en)? > > e.g. > > \startluacode > > if context.modes['specialmode'] then > context('I’m special.') > end > > \stopluacode > ___ 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 ___
[NTG-context] Modes in Lua
Hi, this should be easy: How can I access ConTeXt’s modes in Lua? Is it any different with language modes (*en)? e.g. \startluacode if context.modes['specialmode'] then context('I’m special.') end \stopluacode Greetlings, Hraban --- http://www.fiee.net http://wiki.contextgarden.net GPG Key ID 1C9B22FD ___ 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 ___