[NTG-context] tooltips and glossary

Philipp Gesang pgesang at ix.urz.uni-heidelberg.de
Wed May 5 09:04:02 CEST 2010


... forgot the attachment.
-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments
-------------- 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.unskip()
        context(", (")
        context.at( "v.s. on p.", { refstring } )
        context(").")

        context.par()
    end
end


        

-------------- next part --------------
A non-text attachment was scrubbed...
Name: glossarium.tex
Type: text/x-tex
Size: 1862 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20100505/9b8b8d44/attachment.tex>
-------------- 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/20100505/9b8b8d44/attachment.pgp>


More information about the ntg-context mailing list