X-Git-Url: https://git.toastfreeware.priv.at/debian/jabref.git/blobdiff_plain/a872b88085ac404d82a5fefbcff00c0ffe43071c..b81b04b43ee7726f8f0d589129c892349a4ad24c:/src/help/CustomExports.html diff --git a/src/help/CustomExports.html b/src/help/CustomExports.html index 29d4f69..978968e 100644 --- a/src/help/CustomExports.html +++ b/src/help/CustomExports.html @@ -1,258 +1,581 @@ - - - - - -

Custom export filters

- -JabRef allows you to define and use your own export filters, in the same way as the -standard export filters are defined. An export filter is defined by one or more -layout files, which with the help of a collection of built-in formatter -routines specify the format of the exported files. Your layout files must be prepared -in a text editor outside of JabRef. - -

Adding a custom export filter

- -The only requirement for a valid export filter is the existence of a file with -the extension .layout. To add a new custom export filter, open the -dialog box Options -> Manage custom exports, and click Add new. -A new dialog box will appear, allowing you to specify a name for the export filter -(which will appear in the File -> Custom export menu of the JabRef window), -the path to the .layout file, and the preferred file extension for the export -filter (which will be the suggested extension in the file dialog when you use the -export filter). - -

Creating the export filter

- -To see examples of how export filters are made, look for the package containing the layout files -for the standard export filters on our download page. - -

Layout files

- -Let us assume that we are creating an HTML export filter. - -

While the export filter only needs to consist of a single .layout file, which in this case -could be called html.layout, you may also want to add two files called -html.begin.layout and html.end.layout. The former contains the header part -of the output, and the latter the footer part. JabRef will look for these two files whenever -the export filter is used, and if found, either of these will be copied verbatim to the output -before or after the individual entries are written. - -

Note that these files must reside in the same directory as html.layout, and must be -named by inserting .begin and .end, respectively. - -

In our example export filter, these could look like the following: - -

html.begin.layout:
-<HTML>
- <BODY> text="#275856">
-<basefont size="4" color="#2F4958" face="arial">
- -

html.end.layout:
-</BODY>
- </HTML>
- -

The file html.layout provides the default template for exporting one single entry. If -you want to use different templates for different entry types, you can do this by adding entry-specific -.layout files. These must also reside in the same directory as the main layout file, and -are named by inserting .entrytype into the name of the main layout file. The entry type name -must be in all lowercase. In our example, we might want to add a template for book entries, and this -would go into the file html.book.layout. For a PhD thesis we would add the file -html.phdthesis.layout, and so on. These files are similar to the default layout file, except that -they will only be used for entries of the matching type. Note that the default file can easily be made -general enough to cover most entry types in most export filters. - -

The layout file format

- -Layout files are created using a simple markup format where commands are identified by a preceding -backslash. All text not identified as part of a command will be copied verbatim to the output file. - -

Field commands

- -

An arbitrary word preceded by a backslash, e.g. \author, \editor, -\title or \year, will be interpreted as a reference to the corresponding field, -which will be copied directly to the output. - -

Field formatters

+ + + + + + + +

Custom export filters

+ +

JabRef allows you to define and + use your own export filters, in the same way as the standard + export filters are defined. An export filter is defined by one + or more layout files, which with the help of a + collection of built-in formatter routines specify the format of + the exported files. Your layout files must be prepared in a + text editor outside of JabRef.

+ +

Adding a custom export filter

+ +

The only requirement for + a valid export filter is the existence of a file with the + extension .layout. To add a new custom export filter, + open the dialog box Options -> Manage custom exports, + and click Add new. A new dialog box will appear, + allowing you to specify a name for the export filter (which + will appear as one of the choices in the File type dropdown + menu of the file dialog when you use the File -> + Export menu choice in the JabRef window), the path to the + .layout file, and the preferred file extension for the + export filter (which will be the suggested extension in the + file dialog when you use the export filter).

+ +

Creating the export filter

+ +

To see examples of how export filters are made, look for + the package containing the layout files for the standard + export filters on our download page.

+ +

Layout files

+ +

Let us assume that we are creating an HTML export filter. + While the export filter only needs to consist of a single + .layout file, which in this case could be called + html.layout, you may also want to add two files called + html.begin.layout and html.end.layout. The former + contains the header part of the output, and the latter the + footer part. JabRef will look for these two files whenever the + export filter is used, and if found, either of these will be + copied verbatim to the output before or after the individual + entries are written.

+ +

