{"id":17665767,"url":"https://github.com/mkoeppe/cl-bibtex","last_synced_at":"2026-01-08T06:31:33.268Z","repository":{"id":31945897,"uuid":"35515628","full_name":"mkoeppe/cl-bibtex","owner":"mkoeppe","description":"A compatible re-implementation of the BibTeX program in Common Lisp, with a BST-to-CL compiler. By Matthias Köppe","archived":false,"fork":false,"pushed_at":"2018-12-05T07:47:42.000Z","size":221,"stargazers_count":26,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T00:02:34.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkoeppe.png","metadata":{"files":{"readme":"README","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-12T22:25:56.000Z","updated_at":"2024-05-14T18:48:02.000Z","dependencies_parsed_at":"2022-08-24T10:30:41.436Z","dependency_job_id":null,"html_url":"https://github.com/mkoeppe/cl-bibtex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkoeppe%2Fcl-bibtex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkoeppe%2Fcl-bibtex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkoeppe%2Fcl-bibtex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkoeppe%2Fcl-bibtex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkoeppe","download_url":"https://codeload.github.com/mkoeppe/cl-bibtex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246317688,"owners_count":20758008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-23T21:07:37.123Z","updated_at":"2026-01-08T06:31:33.221Z","avatar_url":"https://github.com/mkoeppe.png","language":"Common Lisp","funding_links":[],"categories":["Online editors ##"],"sub_categories":["Third-party APIs"],"readme":"A BibTeX system in Common Lisp\n******************************\n\nCL-BibTeX is a replacement for the BibTeX program, written in\nCommon Lisp.  The aim is to enable the user to format bibliographic\nentries using Common Lisp programs, rather than using the stack\nlanguage of BibTeX style files.  \n\nIt is released under the terms of version 2.1 of the GNU Lesser\nGeneral Public License as published by the Free Software Foundation\n(see file COPYING) or any later version, as clarified by the preamble\nfound in COPYING-preamble.txt.\n\n(Note: run-lisp is included from CLOCC and has its own license.)\n\nDevelopment now takes place on GitHub at\n\n    https://github.com/mkoeppe/cl-bibtex\n\nA project home page is at\n\n    http://www.nongnu.org/cl-bibtex/\n\n(The old development pages at\nhttp://savannah.nongnu.org/projects/cl-bibtex/ are obsolete.)\n\nThere is a mailing list `cl-bibtex-users@nongnu.org'.\nYou can subscribe to the list at \n\n    http://lists.nongnu.org/mailman/listinfo/cl-bibtex-users\n\n\nReasons\n=======\n\nA powerful tool is needed for dealing with citations in scientific\ndocuments.  BibTeX is good for formatting bibliographies, but\ncustomizing the format is a pain because it requires writing/changing\na program in BAFLL (BibTeX Anonymous Forth-Like Language -- \nDrew McDermott in comp.lang.lisp), which looks like this:\n\nFUNCTION {tie.or.space.connect}\n{ duplicate$ text.length$ #3 \u003c\n    { \"~\" }\n    { \" \" }\n  if$\n  swap$ * *\n}\n\nOther citation-related processing like producing a list of authors and\ncitation indices is usually done with a combination of BibTeX, TeX\nmacros, and ad-hoc scripting with Perl or AWK.\n\nThe new CL-BibTeX system aims to replace all this.\n\n\nStatus\n======\n\nCL-BibTeX is a compatible and stable re-implementation of the BibTeX\nprogram, which was written by Oren Patashnik in the WEB language.\n\nIt consists of the following components:\n\n * A reader for BibTeX style files (.bst),\n * a reader and a writer for bibliography databases (.bib),\n * a reader for .aux files,\n * an implementation of BibTeX's built-in functions (like for parsing and\n   formatting names, etc.),\n * an interpreter for the stack language of BibTeX style files.\n\nThus CL-BibTeX allows to both use existing BibTeX style files,\nand to write new BibTeX styles in Common Lisp.  \n\nIn addition to this, CL-BibTeX contains:\n\n * A compiler that transforms BibTeX style files into comprehensible\n   Common Lisp programs (using type analysis).\n\n   The resulting Common Lisp programs can serve as a starting point\n   for the customization of the style.\n\nFuture directions of CL-BibTeX's development can be found in the TODO\nfile.\n\n\nWhere to start\n==============\n\nCompile and load all Lisp files, using ASDF or bibtex.system.\n\nThe function BIBTEX is like the bibtex program.  Pass the file name\nSTEM; BIBTEX will read STEM.aux, interpret a BST file, and write\nSTEM.bbl:\n\n\t(bibtex-compiler:bibtex \"example\")\n\nIn fact, when the STEM.aux file requests a bibliography style, BIBTEX\nfirst looks whether a Lisp function that implements the style has been\ndefined using DEFINE-BIBTEX-STYLE.  Otherwise, it tries to find (using\nkpathsearch) and load a Lisp file named \"STYLE.lbst\"; it is supposed\nto define the style using DEFINE-BIBTEX-STYLE.  Finally, BIBTEX tries\nto find \"STYLE.bst\" and interpret it.\n\nA BibTeX style implemented in Lisp is supposed to read all\nbibliography files in *BIB-FILES* and to write the formatted\nbibliography to the stream *BBL-OUTPUT*.  The package BIBTEX-RUNTIME\ncontains useful routines for reading AUX files, formatting names, etc.\nAn important function is READ-ALL-BIB-FILES-AND-COMPUTE-BIB-ENTRIES.  \n\nYou can invoke the BST-to-Common-Lisp compiler with the function\nCOMPILE-BST-FILE:\n\n\t(bibtex-compiler:compile-bst-file (kpathsea:find-file \"amsabbrv.bst\")\n\t\t\t\t\t  \"amsabbrv.lbst\")\n\nThe resulting Lisp file is a readable Common Lisp version of the BST\nfile, which can be run on the AUX file to produce a BBL file, without\nusing the BST interpreter:\n\n        (compile-file \"amsabbrv.lbst\")\n        (load \"amsabbrv.lbst\")            ; calls DEFINE-BIBTEX-STYLE\n\n\t(bibtex-compiler:bibtex \"example\")\t    ; now uses the Lisp style\n\nThere is also a little shell script \"bibtex\" for invoking CL-BIBTEX\nfrom the shell; it uses the \"run-lisp\" script from CLOCC.\n\n\nRestrictions of the compiler\n============================\n\nThe BST-\u003eCL compiler works by analyzing the type of the wizard-defined\nfunctions (i.e., those defined by a FUNCTION command in the BST\nfile).  The compiler tries to find out how many \"literals\" (values) a\nfunction pops from the stack and how many it pushes and determines\ntheir types (BOOLEAN, INTEGER, STRING).\n\n* If a wizard-defined function tries to pop a function literal that it\n  hasn't pushed, or leaves a function literal on the stack, you lose.\n  (In other words, you can't define higher-order BST functions.)\n\n* The two branches of an IF$ function must deliver the same net number\n  of values.  (As a special exception, the type of IF$ within a WHILE$\n  body which occurs in the FORMAT.NAMES function of the standard\n  styles is also supported.  This is reported with a warning message.)\n\n\nOn the compilation of a language that no-one can read or write\n==============================================================\n\nThe language of BibTeX style files (BAFLL) is expected to be read or\nwritten by \"wizards\" only.  (This is how the original BibTeX calls the\nauthors of BibTeX style files.)  In fact, when casual users try to\ncustomize a BibTeX style file, they often come up with slightly broken\nstyles that appear to work but which fail in corner cases.  The reason\nis that programs written in BAFLL can hardly be read, written, or even\ndebugged. \n\nThis causes an extra difficulty for the compiler, because broken\ncorner cases tend to misbehave on the stack, rendering the function\nunanalyzable, hence uncompilable.  The compiler now contains a\nheuristic that tries to fix these situations, but it may fail.  In\nthis case, you should try to understand the error messages, fix the\nBibTeX style file accordingly, and try compiling it again.\n\n\nImplementation dependencies\n===========================\n\nIt does not run on some 0.7.? version of SBCL because it does not like\n(COPY-READTABLE NIL).  SBCL 0.7.9 seems to be fine.\n\nI noticed that CMUCL 3.0.8 18c+ does not like (PEEK-CHAR T STREAM NIL\n#\\Space); it won't skip over whitespace when the EOF character is\nwhitespace?  (I don't use this any more in CL-BibTeX.)\n\nCLISP 2.30:\n1. When I invoke COMPILE-BST-FILE, CLISP says \"Lisp stack\n   overflow. RESET\"; this seems to be caused by the pprint-dispatch\n   function for DEFINE-BIBTEX-STYLE.\n2. The format directive ~\u003c...~:\u003e  (logical block) does not seem to work\n   properly.\n(I have used reader conditionalization to make CL-BibTeX work with CLISP.)\n\n\n\nHave fun!\n\n -- Matthias Koeppe \u003cmkoeppe@math.ucdavis.edu\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkoeppe%2Fcl-bibtex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkoeppe%2Fcl-bibtex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkoeppe%2Fcl-bibtex/lists"}