1bibtex(n)                           bibtex                           bibtex(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       bibtex - Parse bibtex files
9

SYNOPSIS

11       package require Tcl  8.4
12
13       package require bibtex  ?0.5?
14
15       ::bibtex::parse ?options? ?text?
16
17       ::bibtex::parse text
18
19       ::bibtex::parse ?-command cmd? -channel chan
20
21       ::bibtex::parse  ?-recordcommand    recordcmd? ?-preamblecommand pream‐
22       blecmd?  ?-stringcommand    stringcmd?  ?-commentcommand    commentcmd?
23       ?-progresscommand progresscmd? (text | -channel chan)
24
25       ::bibtex::wait token
26
27       ::bibtex::destroy token
28
29       ::bibtex::addStrings token stringdict
30
31_________________________________________________________________
32

DESCRIPTION

34       This  package  provides  commands  for the parsing of bibliographies in
35       BibTeX format.
36
37       ::bibtex::parse ?options? ?text?
38              This is the general form of the command for parsing a bibliogra‐
39              phy.  Depending  on the options used to invoke it it will either
40              return a token for the parser, or  the  parsed  entries  of  the
41              input  bibliography.  Instead  of  performing an immediate parse
42              returning a predefined format the  command  can  also  enter  an
43              event-based  parsing  style  where  all  relevant entries in the
44              input are reported through callback commands, in  the  style  of
45              SAX.
46
47       ::bibtex::parse text
48              In  this form the command will assume that the specified text is
49              a bibliography in BibTeX format, parse it,  and  then  return  a
50              list  containing  one element per record found in the bibliogra‐
51              phy. Note that comments,  string  definitions,  preambles,  etc.
52              will  not  show  up  in the result.  Each element will be a list
53              containing record type, bibliography key  and  record  data,  in
54              this  order.  The record data will be a dictionary, its keys the
55              keys of the record, with the associated values.
56
57       ::bibtex::parse ?-command cmd? -channel chan
58              In this form the command will reads the  bibliography  from  the
59              specified Tcl channel chan and then returns the same data struc‐
60              ture as described above.
61
62              If however the option -command is specified the result will be a
63              handle  for the parser instead and all processing will be incre‐
64              mental and happen in the background. When  the  input  has  been
65              exhausted  the  callback  cmd will be invoked with the result of
66              the parse. The exact definition for the callback is
67
68
69              cmd token parseresult
70                     The parse result will have the structure explained above,
71                     for the simpler forms of the parser.
72
73       Note  that the parser will not close the channel after it has exhausted
74       it. This is still the responsibility of the user of the parser.
75
76       ::bibtex::parse ?-recordcommand   recordcmd?  ?-preamblecommand  pream‐
77       blecmd?   ?-stringcommand    stringcmd?  ?-commentcommand   commentcmd?
78       ?-progresscommand progresscmd? (text | -channel chan)
79              This is the most low-level form for  the  parser.  The  returned
80              result  will  be  a  handle for the parser. During processing it
81              will invoke the invoke the specified callback commands for  each
82              type of data found in the bibliography.
83
84              The  processing will be incremental and happen in the background
85              if, and only if a Tcl channel chan is specified. For a text  the
86              processing  will  happen  immediately  and all callbacks will be
87              invoked before the command itself returns.
88
89              The callbacks, i.e. *cmd, are all command prefixes and  will  be
90              invoked  with additional arguments appended to them. The meaning
91              of the arguments depends on the callback and is explained below.
92              The  first  argument  will  however  always be the handle of the
93              parser invoking the callback.
94
95              recordcmd token type key recorddict
96                     This callback is invoked whenever the  parser  detects  a
97                     bibliography  record  in the input. Its arguments are the
98                     record type, the bibliography key for the record,  and  a
99                     dictionary  containing the keys and values describing the
100                     record. Any  string  macros  known  to  the  parser  have
101                     already been expanded.
102
103              preamblecmd token preambletext
104                     This  callback  is invoked whenever the parser detects an
105                     @preamble block in the input. The only  additional  argu‐
106                     ment  is the text found in the preamble block. By default
107                     such entries are ignored.
108
109              stringcmd token stringdict
110                     This callback is invoked whenever the parser  detects  an
111                     @string-based macro definition in the input. The argument
112                     is a dictionary with the macro names as  keys  and  their
113                     replacement  strings  as  values. By default such defini‐
114                     tions are added to the parser state  for  use  in  future
115                     bibliography records.
116
117              commentcmd token commenttext
118                     This  callback  is  invoked whenever the parser detects a
119                     comment in the input. The only additional argument is the
120                     comment text. By default such entries are ignored.
121
122              progresscmd token percent
123                     This  callback  is  invoked during processing to tell the
124                     user about the progress which has been made. Its argument
125                     is  the  percentage  of data processed, as integer number
126                     between 0 and 100.  In the case of incremental processing
127                     the  perecentage will always be -1 as the total number of
128                     entries is not known beforehand.
129
130
131       ::bibtex::wait token
132              This command waits for the parser represented by  the  token  to
133              complete  and  then  returns.  The  returned result is the empty
134              string.
135
136       ::bibtex::destroy token
137              This command cleans up all internal state  associated  with  the
138              parser  represented  by the handle token, effectively destroying
139              it. This command can be called from within the parser  callbacks
140              to terminate processing.
141
142       ::bibtex::addStrings token stringdict
143              This command adds the macro definitions stored in the dictionary
144              stringdict to the parser represented by the handle token.
145
146              The dictionary keys are the macro names  and  the  values  their
147              replacement  strings. This command has the correct signature for
148              use as a -stringcommand callback in an invokation of the command
149              ::bibtex::parse.
150

BUGS, IDEAS, FEEDBACK

152       This  document,  and the package it describes, will undoubtedly contain
153       bugs and other problems.  Please report such in the category bibtex  of
154       the          Tcllib         SF         Trackers         [http://source
155       forge.net/tracker/?group_id=12883].  Please also report any  ideas  for
156       enhancements you may have for either package and/or documentation.
157

KEYWORDS

159       bibliography, bibtex, parsing, text processing
160
162       Copyright (c) 2005 for documentation, Andreas Kupries <andreas_kupries@users.sourceforge.net>
163
164
165
166
167bibtex                                0.5                            bibtex(n)
Impressum