Note that these files must reside in the same directory as + html.layout, and must be named by inserting + .begin and .end, respectively. + In our example export filter, these could look like the + following:

+ +

html.begin.layout:
+ <!DOCTYPE html>
<html>
<body style="color:#275856; font-family: Arial, sans-serif;">
+

+ +

html.end.layout:
+ </body>
</html>

+ +

The file html.layout provides the default + template for exporting one single entry. If you want to use + different templates for different entry types, you can do this + by adding entry-specific .layout files. These must also + reside in the same directory as the main layout file, and are + named by inserting .entrytype into the name of the main + layout file. The entry type name must be in all lowercase. In + our example, we might want to add a template for book entries, + and this would go into the file html.book.layout. For a + PhD thesis we would add the file html.phdthesis.layout, + and so on. These files are similar to the default layout file, + except that they will only be used for entries of the matching + type. Note that the default file can easily be made general + enough to cover most entry types in most export filters.

+ +

The layout file format

+ +

Layout files are created using a + simple markup format where commands are identified by a + preceding backslash. All text not identified as part of a + command will be copied verbatim to the output file.

+ +

Field commands

+ +

An arbitrary word preceded by a backslash, e.g. + \author, \editor, \title + or \year, will be interpreted as a reference to + the corresponding field, which will be copied directly to the + output.

+ +

Field formatters

+ +

Often there will be a need for some preprocessing of the + field contents before output. This is done using a field + formatter - a java class containing a single method that + manipulates the contents of a field.

+ +

A formatter is used by inserting the \format + command followed by the formatter name in square braces, and + the field command in curly braces, e.g.:

+ +

\format[ToLowerCase]{\author}

+ +

You can also specify multiple formatters separated by + commas. These will be called sequentially, from left to right, + e.g.

+ +

\format[ToLowerCase,HTMLChars]{\author}

+ +

will cause the formatter ToLowerCase to be called + first, and then HTMLChars will be called to format the + result. You can list an arbitrary number of formatters in this + way.

+ +

The argument to the formatters, withing the curly braces, + does not have to be a field command. Instead, you can insert + normal text, which will then be passed to the formatters + instead of the contents of any field. This can be useful for + some fomatters, e.g. the CurrentDate formatter (described + below).

+ +

Some formatters take an extra argument, given in parentheses + immediately after the formatter name. The argument can be enclosed + in quotes, which is necessary if it includes the parenthesis characters. + For instance, \format[Replace("\s,_")]{\journal} calls + the Replace formatter with the argument \s,_ (which results + in the "journal" field after replacing all whitespace by underscores). +

+ +

See below for a list of built-in export formatters.

+ +

Conditional output

+ +

Some static output might only make + sense if a specific field is set. For instance, say we want to + follow the editor names with the text (Ed.). This + can be done with the following text:

+ +

\format[HTMLChars,AuthorFirstFirst]{\editor} + (Ed.)

+ +

However, if the editor field has not been set - + it might not even make sense for the entry being exported - the + (Ed.) would be left hanging. This can be prevented + by instead using the \begin and \end + commands:

+ +

\begin{editor}
+ \format[HTMLChars,AuthorFirstFirst]{\editor} (Ed.)
+ \end{editor}

+ +

The \begin and \end commands make + sure the text in between is printed if and only if the field + referred in the curly braces is defined for the entry being + exported.

+ +

A conditional block can also be dependent on more than one field, and the content is only printed when simple boolean conditions are satisfied. Two boolean operator are provided:

+ +

To output text only if both year and month are set, use a block like the following:

\begin{year&&month}Month: \format[HTMLChars]{\month}\end{year&&month}

which will print "Month: " plus the contents of the month field, but only if also the year field is defined.

+ +

Note: Use of the \begin and + \end commands is a key to creating layout files + that work well with a variety of entry types.

+ +

Grouped output

+ +

If you wish to separate your entries + into groups based on a certain field, use the grouped output + commands. Grouped output is very similar to conditional output, + except that the text in between is printed only if the field + referred in the curly braces has changed value.

+ +

For example, let's assume I wish to group by keyword. Before + exporting the file, make sure you have sorted your entries + based on keyword. Now use the following commands to group by + keyword:

+ +

\begingroup{keywords}New Category: + \format[HTMLChars]{\keywords}
+ \endgroup{keywords}

+ +

Sharing your work

+ +

