* Re: Index items (additional question) [not found] <mailman.159.1429437332.8971.ntg-context@ntg.nl> @ 2015-04-19 18:30 ` Robert Blackstone 0 siblings, 0 replies; 3+ messages in thread From: Robert Blackstone @ 2015-04-19 18:30 UTC (permalink / raw) To: ntg-context On 19 Apr 2015, at 11:55 , Hans Hagen <pragma@wxs.nl> wrote > > On 4/19/2015 9:47 AM, Robert Blackstone wrote: >> >> On 16 Apr 2015, at 15:38 , Hans Hagen <pragma@wxs.nl> gave me the following: >> >>> \startluacode >>> >>> document.indexentries = { >>> ["rule"] = [[Rule(s)]], >>> ["ruleimperfect"] = [[+ \quote{imperfect to perfect, from}]], >>> ["galilei"] = [[Galilei, Vincenzo]], >>> } >>> >>> function document.getindexentry(n) >>> context("\\index[%s]{%s}",n,document.indexentries[n] or ("<" .. >>> n .. ">")) >>> end >>> >>> \stopluacode >>> >>> \unexpanded\def\InEn[#1]% >>> {\ctxlua{document.getindexentry("#1")}} >>> >>> \starttext >>> That this rule >>> \InEn[rule] >>> \InEn[ruleimperfect] was not applied by everybody is for example shown >>> in {\em Fronimo}% >>> \InEn[galilei] >>> >>> etc etc >> >> >> This code works beautifully in this way, with only a few index entries at the top of the file, before \starttext. >> But how can I deal with the thousand or more index items in my project, which I have collected in four separate dedicated files with indexentries, like the three shown in the example-code. >> >> I have really no idea what else should be in these files, what sort of name they should have, in particular extension, and how and where I can input them. >> I use TeXShop as my texteditor but that is probably not relevant here. >> >> Can you give me some guidance, please? > > \startluacode > > document.indexentries = { > ["rule"] = [[Rule(s)]], > ["ruleimperfect"] = [[+ \quote{imperfect to perfect, from}]], > ["galilei"] = [[Galilei, Vincenzo]], > } > > function document.loadindexentries(filename) > local fullname = resolvers.findfile(filename) > if fullname ~= "" then > local data = io.loaddata(fullname) > for a, b in string.gmatch(data,"%s*(%S+)%s+([^\n\r]+)") do > document.indexentries[a] = b > end > end > end > > function document.getindexentry(n) > local ie = document.indexentries[n] > if not ie then > logs.report("index","missing entry %a",n) > end > context("\\index[%s]{%s}",n,ie or ("<" .. n .. ">")) > end > > \stopluacode > > \unexpanded\def\LoadInEn[#1]{\ctxlua{document.loadindexentries("#1")}} > \unexpanded\def\InEn [#1]{\ctxlua{document.getindexentry("#1")}} > > \LoadInEn[whatever.txt] > > \starttext > That this rule > \InEn[rule] > \InEn[ruleimperfect] was not applied by everybody is for example shown > in {\em Fronimo}% > \InEn[galilei] > > \InEn[unknown] > > etc etc > > \InEn[GalileiFronimo] > \InEn[Cadence] > \InEn[CadenceP] > \InEn[PlagalCad] > \index[Fronimo]{{\em Fronimo} (Galilei)} (1584), Vincenzo Galileo's > treatise on lute playing and the intabulation% > \index[Intabulation]{intabulation} of vocal music. > \page > > whatever.txt: > > GalileiFronimo +{\em Fronimo} > Cadence cadence(s) > CadenceP + plagal > PlagalCad plagal cadence > Hi Hans, Thank you for your reply. It took me a while to make your code operational in the way I need it. For the new example you gave is still an "integral file". My project, like most book-projects, I guess, is modular with a master file Project.tex, into which everything else, setups, .bbl's, front- and backmatter, the various chapters are input. Though strictly speaking it would not be impossible to add some 1000 lines of index entries before \startproject, it would not be especially handy, and I cannot believe that it would be the proper ConTeXt-way to do it. I found that when I split your code, transferred the top part to a new file, which I named "IndexItems", and input that into the other half, the text proper, it works. But when I add another file with indexentries, for instance "indexitemsnames", then only one of them, the one at the top is used. So it seems that the whole collection of index items must be in one file. Is that the only possibility or are there ways to enable the use of several collections of index items? Best regards, Robert ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <mailman.128.1429191487.8971.ntg-context@ntg.nl>]
* Re: Index items (additional question) [not found] <mailman.128.1429191487.8971.ntg-context@ntg.nl> @ 2015-04-19 7:47 ` Robert Blackstone 2015-04-19 9:50 ` Hans Hagen 0 siblings, 1 reply; 3+ messages in thread From: Robert Blackstone @ 2015-04-19 7:47 UTC (permalink / raw) To: ntg-context On 16 Apr 2015, at 15:38 , Hans Hagen <pragma@wxs.nl> gave me the following: > \startluacode > > document.indexentries = { > ["rule"] = [[Rule(s)]], > ["ruleimperfect"] = [[+ \quote{imperfect to perfect, from}]], > ["galilei"] = [[Galilei, Vincenzo]], > } > > function document.getindexentry(n) > context("\\index[%s]{%s}",n,document.indexentries[n] or ("<" .. > n .. ">")) > end > > \stopluacode > > \unexpanded\def\InEn[#1]% > {\ctxlua{document.getindexentry("#1")}} > > \starttext > That this rule > \InEn[rule] > \InEn[ruleimperfect] was not applied by everybody is for example shown > in {\em Fronimo}% > \InEn[galilei] > > etc etc Hi Hans, sorry to bother you again on this topic. This code works beautifully in this way, with only a few index entries at the top of the file, before \starttext. But how can I deal with the thousand or more index items in my project, which I have collected in four separate dedicated files with indexentries, like the three shown in the example-code. I have really no idea what else should be in these files, what sort of name they should have, in particular extension, and how and where I can input them. I use TeXShop as my texteditor but that is probably not relevant here. Can you give me some guidance, please? Thanks in advance. Best regards, Robert Blackstone ___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Index items (additional question) 2015-04-19 7:47 ` Robert Blackstone @ 2015-04-19 9:50 ` Hans Hagen 0 siblings, 0 replies; 3+ messages in thread From: Hans Hagen @ 2015-04-19 9:50 UTC (permalink / raw) To: mailing list for ConTeXt users On 4/19/2015 9:47 AM, Robert Blackstone wrote: > > On 16 Apr 2015, at 15:38 , Hans Hagen <pragma@wxs.nl> gave me the following: > >> \startluacode >> >> document.indexentries = { >> ["rule"] = [[Rule(s)]], >> ["ruleimperfect"] = [[+ \quote{imperfect to perfect, from}]], >> ["galilei"] = [[Galilei, Vincenzo]], >> } >> >> function document.getindexentry(n) >> context("\\index[%s]{%s}",n,document.indexentries[n] or ("<" .. >> n .. ">")) >> end >> >> \stopluacode >> >> \unexpanded\def\InEn[#1]% >> {\ctxlua{document.getindexentry("#1")}} >> >> \starttext >> That this rule >> \InEn[rule] >> \InEn[ruleimperfect] was not applied by everybody is for example shown >> in {\em Fronimo}% >> \InEn[galilei] >> >> etc etc > > Hi Hans, > sorry to bother you again on this topic. > > This code works beautifully in this way, with only a few index entries at the top of the file, before \starttext. > But how can I deal with the thousand or more index items in my project, which I have collected in four separate dedicated files with indexentries, like the three shown in the example-code. > > I have really no idea what else should be in these files, what sort of name they should have, in particular extension, and how and where I can input them. > I use TeXShop as my texteditor but that is probably not relevant here. > > Can you give me some guidance, please? \startluacode document.indexentries = { ["rule"] = [[Rule(s)]], ["ruleimperfect"] = [[+ \quote{imperfect to perfect, from}]], ["galilei"] = [[Galilei, Vincenzo]], } function document.loadindexentries(filename) local fullname = resolvers.findfile(filename) if fullname ~= "" then local data = io.loaddata(fullname) for a, b in string.gmatch(data,"%s*(%S+)%s+([^\n\r]+)") do document.indexentries[a] = b end end end function document.getindexentry(n) local ie = document.indexentries[n] if not ie then logs.report("index","missing entry %a",n) end context("\\index[%s]{%s}",n,ie or ("<" .. n .. ">")) end \stopluacode \unexpanded\def\LoadInEn[#1]{\ctxlua{document.loadindexentries("#1")}} \unexpanded\def\InEn [#1]{\ctxlua{document.getindexentry("#1")}} \LoadInEn[whatever.txt] \starttext That this rule \InEn[rule] \InEn[ruleimperfect] was not applied by everybody is for example shown in {\em Fronimo}% \InEn[galilei] \InEn[unknown] etc etc \InEn[GalileiFronimo] \InEn[Cadence] \InEn[CadenceP] \InEn[PlagalCad] \index[Fronimo]{{\em Fronimo} (Galilei)} (1584), Vincenzo Galileo's treatise on lute playing and the intabulation% \index[Intabulation]{intabulation} of vocal music. \page whatever.txt: GalileiFronimo +{\em Fronimo} Cadence cadence(s) CadenceP + plagal PlagalCad plagal cadence ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-19 18:30 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <mailman.159.1429437332.8971.ntg-context@ntg.nl> 2015-04-19 18:30 ` Index items (additional question) Robert Blackstone [not found] <mailman.128.1429191487.8971.ntg-context@ntg.nl> 2015-04-19 7:47 ` Robert Blackstone 2015-04-19 9:50 ` Hans Hagen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).