From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/58523 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: tooltips and glossary Date: Wed, 5 May 2010 09:04:02 +0200 Message-ID: <20100505070402.GA21581@aides> References: <20100505070218.GA21609@aides> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0831571859==" X-Trace: dough.gmane.org 1273043112 12675 80.91.229.12 (5 May 2010 07:05:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 5 May 2010 07:05:12 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed May 05 09:05:11 2010 connect(): No such file or directory Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O9YfM-0006xh-91 for gctc-ntg-context-518@m.gmane.org; Wed, 05 May 2010 09:05:08 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id B9BE4C9C3E; Wed, 5 May 2010 09:05:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id vdtNdGb7i+wp; Wed, 5 May 2010 09:05:02 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 8BF09C9BA5; Wed, 5 May 2010 09:04:56 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 661B5C9BA5 for ; Wed, 5 May 2010 09:04:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mx55gOnIdNZy for ; Wed, 5 May 2010 09:04:51 +0200 (CEST) Original-Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by balder.ntg.nl (Postfix) with ESMTP id DD972C9B99 for ; Wed, 5 May 2010 09:04:51 +0200 (CEST) Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id o4574eDp023248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 5 May 2010 09:04:40 +0200 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id o4574osg023824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 5 May 2010 09:04:50 +0200 Original-Received: from localhost (mnhm-4d010ce9.pool.mediaWays.net [77.1.12.233]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id o4574gQQ003774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Wed, 5 May 2010 09:04:43 +0200 In-Reply-To: <20100505070218.GA21609@aides> X-Operating-System: Linux aides 2.6.34-rc3 User-Agent: Mutt/1.5.20 (2010-04-22) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:58523 Archived-At: --===============0831571859== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="da4uJneut+ArUgXk" Content-Disposition: inline --da4uJneut+ArUgXk Content-Type: multipart/mixed; boundary="l76fUT7nc3MelDdI" Content-Disposition: inline --l76fUT7nc3MelDdI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =2E.. forgot the attachment. --=20 () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments --l76fUT7nc3MelDdI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="glossarium.lua" Content-Transfer-Encoding: quoted-printable -- ---------------------------------------------------------------------------= ----- -- FILE: glossarium.lua -- USAGE: ConTeXt MkIV only -- DESCRIPTION: ad-hoc glossary -- AUTHOR: Philipp Gesang (Phg), -- VERSION: 1.0 -- CREATED: 04/05/10 13:00:54 CEST -- REVISION: 1 ---------------------------------------------------------------------------= ----- -- gloss =3D {} gloss.tracker, gloss.content =3D {}, {} function gloss.warn( text ) context.message( "=3D=3D GLOSSARY: " .. text ) end function gloss.newgloss( keyword, entry ) if gloss.content[keyword] then gloss.warn( "Entry for " .. keyword .. " exists. Skipping." ) else gloss.content[keyword] =3D entry end end function gloss.usegloss( keyword, explained_here) if gloss.content[keyword] then local indstring =3D "glossind:" .. keyword if explained_here ~=3D "" and not gloss.tracker[keyword] then local refstring =3D "gloss:" .. keyword context.reference({ refstring }, "") gloss.tracker[keyword] =3D true end context.goto(keyword, {indstring}) else gloss.warn( "No entry for " .. keyword .. ". Skipping." ) end end function gloss.place_glossary () -- get all keywords and sort them local sort_me =3D {} for key, _ in pairs(gloss.content) do table.insert(sort_me, key) end table.sort(sort_me) -- pretty print them somehow for _, keyword in ipairs(sort_me) do local refstring =3D "gloss:" .. keyword local indstring =3D "glossind:" .. keyword context.noindentation() context.reference({ indstring }, "") context.bgroup()=20 context.bf() --context.goto( keyword, { refstring } ) context(keyword) context.egroup() -- leave some space before entry context.hskip1em() context(gloss.content[keyword]) context.unskip() context(", (") context.at( "v.s. on p.", { refstring } ) context(").") context.par() end end =20 --l76fUT7nc3MelDdI Content-Type: text/x-tex; charset=us-ascii Content-Disposition: attachment; filename="glossarium.tex" Content-Transfer-Encoding: quoted-printable \setupinteraction[state=3Dstart] \ctxlua{dofile("glossarium.lua")} % Use \gloss#1#2 somewhere before \starttext, in a secondary file if you li= ke. % #1: gloss reference key (used as index) % #2: the entry (explanation) \def\gloss#1#2{% \ctxlua{gloss.newgloss("#1", "\luaescapestring{#2}")} } \def\dousegloss[#1]#2{% \ctxlua{gloss.usegloss("#2", "#1")}% } % Use this in your text to create a reference to the glossary. % #1: optional, If this is the main passage where you explain the entry in = detail,=20 % the glossary will link back here. (Just make it non-empty.) % #2: the gloss key \unexpanded\def\usegloss{\dosingleempty\dousegloss} % This is meant to create the glossary after the text: % The gloss key is typeset in bold face and will reference the point in the % main text where \usegloss was called with a nonempty first arg. \def\placeglossary{\ctxlua{gloss.place_glossary()}} \starttext \gloss{glossary}{% A collection of glosses; a list with explanations of abstruse, antiquated, dialectal, or technical terms; a partial dictionary. (As defi= ned by M.~Saunders)% } \gloss{index}{% An index (plural: indexes) is a list of words or phrases ('headings') and associated pointers ('locators') to where useful material relating to that heading can be found in a document. (As def'ed by the English Wikipedia) } test \usegloss{glossary} test. \page Here \usegloss{index} just occurs. \page The glossary entry \usegloss[exp]{index} is explained here. \page Here \usegloss{index} just occurs again. \footnote{Here \usegloss{index} just occurs again.} \page Here we'll deal with \usegloss[exp]{glossary} in detail. \page Here \usegloss{index} just occurs again. \page Here \usegloss{index} just occurs again. \page Here we mention \usegloss{glossary}. \page Here \usegloss{index} just occurs again. \page \placeglossary \stoptext --l76fUT7nc3MelDdI-- --da4uJneut+ArUgXk Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkvhGGIACgkQ02lYlJYWs9LIPwCglmD0RZ2ULXSI6wax1waJGLqI u8kAn1fMOOrYtMXQDrsIzlbRBvf2bEbH =o1pG -----END PGP SIGNATURE----- --da4uJneut+ArUgXk-- --===============0831571859== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============0831571859==--