With external layout files, it's + fairly simple to share custom export formats between users. If + you write an export filter for a format not supported by + JabRef, or an improvement over an existing one, we encourage + you to post your work on our SourceForge.net page. The same + goes for formatter classes that you write. We'd be happy to + distribute a collection of submitted layout files, or to add to + the selection of standard export filters and formatters.

+ +

Starting with JabRef 2.4 you can also package your + ExportFormat or LayoutFormatter as a plug-in. If you do so, + you can provide a single zip-file to other user to make use + of your ExportFormat. For an example download the JabRef + source release and have a look at the directory + src/plugins/. Don't hesitate to stop by the + forums on Sourceforge, since we don't have extensive documentation, yet.

+ + +

Built-in export formatters

+ +

JabRef provides the following set of formatters:

+ + + +

The Authors formatter

+ +

To accommodate for the numerous citation styles, the Authors formatter allows flexible control over the layout of the author list. The formatter takes a comma-separated list of options, by which the default values can be overridden. The following option/value pairs are currently available, where the default values are given in curly brackets.

+
+
AuthorSort = [ {FirstFirst} | LastFirst | LastFirstFirstFirst ]
+
specifies the order in which the author names are formatted. + +
+ +
AuthorAbbr = [ FullName | LastName | {Initials} | InitialsNoSpace | FirstInitial | MiddleInitial ]
+
specifies how the author names are abbreviated. + +
+ +
AuthorPunc = [ {FullPunc} | NoPunc | NoComma | NoPeriod ]
+
specifies the punctuation used in the author list when AuthorAbbr is used + +
+ +
AuthorSep = [ {Comma} | And | Colon | Semicolon | Sep=<string> ]
+
specifies the separator to be used between authors. Any separator can be specified, with the Sep=<string> option. Note that appropriate spaces need to be added around string.
+ +
AuthorLastSep = [ Comma | {And} | Colon | Semicolon | Amp | Oxford | LastSep=<string> ]
+
specifies the last separator in the author list. Any separator can be specified, with the LastSep=<string> option. Note that appropriate spaces need to be added around string.
+ +
AuthorNumber = [ {inf} | <integer> ]
+
specifies the number of authors that are printed. If the number of authors exceeds the maximum specified, the authorlist is replaced by the first author (or any number specified by AuthorNumberEtAl), followed by EtAlString.
+ +
AuthorNumberEtAl = [ {1} | <integer> ]
+
specifies the number of authors that are printed if the total number of authors exceeds AuthorNumber. +This argument can only be given after AuthorNumber has already been given.
+ +
EtAlString = [ { et al.} | EtAl=<string> ]
+
specifies the string used to replace multiple authors. Any string can be given, using EtAl=<string>
+ +
+ +

If an option is unspecified, the default value (shown in curly brackets above) is used. Therefore, only layout options that differ from the defaults need to be specified. The order in which the options are defined is (mostly) irrelevant. So, for example,

+

\format[Authors(Initials,Oxford)]{\author}

+

is equivalent to

+

\format[Authors(Oxford,Initials)]{\author}

+

As mentioned, the order in which the options are specified is irrelevant. There is one possibility for ambiguity, and that is if both AuthorSep and AuthorLastSep are given. In that case, the first applicable value encountered would be for AuthorSep, and the second for AuthorLastSep. It is good practise to specify both when changing the default, to avoid ambiguity.

+ +

Examples

+

Given the following authors, "Joe James Doe and Mary Jane and Bruce Bar and Arthur Kay" ,the Authors formatter will give the following results:

+
+
Authors(), or equivalently, Authors(FirstFirst,Initials,FullPunc,Comma,And,inf,EtAl= et al.)
+
J. J. Doe, M. Jane, B. Bar and A. Kay
+ +
Authors(LastFirstFirstFirst,MiddleInitial,Semicolon)
+
Doe, Joe J.; Mary Jane; Bruce Bar and Arthur Kay
+ +
Authors(LastFirst,InitialsNoSpace,NoPunc,Oxford)
+
Doe JJ, Jane M, Bar B, and Kay A
+ +
Authors(2,EtAl= and others)
+
J. J. Doe and others
+
+

Most commonly available citation formats should be possible with this formatter. For even more advanced options, consider using the Custom Formatters detailed below.

+ +

The WrapFileLinks formatter

+ +

This formatter iterates over all file links, or all file links of a specified type, outputting a format string given as the first argument. The format string can contain a number of escape sequences indicating file link information to be inserted into the string.

+

