[NTG-context] tooltips and glossary

Philipp Gesang pgesang at ix.urz.uni-heidelberg.de
Tue May 4 14:28:59 CEST 2010


(Preliminary remark to M.S.: please, please, configure your MUA to
correctly reply to the current thread!)


Hi Michael,


I'm cc'ing you in case the list eats the attachments.

On 2010-05-04 <04:44:21>, Michael Saunders wrote:
> Marius:
> 
> > Try this one: http://www.tex.ac.uk/tex-archive/info/context-top-ten/cmds.pdf
> > -> page 14
> 
> Thanks, but that looks like it's just some extracts from cont-eni
> translated from Engijsh into Engrish along with a distracting

No, it's plain English. Unfamiliar phrases are just one consequence of a
language becoming the world standard. Do you want to flame Italians or
French for not adhering to the norms of classical Latin? You don't.
There's no point at all in even mentioning somebody's stylistic
idiosyncrasies on the internets. Just face it: the world won't adopt
English as a global means of communication without interfering with its
norms. If you don't understand something why don't you contact the
author, his email adress is right there on the first page.

> more clear.  A glossary is like a little dictionary in the back of a
> book that defines the specialized words and phrases that the book uses
> that might not be known to the general reader.  Here is a definition
> of "glossary":

> Ideally, I'd like a system where I could keep the entries in a bib
> database or in a special .tex file.  The records would include the
> headword and the gloss, and maybe a cross reference to the point in
> the text that dealt with the headword definitively---the point where
> the term was explained.  (A document that defines and explains the new
> words and phrases it coins---imagine such a thing!)  It would be nice
> if there were a command that would automatically link this point in
> the text with the glossary entry.  LaTeX has several packages
> (glosstex, gloss, glossary, glossaries) that do things like this.

I append a snippet that should allow basic glossaries. It doesn't
provide much functionality (capitalization might have to be implemented
…) but you may fit it to your needs. As for the tooltips, unfortunately
I don't know how to create them. The functionality would be nice,
though, as long as no javascript is involved.

(As for the code, it's certainly not context style, I'm aware of that
but don't have the time to care.)

Awaiting your feedback,


Philipp

> To do this in Context, I will probably have to do it all manually,
> defining a command to set an entry and then doing all the
> alphabetization and cross-referencing by hand.
> 
> What I would really, really, like is to add short definitions to each
> glossary record that could pop up as tooltips when the reader hovers
> over an unfamiliar word.  Since there is no mechanism for glossaries
> in Context, there is no mechanism to build this into, but I'm still
> interested in doing it.  The idea is, I could write something like:
> 
> \gloss{strange word}{short definition}
> 
> The text would read "strange word".  When you hover over it with the
> cursor, a tooltip would appear saying "short definition".  It would be
> great if this were linked to a glossary mechanism so I wouldn't have
> to keep writing the short definition---I could say something like:
> 
> \gloss{strange word}
> 
> and its short definition would be looked up automatically for the
> tooltip.  The automatic reference to the word might look like this, in
> the text:
> 
> \gref{strange word}
> 
> which would cause the page number at that point to be printed at the
> end of the glossary entry for "strange word".
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context at 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
> ___________________________________________________________________________________

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glossarium.tex
Type: text/x-tex
Size: 1799 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20100504/26f02e89/attachment.tex>
-------------- next part --------------
--
--------------------------------------------------------------------------------
--         FILE:  glossarium.lua
--        USAGE:  ConTeXt MkIV only
--  DESCRIPTION:  ad-hoc glossary
--       AUTHOR:  Philipp Gesang (Phg), <megas.kapaneus at gmail.com>
--      VERSION:  1.0
--      CREATED:  04/05/10 13:00:54 CEST
--     REVISION:  1
--------------------------------------------------------------------------------
--

gloss = {}
gloss.tracker, gloss.content = {}, {}

function gloss.warn( text )
    context.message( "== GLOSSARY: " .. text )
end

function gloss.newgloss( keyword, entry )
    if gloss.content[keyword] then
        gloss.warn( "Entry for " .. keyword .. " exists. Skipping." )
    else
        gloss.content[keyword] = entry
    end
end

function gloss.usegloss( keyword, explained_here)
    if gloss.content[keyword] then
        local indstring = "glossind:" .. keyword
        if explained_here ~= "" and
           not gloss.tracker[keyword] then
            local refstring = "gloss:" .. keyword
            context.reference({ refstring }, "")
            gloss.tracker[keyword] = 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 = {}
    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 = "gloss:"    .. keyword
        local indstring = "glossind:" .. keyword
        context.noindentation()
        context.reference({ indstring }, "")
        context.bgroup() 
            context.bf()
            context.goto( keyword, { refstring } )
            --context(keyword)
        context.egroup()
        -- leave some space before entry
        context.hskip1em()
        context(gloss.content[keyword])
        context.par()
    end
end


        

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20100504/26f02e89/attachment.pgp>


More information about the ntg-context mailing list