Giter Club home page Giter Club logo

bibtex-js's People

Contributors

dependabot[bot] avatar digitalheir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bibtex-js's Issues

Compute `sort.key$` for entries

Also see #3

When sorting, BibTEX computes a string, named
sort.key$, for each entry. The sort.key$ string is an (often long) string defining the order
in which entries will be sorted. To avoid any ambiguity, sort.key$ should only contain alphanumeric
characters. Classical non-alphanumeric characters23, except special characters, will
be removed by a BibTEX function named purify$. For special characters, purify$ removes
spaces and LATEX commands (strings beginning with a backslash), even those placed between
brace pairs. Everything else is left unmodified. For instance, t^ete, t{^e}te and t{^{e}}te
are transformed into tete, while tête gives tête; Bib{\TeX} gives Bib and Bib\TeX becomes
BibTeX. There are thirteen LATEX commands that won’t follow the above rules: \OE, \ae, \AE,
\aa, \AA, \o, \O, \l, \L, \ss. Those commands correspond to ı, , œ, Œ, æ, Æ, å, Å, ø, Ø, ł, Ł,
ß, and purify$ transforms them (if they are in a special character, in i, j, oe, OE, ae, AE, aa,
AA, o, O, l, L, ss, respectively.

http://tug.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf

Parse titles

Needs helper functions, see #1, #2, #3.

We’ll need several definitions before going further. The brace depth of an item is the number of
braces surrounding it. This is not a very formal definition, but for instance, in the title above, \LaTeX
has brace depth 2, the C has brace depth 1, and everything else has depth 0. A special character is a
part of a field starting with a left brace being at brace depth 0 immediately followed with a backslash,
and ending with the corresponding right brace. For instance, in the above example, there is no special
character, since \LaTeX is at depth 2. It should be noticed that anything in a special character is
considered as being at brace depth 0, even if it is placed between another pair of braces.
That’s it for the definitions. Generally speaking, several modifications can be applied to the title
by the bibliography style:
• first of all, the title might be used for sorting. When sorting, BibTEX computes a string, named
sort.key$, for each entry. The sort.key$ string is an (often long) string defining the order
in which entries will be sorted. To avoid any ambiguity, sort.key$ should only contain alphanumeric
characters. Classical non-alphanumeric characters23, except special characters, will
be removed by a BibTEX function named purify$. For special characters, purify$ removes
spaces and LATEX commands (strings beginning with a backslash), even those placed between
brace pairs. Everything else is left unmodified. For instance, t^ete, t{^e}te and t{^{e}}te
are transformed into tete, while tête gives tête; Bib{\TeX} gives Bib and Bib\TeX becomes
BibTeX. There are thirteen LATEX commands that won’t follow the above rules: \OE, \ae, \AE,
\aa, \AA, \o, \O, \l, \L, \ss. Those commands correspond to ı, , œ, Œ, æ, Æ, å, Å, ø, Ø, ł, Ł,
ß, and purify$ transforms them (if they are in a special character, in i, j, oe, OE, ae, AE, aa,
AA, o, O, l, L, ss, respectively.
• the second transformation applied to a title is to be turned to lower case (except the first character).
The function named change.case$ does this job. But it only applies to letters that are
a brace depth 0, except within a special character. In a special character, brace depth is always
0, and letters are switched to lower case, except LATEX commands, that are left unmodified.

http://tug.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf

Usage Help

Hello,
I would like to try out the library but have two concerns.

  1. How do I use it in a website? I tried <script src="downloadedFile.js"></script> but I do not know how (under which name) to access the functions then. Can it be used with requirejs?
  2. Could you add example code showing how to iterate over all entries of a file and all fields of an entry, please? (order not important for now)

Cannot compile typescript

bibtex-js$ tsc src/index.ts 
src/bibfile/bib-entry/BibEntry.ts(68,34): error TS2322: Type 'FieldValue' is not assignable to type 'Authors'.
  Type 'number' is not assignable to type 'Authors'.
src/bibfile/bib-entry/BibStringEntry.ts(107,16): error TS2339: Property 'assign' does not exist on type 'ObjectConstructor'.
src/lexer/Lexer.ts(112,35): error TS2339: Property 'parseInt' does not exist on type 'NumberConstructor'.
src/lexer/Lexer.ts(113,27): error TS2339: Property 'isFinite' does not exist on type 'NumberConstructor'.

bibtex-js$ tsc --version
Version 2.6.1

PS: The npm installed precompiled version seems to work so far, however I wanted to modify it, since I do not want string fields to resolved. I want to read a bibfile, check some things and write it again, with cleaned up formatting to my chosing. I tested "bibclean" and "biber output_format bibtex" which both do not suffide, so I wanted to do my own and looked around for a .js library that can read bibtex files, bevor i have to write yet another parser.

Implement `change.case$`

the second transformation applied to a title is to be turned to lower case (except the first character).
The function named change.case$ does this job. But it only applies to letters that are
a brace depth 0, except within a special character. In a special character, brace depth is always
0, and letters are switched to lower case, except LATEX commands, that are left unmodified.

http://tug.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf

Parse authors

The first point to notice is that two authors are separated with the keyword and. The format of the
names is the second important point: The last name first, then the first name, with a separating
comma. In fact, BibTEX understands other formats.
Before going further, we remark an important point: BibTEX will have to guess which part is the
first name and which part is the last name. It also has to distinguish a possible “von” part (as in John
von Neumann) and a possible “Jr” part.
The following explanation is somewhat technical. The first name will be called First, the last
name is denoted by Last, the “von” with von and the “Jr” part, Jr.
So, BibTEX must be able to distinguish between the different parts of the author field. To that
aim, BibTEX recognizes three possible formats:
• First von Last;
• von Last, First;
• von Last, Jr, First.

http://tug.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf

Implement `purify$`

Classical non-alphanumeric characters23, except special characters, will
be removed by a BibTEX function named purify$. For special characters, purify$ removes
spaces and LATEX commands (strings beginning with a backslash), even those placed between
brace pairs. Everything else is left unmodified. For instance, t^ete, t{^e}te and t{^{e}}te
are transformed into tete, while tête gives tête; Bib{\TeX} gives Bib and Bib\TeX becomes
BibTeX. There are thirteen LATEX commands that won’t follow the above rules: \OE, \ae, \AE,
\aa, \AA, \o, \O, \l, \L, \ss. Those commands correspond to ı, , œ, Œ, æ, Æ, å, Å, ø, Ø, ł, Ł,
ß, and purify$ transforms them (if they are in a special character, in i, j, oe, OE, ae, AE, aa,
AA, o, O, l, L, ss, respectively.

http://tug.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.