Contents
Bibtex2 Parser
Description
The Bibtex2 parser allows you to have bibtex code rendered nicely inside Moin's code blocks. For a similar parser, see ParserMarket/Bibtex
Download & Release Notes
Download |
Release Version |
Moin Version |
Release Notes |
1.5.2 |
1.9 |
Installation
For general installation instructions, see ParserMarket/InstallingParsers. For more detailed instructions, see /Installation
Usage
To use this parser, simply put #!bibtex after the beginning of the code block.
Example
{{{#!bibtex @Book{aho.74, author= {Alfred V. Aho and John E. Hopcroft and Jeffrey D. Ullman}, title = {The Design and Analysis of Computer Algorithms}, publisher= {Addison-Wesley}, year = {1974}, } }}}
Copyright
This parser is copyrighted by JunHu and Alexandre Duret-Lutz
License
This parser is released under the terms of the GNU GPL.
Discussion
Hi Jun, very useful parser, I would have 2 suggestions:
- is it possible to have next to the bibtex some buttons "bibtex, "abstract", "pdf" that would allow to show or not the corresponding entry (I wished to be able to show the raw bibtex entry without the people having to click on "see raw text)
- I use also the latex parser... how difficult is it to use both?
thanks again
Dear Jun
in the actual version there are no formatting used in HlinsDatabase
Howard Barringer = http://www.cs.man.ac.uk/fmethods/people/howard.html Roderick Bloem = http://vlsi.colorado.edu/~rbloem/ Edmund M. Clarke = http://www-2.cs.cmu.edu/~emc/ Costas Courcoubetis = http://www.aueb.gr/users/courcou/ Jean-Michel Couvreur = http://www.labri.fr/~couvreur Edsger Wybe Dijkstra = http://www.cs.utexas.edu/users/EWD/
I would prefer if this could be changed to list items
Howard Barringer = http://www.cs.man.ac.uk/fmethods/people/howard.html
Roderick Bloem = http://vlsi.colorado.edu/~rbloem/
Edmund M. Clarke = http://www-2.cs.cmu.edu/~emc/
Costas Courcoubetis = http://www.aueb.gr/users/courcou/
Jean-Michel Couvreur = http://www.labri.fr/~couvreur
Edsger Wybe Dijkstra = http://www.cs.utexas.edu/users/EWD/
The updated version does what you want But instead of a bullet list, a description list can be used:
Howard Barringer:: http://www.cs.man.ac.uk/fmethods/people/howard.html Roderick Bloem:: http://vlsi.colorado.edu/~rbloem/ Edmund M. Clarke:: http://www-2.cs.cmu.edu/~emc/ Costas Courcoubetis:: http://www.aueb.gr/users/courcou/ Jean-Michel Couvreur:: http://www.labri.fr/~couvreur Edsger Wybe Dijkstra:: http://www.cs.utexas.edu/users/EWD/
(also notice that a white space ' ' can be used to match .) Then it will have some formatting:
- Howard Barringer
- Roderick Bloem
- Edmund M. Clarke
- Costas Courcoubetis
- Jean-Michel Couvreur
- Edsger Wybe Dijkstra
I don't understand why this code works and yours not. I have removed all my changes and now your code works too. Probably it was the flush on the pipe I don't know. Because I am not sure already missing something I better put the whole code on this page. -- ReimarBauer 2005-03-07 20:16:04
- Hi Reimar, thank you very much for your effort and help. But unfortunately it does not work on my machine. The LaTeX parser does not work either - it says something like "fail to remove /tmp/tmpAFAad...". both of them worked perfectly some time before (on moinmoin 1.3.1, and possbily on 1.3.3).
In bibtex.py, yours and mine, everything works as expected until tmp = '\n'.join(pout.readlines()). the pipe does not work. tried the command and the input in a terminal console as a normal user, it worked. Wrote a small python program to simulate the behavior and run it from the command line, it also worked.
That's was the same behaviour in my standalone wiki which I use regular to test new things. There was one more thing which I haven't described. Sometimes during my trials there were bibtex processes hanging and they blocked to break down the local moin session. So I have killed all moin and bibtex processes. This could be a pretty good explanaition why afterwards the pipe works. -- ReimarBauer 2005-03-08 08:20:08
Then I tried a simple command instead of bibtex2html, for example pin, pout = popen2('cat'), it should copy the bibtex source to the output - it does when I try directly from the command line, but the output is emply when from the cgi. I guess it might be a particular problem of my linux and appache.
Problem solved! it is indeed a problem of my bibtex and latex installation. few days ago I replaced tetex package with texlive, the default path to bibtex and latex has changed to somewhere else instead of the default /usr/bin. bibtex2html in our code just could not find where bibtex is. By build symbolic links in /usr/bin to bibtex and latex executables, problem disappeared. -- JunHu 2005-03-09 01:11:54
W.r.t formatting in HlinsDatabase, I have been thinking of it - hlins takes a text file in a particular format as a -db parameter, if we want to use list items in HlinsDatabase, a tmp file has to be created to reformat the input and feed that parameter - I am no python programmer, it seems to me too much of hassle. -- JunHu 2005-03-07 23:55:04
Check out the updated version. -- JunHu 2005-03-09 21:49:27
Fine I'd looked into the macro RandomQuote.py. That's the part to separate the list items:
# this selects lines looking like a list item # !!! TODO: make multi-line quotes possible (optionally split by "----" or something) quotes = raw.splitlines() quotes = [quote.strip() for quote in quotes] quotes = [quote[2:] for quote in quotes if quote.startswith('* ')]
This seems not to be difficult to add for me. I feel better to use common rules for things which are type of list. In my eyes it is not good to have special list rules to remember. -- ReimarBauer DateTime(2005-03-09T22:35:25Z)
Agreed. Updated. -- JunHu 2005-03-10 10:29:39
While you have already implemented this I got another idea to make HlinsDatabase strict more wikilike e.g. {{{ * Howard Barringer
[http://vlsi.colorado.edu/~rbloem/ Roderick Bloem]
[http://www-2.cs.cmu.edu/~emc/ Edmund M. Clarke]
[http://www.aueb.gr/users/courcou/ Costas Courcoubetis]
[http://www.labri.fr/~couvreur Jean-Michel Couvreur]
}}} I am sorry sometimes I got ideas step by step. So here is the code of the formatter. -- ReimarBauer DateTime(2005-03-12T11:34:10Z)
def format(self, formatter): lines = self.raw.split('\n') output ='' settings = '-s ' + self.style if not self.abstract: settings = settings + ' -noabstract' if not self.keywords: settings = settings + ' -nokeywords' if self.usekeys: settings = settings + ' -use-keys' try: all = '\n'.join(lines).strip() pin, pout, perr = os.popen3('%s -c %s %s %s ' % (bibtex2html, bibtex, param, settings)) pin.write(all.encode('utf-8')) pin.flush() pin.close() output = '\n'.join(pout.readlines()) pout.close() perr.close() except IOError: output = '\n'.join(perr.readlines()) pin.close() pout.close() perr.close() self.out.write(formatter.preformatted(1)+ output+ formatter.preformatted(0)) return pagename = self.hlinsdb page = Page(self.request, pagename) raw = page.get_raw_body() if not self.request.user.may.read(pagename): raw = "" quotes = raw.splitlines() quotes = [quote.strip() for quote in quotes] quotes = [quote[2:] for quote in quotes if quote.startswith('* ')] #process the hyperlinks db if output!='': for line in quotes: link,name=line[1:-1].split(' ',1) name=name.strip() link=link.strip() url=formatter.url(1, link)+' ' +name + formatter.url(0) output = re.sub(str(name),str(url),output) # To please Springer-Verlag. output = output.replace('Springer-Verlag', '©Springer-Verlag') self.request.write(formatter.rawHTML(wikiutil.decodeUnknownInput(output)))
Thank you very much for the nice idea and the example code. it is now implemented in the latest version. -- JunHu 2005-03-17 11:00:55
I really find it very useful if I can put the bibtex data in a page, and the bibtex macro sorts the entries (according to the style parameter, etc.) upon save. How do I get this functionality? -- MuseTalk 2006-05-09 06:04:45