This formatter can take an optional second argument specifying the name of a file type. If specified, the iteration will only include those files with a file type matching the given name (case-insensitively). If specified as an empty argument, all file links will be included.

+

After the second argument, pairs of additional arguments can be added in order to specify regular expression replacements to be done upon the inserted link information before insertion into the output string. A non-paired argument will be ignored. In order to specify replacements without filtering on file types, use an empty second argument.

+

The escape sequences for embedding information are as follows:

+ +

For instance, an entry could contain a file link to the file "/home/john/report.pdf" of the "PDF" type with description "John's final report". Using the WrapFileLinks formatter with the following argument:

+

\format[WrapFileLinks(\i. \d (\p))]{\file}

+

would give the following output:

+
+    1. John's final report (/home/john/report.pdf)
+
+
+

If the entry contained a second file link to the file "/home/john/draft.txt" of the "Text file" type with description 'An early "draft"', the output would be as follows:

+
+    1. John's final report (/home/john/report.pdf)
+    2. An early "draft" (/home/john/draft.txt)
+
+
+

If the formatter was called with a second argument, the list would be filtered. For instance:

+

\format[WrapFileLinks(\i. \d (\p),,text file)]{\file}

+

would show only the text file:

+
+    1. An early "draft" (/home/john/draft.txt)
+
+
+

If we wanted this output to be part of an XML styled output, the quotes in the file description could cause problems. Adding two additional arguments to translate the quotes into XML characters solves this:

+

