bib2wiki is a perl script to generate a template to cite scientific references on this very website from its $\mathrm{B{\scriptstyle{IB}}\TeX}$ entry.
This is, for instance, an old paper of ours: Electrostatic control of quantum dot entanglement induced by coupling to external reservoirs. E. del Valle, F. P. Laussy and C. Tejedor in Europhys. Lett. 80:57001 (2007).
The rationale is explained in this blog post and examples of its use are in this other blog post. Undefined references can be fixed with keys2wiki.
It supports Bash autocompletion, as is declared in showme.
It is based on BibTeX::Parser.
# Usage: # To print one key: # bib2wiki laussy04a # # To print several keys: # bib2wiki -keys=laussy04a,laussy05a,laussy06a # # To print everything: # bib2wiki -keys=all
#! /usr/bin/perl -X -s
# _ _ _ ____ _ _ _
#| |__ (_) |__|___ \__ _(_) | _(_)
#| '_ \| | '_ \ __) \ \ /\ / / | |/ / |
#| |_) | | |_) / __/ \ V V /| | <| |
#|_.__/|_|_.__/_____| \_/\_/ |_|_|\_\_|
# F.P. Laussy - fabrice.laussy@gmailcom
# v0°5 Sun 16 Jul 2023
# v0°7 Sun 31 Dec 2023 - http://laussy.org/wiki/Blog:Trifles/v0%C2%B07_of_bib2wiki
# v0°1 Tue Sep 16 2025
#
# Usage:
# To print one key:
# bib2wiki laussy04a
#
# To print several keys:
# bib2wiki -keys=laussy04a,laussy05a,laussy06a
#
# To print everything:
# bib2wiki -keys=all
use BibTeX::Parser;
use IO::File;
# clear screen
import os;
#os.system('clear');
# This is to remove warnings from the bibTeX parser:
use File::Spec;
open STDERR, '>', File::Spec->devnull();
# default file
my $fh = IO::File->new("/home/laussy/bib/sci.bib");
my $parser = BibTeX::Parser->new($fh);
# the map lc converts to lowercases
my @mykeys = map { lc } split(/,/, $keys);
push(@mykeys,$ARGV[0]);
while (my $entry = $parser->next ) {
if ($entry->parse_ok) {
my $bibkey = $entry->key;
if (($keys eq "all") or ($bibkey ~~ @mykeys)) {
my $type = $entry->type;
my $title = $entry->field("title");
my $url = $entry->field("url");
$url =~ s/doi:/http:\/\/dx.doi.org\//;
my $journal = $entry->field("journal");
my $volume = $entry->field("volume");
my $pages = $entry->field("pages");
my $year = $entry->field("year");
# print $type . " -- " . $bibkey . "\n";
# print $bibkey . "\n";
print "\033[1;33m$bibkey\033[0m\n"; #Bold and Yellow
# my $output = "'''[" . $url . " " . $title . "]'''. ";
# my $output = "<u>[[" . $title . "]]</u>. ";
my $output = "<u>[[" . $bibkey . "|" . $title . "]]</u>. ";
my @authors = $entry->author;
# or:
# my @editors = $entry->editor;
# keep all but last authors
my @notlast = @authors;
pop @notlast;
foreach my $author (@notlast) {
my $initials = $author->first;
$initials =~ s/~/ /g;
$output .= "[[" . $initials . " "
. $author->von . " "
. $author->last . "]], "
## . $author->jr;
}
# print last author
my $initials = $authors[-1]->first;
$initials =~ s/~//g;
if (@notlast) { $output .= "and " };
$output .= "[[" . $initials . " " . $authors[-1]->von . " " . $authors[-1]->last . "]] in ";
# my $output = "'''[" . $url . " " . $title . "]'''. ";
$output .= "[[" . $journal . "]] [" . $url . " '''" . $volume ."''':" . $pages . "] ([[" . $year . "]]).\n\n";
$output =~ s/, and/ and/g;
$output =~ s/ +/ /g;
$output =~ s/--/-/g;
$output =~ s/{//g;
$output =~ s/}//g;
$output =~ s/\\'a/á/g;
$output =~ s/\\'e/é/g;
$output =~ s/\\`e/è/g;
$output =~ s/\\'i/í/g;
$output =~ s/\\\^i/î/g;
$output =~ s/\\'o/ó/g;
$output =~ s/\\"a/ä/g;
$output =~ s/\\"o/ö/g;
$output =~ s/\\"u/ü/g;
$output =~ s/\\~n/ñ/g;
$output =~ s/\\'E/É/g;
# my macros
$output =~ s/\\Imamoglu/İmamoğlu/g;
$output =~ s/\\Vuckovic/Vučković/g;
print $output;
}
} else {
warn "Error parsing file: " . $entry->error;
}
}