Bib2wiki: Difference between revisions
Fabrice P. Laussy's Web
Fabrice (talk | contribs)
New script for referencing on this web
 
Fabrice (talk | contribs)
Line 3: Line 3:
'''''bib2wiki''''' is a [[perl]] script to generate a [[template]] to cite scientific refeferences on this [[laussy.org|very website]] from its [[bibTeX|$\mathrm{B{\scriptstyle{IB}}\TeX}$]] entry.
'''''bib2wiki''''' is a [[perl]] script to generate a [[template]] to cite scientific refeferences on this [[laussy.org|very website]] from its [[bibTeX|$\mathrm{B{\scriptstyle{IB}}\TeX}$]] entry.


The rationale is explained [[Blog:Hacks/A_simple_way_to_quote_from_bibTeX_in_MediaWiki|in this blog post]].
This is, for instance, an old paper of ours: {{delvalle07a}}
 
The rationale is explained [[Blog:Hacks/A_simple_way_to_quote_from_bibTeX_in_MediaWiki|in this blog post]] and '''[[Blog:Hacks/bib2wiki_or_parsing_bibTeX_into_mediawiki_templates|examples of its use are in this other blog post]]'''.


It is based on [https://metacpan.org/pod/BibTeX::Parser BibTeX::Parser].
It is based on [https://metacpan.org/pod/BibTeX::Parser BibTeX::Parser].
Line 19: Line 21:
# To print several keys:
# To print several keys:
#  bib2wiki -keys=laussy04a,laussy05a,laussy06a
#  bib2wiki -keys=laussy04a,laussy05a,laussy06a
</pre>
== Get the keys from Mediawiki ==
To extract the keys needed on a page, in edit mode, look for the list of templates at the end. It could look something like this:
<wz tip="References not yet uploaded to the wiki.">[[File:Screenshot_20230716_164012.png|250px]]</wz>
Copy/past in a file (say <tt>templates</tt>) on which you run:
<pre>
cat templates | perl -pe 's/Template:([a-zA-Z]+[0-9]{2}[a-z])\s\(edit\)\.*/\1/p' | sed '/Template/d' | awk -vORS=, '{ print $1 }' | sed 's/,$/\n/'
</pre>
That will output on one line the list of templates needed:
<pre>
Kirkwood35a,Kirkwood39a,Kirkwood42a,Kirkwood50a,Lopezcarreno18b,Percus58a,Salsburg53a,Sells53a,Thiele63a,Wertheim63a,Zerniker37a
</pre>
You can then pass this to bib2wiki
<pre>
bib2wiki -keys=Kirkwood35a,Kirkwood39a,Kirkwood42a,Kirkwood50a,Lopezcarreno18b,Percus58a,Salsburg53a,Sells53a,Thiele63a,Wertheim63a,Zerniker37a
</pre>
which will return the list you have to upload:
<pre>
kirkwood35a
<u>[[Statistical Mechanics of Fluid Mixtures]]</u>. [[J. G. Kirkwood]] in [[J. Chem. Phys.]] [http://dx.doi.org/10.1063/1.1749657 '''3''':300] ([[1935]]).
kirkwood39a
<u>[[Molecular Distribution in Liquids]]</u>. [[J. G. Kirkwood]] in [[J. Chem. Phys.]] [http://dx.doi.org/10.1063/1.1750344 '''7''':919] ([[1939]]).
kirkwood42a
<u>[[The Radial Distribution Function in Liquids]]</u>. [[J. G. Kirkwood]] and [[E. Monroe]] in [[J. Chem. Phys.]] [http://dx.doi.org/10.1063/1.1723737 '''10''':394] ([[1942]]).
etc.
</pre>
</pre>

Revision as of 21:26, 16 July 2023

bib2wiki

bib2wiki is a perl script to generate a template to cite scientific refeferences 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.

It is based on BibTeX::Parser.

Usage

# Usage: 
# To print everything:
#   bib2wiki -keys=all
#
# To print one key:
#   bib2wiki -keys=laussy04a
#
# To print several keys:
#   bib2wiki -keys=laussy04a,laussy05a,laussy06a