Dear Taco,
> Oh boy, I am sorry! My fault! The *correct* recipe is: run once, so the
> bbl exists, then delete the \setupbibtex line from your source, then
> edit the bbl, then recompile.
Thanks. This works now. I wrote a little python script now to save time and
thought maybe someone else might need it as well. It works for me but it was 
just a quick shot. There was not much time to think about all possibilities, 
and may be the regular expressions need to be modified. I first need to get this
thesis finished. So no guarantee.

All the best

Hubertus
#!/usr/bin/python
# -*- coding: utf-8 -*-

import re
import shutil

fileName    = 'filename.bbl'            # Change here the filename
fileNameOld = fileName + '-old'         
shutil.copyfile(fileName, fileNameOld)  # Make a copy of the file
f = open(fileNameOld)
out = open(fileName, 'w')

author  = re.compile('a={+( [^}]* ) }', re.VERBOSE) # Find author
author3 = re.compile('(\w{2,3})')                   # Get the first 3 letters
year    = re.compile('y=\d{2,} (\d{2,}\w?)', re.VERBOSE) # Get the year e.g. 09a
shortRe = re.compile('(s=)(.*)\]')                  # Substitute the short key 
while True:
    tmp = [] # Array where from \startpulication[...] ... is saved
    line = f.readline()
    # Look for the start of a new publication
    if line.find('startpublication') >= 0:
        tmp.append(line)
        # Go the end of that publication \startpulication[...]
        while True:
            a = f.readline()
            tmp.append(a)
            if a.find(']') >= 0:
                break
        # Go through tmp to get the needed information
        short = ''
        for i in range(len(tmp)):
            a = tmp[i]
            if author.search(a):
                short = ''
                short = author3.findall(author.findall(a)[0])[0]
            if year.search(a):
                short += year.findall(a)[0]
            if shortRe.search(a):
                a = shortRe.sub(r'\1%s]', a) % short
            out.write(a)
    # If no entry in \startpulication[...] just write it again to the file
    else:
        out.write(line)

    # reached end of file
    if line == '':
        break

f.close()
out.close()
___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to