\format[WrapFileLinks(\i. \d (\p),,text file,",&quot;)]{\file}

+

would give the following output:

+
+    1. An early "draft" (/home/john/draft.txt)
+
+
+

Additional pairs of replacements could be added.

+ + +

Custom formatters

+

If none of the available formatters can do what you want to + achieve, you can add your own by implementing the + net.sf.jabref.export.layout.LayoutFormatter + interface. If you insert your class into the + net.sf.jabref.export.layout.format package, you + can call the formatter by its class name only, like with the + standard formatters. Otherwise, you must call the formatter by + its fully qualified name (including package name). In any case, + the formatter must be in your classpath when running + JabRef.

-

Often there will be a need for some preprocessing of the field contents before output. This is - done using a field formatter - a java class containing a single method that manipulates the - contents of a field. -

A formatter is used by inserting the \format command followed by the formatter name in - square braces, and the field command in curly braces, e.g.: +

Using Custom Name Formatters

-

\format[ToLowerCase]{\author} +

From JabRef 2.2, it is possible to define custom name + formatters using the bibtex-sty-file syntax. This allows + ultimate flexibility, but is a cumbersome to write

-

You can also specify multiple formatters separated by commas. These will be called sequentially, - from left to right, e.g. +

You can define your own formatter in the preference tab + "Name Formatter" using the following format and then use it + with the name given to it as any other formatter

+ <case1>@<range11>@<format>@<range12>@<format>@<range13>...@@
-

\format[ToLowerCase,HTMLChars]{\author} + <case2>@<range21>@... and so on. -

will cause the formatter ToLowerCase to be called first, and then HTMLChars will be - called to format the result. You can list an arbitrary number of formatters in this way. +

This format first splits the task to format a list of author + into cases depending on how many authors there are (this is + since some formats differ depending on how many authors there + are). Each individual case is separated by @@ and contains + instructions on how to format each author in the case. These + instructions are separated by a @.

-

The argument to the formatters, withing the curly braces, does not have to be a field command. Instead, -you can insert normal text, which will then be passed to the formatters instead of the contents of any field. -This can be useful for some fomatters, e.g. the CurrentDate formatter (described below). +

Cases are identified using integers (1, 2, 3, etc.) or the + character * (matches any number of authors) and will tell the + formatter to apply the following instructions if there are a + number of less or equal of authors given.

-

JabRef provides the following set of formatters, some of which depend on the others: -

+

For instance with an authorlist of "Joe Doe and Mary Jane + and Bruce Bar and Arthur Kay":

-

If none of the available formatters can do what you want to achieve, you can add your own by implementing - the net.sf.jabref.export.layout.LayoutFormatter interface. If you insert your class - into the net.sf.jabref.export.layout.format package, you can call the formatter by its - class name only, like with the standard formatters. Otherwise, you must call the formatter by its fully - qualified name (including package name). In any case, the formatter must be in your classpath when running - JabRef.

- - -

Using Custom Name Formatters

- -

With JabRef 2.2 it is now possible to define custom name formatters using the bibtex-sty-file syntax. -This allows ultimate flexibility, but is a cumbersome to write

-

You can define your own formatter in the preference tab "Name Formatter" using the following format -and then use it with the name given to it as any other name formatter

- - - <case1>@<range11>@<format>@<range12>@<format>@<range13>...@@
- <case2>@<range21>@... and so on. -
- -

This format first splits the task to format a list of author into cases depending on -how many authors there are (this is since some formats differ depending on how many authors there are). -Each individual case is separated by @@ and contains instructions on how to format each author in the case. -These instructions are separated by a @.

-

Cases are identified using integers (1,2,3,etc.) or the character * (matches any number of authors) and will tell -the formatter to apply the following instructions if there are a number of less or equal of authors given. -

-

- Ranges are either <integer>..<integer>, <integer> or the character * using a 1 based index for indexing - authors from the given list of authors. Integer indexes can be negative to denote them to start from - the end of the list where -1 is the last author. -

- -

For instance with an authorlist of "Joe Doe and Mary Jane and Bruce Bar and Arthur Kay":

- + -

Large example:

-
-

To turn:

-

"Joe Doe and Mary Jane and Bruce Bar and Arthur Kay"

-

into

-

"Doe, J., Jane, M., Bar, B. and Kay, A."

-

you would use

-

1@*@{ll}, {f}.@@2@1@{ll}, {f}.@2@ and {ll}, {f}.@@*@1..-3@{ll}, {f}., @-2@{ll}, {f}.@-1@ and {ll}, {f}.

-
-

If somebody would like to write a better tutorial about this: Write a mail to one of the JabRef mailinglists!

+

The <format>-strings use the Bibtex + formatter format:

-

Conditional output

+

The four letters v, f, l, j indicate the name parts von, + first, last, jr which are used within curly braces. A single + letter v, f, l, j indicates that the name should be + abbreviated. If one of these letters or letter pairs is + encountered JabRef will output all the respective names + (possibly abbreviated), but the whole expression in curly + braces is only printed if the name part exists.

-Some static output might only make sense if a specific field is set. For instance, say we want to follow -the editor names with the text (Ed.). This can be done with the following text: +

For instance if the format is "{ll} {vv {von Part}} {ff}" + and the names are "Mary Kay and John von Neumann", then JabRef + will output "Kay Mary" (with two space between last and first) + and "Neuman von von Part John".

-

\format[HTMLChars,AuthorFirstFirst]{\editor} (Ed.) +

I give two examples but would rather point you to the bibtex + documentation.

-

However, if the editor field has not been set - it might not even make sense for the entry - being exported - the (Ed.) would be left hanging. This can be prevented by instead using the -\begin and \end commands: +

Small example: "{ll}, {f.}" will turn + "Joe Doe" into "Doe, J."

-

\begin{editor}
\format[HTMLChars,AuthorFirstFirst]{\editor} (Ed.) -
\end{editor}
+

Large example:

-

The \begin and \end commands make sure the text in between is printed if and -only if the field referred in the curly braces is defined for the ently being exported. +

+

To turn:

-

Note: Use of the \begin and \end commands is a key to creating - layout files that work well with a variety of entry types. +

"Joe Doe and Mary Jane and Bruce Bar and Arthur + Kay"

-

Grouped output

+

into

-If you wish to separate your entries into groups based on a certain field, use the grouped output commands. -Grouped output is very similar to conditional output, except that the text in between is printed only if the -field referred in the curly braces has changed value. +

"Doe, J., Jane, M., Bar, B. and Kay, + A."

-

For example, let's assume I wish to group by keyword. Before exporting the file, make sure you have sorted -your entries based on keyword. Now use the following commands to group by keyword: +

you would use

-

\begingroup{keywords}New Category: \format[HTMLChars]{\keywords} -
\endgroup{keywords}
+

1@*@{ll}, {f}.@@2@1@{ll}, {f}.@2@ and {ll}, + {f}.@@*@1..-3@{ll}, {f}., @-2@{ll}, {f}.@-1@ and {ll}, + {f}.

+
-

Sharing your work

+

If somebody would like to write a better tutorial about + this: Write a mail to one of the JabRef mailinglists!

-With external layout files, it's fairly simple to share custom export formats between users. -If you write an export filter for a format not supported by JabRef, or an improvement over an -existing one, we encourage you to post your work on our SourceForge.net page. The same goes for -formatter classes that you write. We'd be happy to distribute a collection of submitted -layout files, or to add to the selection of standard export filters and formatters. - + +