summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ltb2bib/ltb2bib.sty
blob: fd6bf756df8f21498ff2e2619b830c860ad43312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
%%
%% This is file `ltb2bib.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ltb2bib.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2017 by Laurent Bartholdi <laurent.bartholdi@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{ltb2bib}
    [2017/04/03 0.01 First release in the wild]
\ProvidesPackage{ltb2bib}[2017/04/03 v0.01]
\@ifundefined{thebibliography}{\newenvironment{thebibliography}{}{}}{}
\@ifundefined{footnotesize}{\let\footnotesize\relax}{}
\RequirePackage{amsrefs}
\RequirePackage{xpatch}
\newwrite\@bibfile
\let\protected@iwrite\protected@write
\xpatchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}
\def\bib@write#1{\protected@iwrite\@bibfile{\let~\relax\def\ndash{--}}{#1}}
\gdef\space{ }
\gdef\spsp{\space\space}
\def\@author#1{\toks0={}\toks1={}%
  \def\name##1{\toks0=\expandafter{\the\toks0\the\toks1{##1}}\toks1={\spsp and }}%
  #1
  \bib@write{\spsp author={\the\toks0},}%
}
\def\@editor#1{\toks0={}\toks1={}%
  \def\name##1{\toks0=\expandafter{\the\toks0\the\toks1{##1}}\toks1={\spsp and }}%
  #1
  \bib@write{\spsp editor={\the\toks0},}%
}
\def\@translator#1{\toks0={}\toks1={}%
  \def\name##1{\toks0=\expandafter{\the\toks0\the\toks1{##1}}\toks1={\spsp and }}%
  #1
  \bib@write{\spsp translator={\the\toks0},}%
}
\def\@contribution#1{\bib@write{\spsp contribution=\@charlb#1\@charrb,}}
\def\@isbn#1{\def\fld@elt##1{\bib@write{\spsp isbn=\@charlb##1\@charrb,}}#1}
\def\@issn#1{\def\fld@elt##1{\bib@write{\spsp issn=\@charlb##1\@charrb,}}#1}
\def\@review#1{\def\MR##1{\let\MR\relax\bib@write{\spsp review={\MR{##1}},}}#1}
\def\@partial#1{\bib@write{\spsp partial=\@charlb#1\@charrb,}}
\def\@accessdate#1{\bib@write{\spsp accessdate=\@charlb#1\@charrb,}}
\def\@address#1{\bib@write{\spsp address=\@charlb#1\@charrb,}}
\def\@book#1{\bib@write{\spsp book=\@charlb#1\@charrb,}}
\def\@booktitle#1{\bib@write{\spsp booktitle=\@charlb#1\@charrb,}}
\def\@conference#1{\bib@write{\spsp conference=\@charlb#1\@charrb,}}
\def\@copula#1{\bib@write{\spsp copula=\@charlb#1\@charrb,}}
\def\@date#1{\bib@write{\spsp year=\@charlb#1\@charrb,}}
\def\@doi#1{\bib@write{\spsp doi=\@charlb#1\@charrb,}}
\def\@edition#1{\bib@write{\spsp edition=\@charlb#1\@charrb,}}
\def\@eprint#1{\bib@write{\spsp eprint=\@charlb#1\@charrb,}}
\def\@fulljournal#1{\bib@write{\spsp fulljournal=\@charlb#1\@charrb,}}
\def\@hyphenation#1{\bib@write{\spsp hyphenation=\@charlb#1\@charrb,}}
\def\@institution#1{\bib@write{\spsp institution=\@charlb#1\@charrb,}}
\def\@journal#1{\bib@write{\spsp journal=\@charlb#1\@charrb,}}
\def\@label#1{\bib@write{\spsp label=\@charlb#1\@charrb,}}
\def\@language#1{\bib@write{\spsp language=\@charlb#1\@charrb,}}
\def\@name#1{\bib@write{\spsp name=\@charlb#1\@charrb,}}
\def\@note#1{\bib@write{\spsp note=\@charlb#1\@charrb,}}
\def\@number#1{\bib@write{\spsp number=\@charlb#1\@charrb,}}
\def\@organization#1{\bib@write{\spsp organization=\@charlb#1\@charrb,}}
\def\@pages#1{\bib@write{\spsp pages=\@charlb#1\@charrb,}}
\def\@part#1{\bib@write{\spsp part=\@charlb#1\@charrb,}}
\def\@place#1{\bib@write{\spsp place=\@charlb#1\@charrb,}}
\def\@publisher#1{\bib@write{\spsp publisher=\@charlb#1\@charrb,}}
\def\@reprint#1{\bib@write{\spsp reprint=\@charlb#1\@charrb,}}
\def\@school#1{\bib@write{\spsp school=\@charlb#1\@charrb,}}
\def\@series#1{\bib@write{\spsp series=\@charlb#1\@charrb,}}
\def\@setup#1{\bib@write{\spsp setup=\@charlb#1\@charrb,}}
\def\@status#1{\bib@write{\spsp status=\@charlb#1\@charrb,}}
\def\@subtitle#1{\bib@write{\spsp subtitle=\@charlb#1\@charrb,}}
\def\@title#1{\bib@write{\spsp title=\@charlb#1\@charrb,}}
\def\@translation#1{\bib@write{\spsp translation=\@charlb#1\@charrb,}}
\def\@type#1{\bib@write{\spsp type=\@charlb#1\@charrb,}}
\def\@url#1{\bib@write{\spsp url=\@charlb#1\@charrb,}}
\def\@volume#1{\bib@write{\spsp volume=\@charlb#1\@charrb,}}
\def\@xref#1{\bib@write{\spsp xref=\@charlb#1\@charrb,}}
\def\@year#1{\bib@write{\spsp year=\@charlb#1\@charrb,}}
\def\make@bibspec#1#2{\BibSpec{#1}{%
    +{}{\bib@write{@#2\@charlb\current@citekey,}}{transition}
    +{}{\@author}        {author}
    +{}{\@editor}        {editor}
    +{}{\@translator}    {translator}
    +{}{\@contribution}  {contribution}
    +{}{\@isbn}          {isbn}
    +{}{\@issn}          {issn}
    +{}{\@review}        {review}
    +{}{\@partial}       {partial}
    +{}{\@accessdate}    {accessdate}
    +{}{\@address}       {address}
    +{}{\@book}          {book}
    +{}{\@booktitle}     {booktitle}
    +{}{\@conference}    {conference}
    +{}{\@copula}        {copula}
    +{}{\@date}          {date}
    +{}{\@doi}           {doi}
    +{}{\@edition}       {edition}
    +{}{\@eprint}        {eprint}
    +{}{\@fulljournal}   {fulljournal}
    +{}{\@hyphenation}   {hyphenation}
    +{}{\@institution}   {institution}
    +{}{\@journal}       {journal}
    +{}{\@label}         {label}
    +{}{\@language}      {language}
    +{}{\@name}          {name}
    +{}{\@note}          {note}
    +{}{\@number}        {number}
    +{}{\@organization}  {organization}
    +{}{\@pages}         {pages}
    +{}{\@part}          {part}
    +{}{\@place}         {place}
    +{}{\@publisher}     {publisher}
    +{}{\@reprint}       {reprint}
    +{}{\@school}        {school}
    +{}{\@series}        {series}
    +{}{\@setup}         {setup}
    +{}{\@status}        {status}
    +{}{\@subtitle}      {subtitle}
    +{}{\@title}         {title}
    +{}{\@translation}   {translation}
    +{}{\@type}          {type}
    +{}{\@url}           {url}
    +{}{\@volume}        {volume}
    +{}{\@xref}          {xref}
    +{}{\@year}          {year}
  +{}{\bib@write{\@charrb^^J}}{transition}
}}
\newskip\ltb@baselineskip
\newskip\ltb@parskip
\newcommand\writebib[2]{%
  \immediate\openout\@bibfile=#2.bib
  \bib@write{\@percentchar\space Converted bibliography from #1[.ltb] to #2.bib}%
  \typeout{Writing bibliography to #2.bib...}%
  \make@bibspec{article}{Article}%
  \make@bibspec{partial}{InCollection}%
  \make@bibspec{contribution}{InCollection}%
  \make@bibspec{book}{Book}%
  \make@bibspec{collection.article}{InCollection}%
  \make@bibspec{conference}{Conference}%
  \make@bibspec{innerbook}{InBook}%
  \make@bibspec{report}{TechReport}%
  \make@bibspec{thesis}{PhdThesis}%
  \make@bibspec{webpage}{Misc}%
  \ltb@parskip=\parskip
  \ltb@baselineskip=\baselineskip
  \let\ltb@item=\item
  \parskip=0pt
  \baselineskip=0pt
  \let\item=\relax
  \let\fld@elt=\relax
  \bibselect*{#1}%
  \bib@write{\@percentchar\space End of #2.bib}%
  \immediate\closeout\@bibfile
  \parskip=\ltb@parskip
  \baselineskip=\ltb@baselineskip
  \let\item=\ltb@item
}

\endinput
%%
%% End of file `ltb2bib.sty'.