Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ionen-angewandte-physik
AG-Wester
bibtools
Commits
4e162988
Commit
4e162988
authored
Mar 22, 2021
by
User expired
Browse files
Text interface to ris2bib online converter added
parent
e2c7c8ab
Pipeline
#42798
passed with stage
in 2 minutes and 22 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
README.rst
README.rst
+6
-0
bin/ris2bib
bin/ris2bib
+78
-0
No files found.
README.rst
View file @
4e162988
...
@@ -57,4 +57,10 @@ Notes on the BibTeX format
...
@@ -57,4 +57,10 @@ Notes on the BibTeX format
- New BibTeX files may enclose contents in quotation marks, but string
- New BibTeX files may enclose contents in quotation marks, but string
concatenation with ``#`` is not supported.
concatenation with ``#`` is not supported.
Related
=======
- The ``bin/ris2bib`` is a command line interface to convert RIS files to
BibTeX format using the `ris2bib`_ online converter by Nicolas Bruot.
.. _bibtools.pdf: https://bop.uber.space/files/bibtools/bibtools.pdf
.. _bibtools.pdf: https://bop.uber.space/files/bibtools/bibtools.pdf
.. _ris2bib: https://www.bruot.org/ris2bib/
bin/ris2bib
0 → 100755
View file @
4e162988
#
!/usr/bin/perl -w
#
Use
online
ris2bib
to
convert
one
ris
(
RIS
)
file
to
bib
(
BIBTEX
)
file
use
strict
;
use
Encode
;
package
MyParser
;
use
base
qw
(
HTML
::
Parser
);
my
$
is_bib
=
0
;
my
$
bib
=
''
;
sub
start
{
my
($
self
,
$
tagname
,
$
attr
,
$
attrseq
,
$
origtext
)
=
@
_
;
if
($
tagname
eq
'textarea'
)
{
if
($
attr
->{
name
}
eq
'bib'
)
{
$
is_bib
=
1
;
}
}
}
sub
text
{
if
($
is_bib
eq
1
)
{
my
($
self
,
$
text
)
=
@
_
;
$
bib
=
$
text
;
$
is_bib
=
0
;
}
}
#
Get
ris
filename
from
first
argument
.
my
$
num_args
=
$#
ARGV
+
1
;
if
($
num_args
<
1
)
{
print
"Usage: ris2bib filename.ris [files...]
\n
"
;
exit
;
}
for
(
my
$
i
=
0
;
$
i
<
$
num_args
;
$
i
++)
{
my
$
risfile
=
$
ARGV
[$
i
];
my
$
bibfile
=
$
risfile
;
$
bibfile
=~
s
/\.
ris
/.
bib
/;
print
"Convert '"
,
$
risfile
,
"' to '"
,
$
bibfile
,
"'.
\n
"
;
#
Load
input
ris
file
.
my
$
ris
=
''
;
open
RISFILE
,
'<'
,
$
risfile
or
die
"
\n
Cannot open input file `$risfile': $!
\n
"
;
while
(
my
$
line
=
<
RISFILE
>)
{
chomp
$
line
;
$
ris
=
$
ris
.$
line
.
"
\n
"
;
}
#
Online
conversion
to
bibtex
.
use
HTTP
::
Request
::
Common
qw
(
POST
);
use
LWP
::
UserAgent
;
use
LWP
::
Protocol
::
https
;
my
$
ua
=
LWP
::
UserAgent
->
new
;
my
$
req
=
POST
"https://www.bruot.org/ris2bib/"
,
[
ris
=>
$
ris
];
my
$
result
=
Encode
::
decode
(
'utf8'
,
$
ua
->
request
($
req
)->
as_string
);
#
Extract
bibtext
record
from
html
.
$
is_bib
=
0
;
$
bib
=
''
;
my
$
parser
=
MyParser
->
new
;
$
parser
->
parse
(
$
result
);
#
Write
bibtex
result
to
file
.
open
(
FH
,
'>'
,
$
bibfile
)
or
die
$
!;
print
FH
Encode
::
encode
(
'utf8'
,
$
bib
);
close
(
FH
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment