Skip to content

Instantly share code, notes, and snippets.

Last active October 22, 2017 11:07
Show Gist options
  • Save jagot/e47dc6c2785beb81ee38aadae0711a6e to your computer and use it in GitHub Desktop.
Save jagot/e47dc6c2785beb81ee38aadae0711a6e to your computer and use it in GitHub Desktop.
Script to generate journal abbrevations for use with Biber
Advances in Atomic and Molecular Physics|Adv. Atom. Mol. Phys.
Advances in Chemical Physics|Adv. Chem. Phys.
Chemical Physics Letters|Chem. Phys. Lett.
Chemical Physics|Chem. Phys.
Computer Physics Communications|Comput. Phys. Commun.
Faraday Discussions|Faraday Discuss.
High Power Laser Science and Engineering|High Power Laser Sci. Eng.
Journal of Experimental and Theoretical Physics|J. Exp. Theor. Phys.
Journal of Physics B: Atomic, Molecular and Optical Physics|J. Phys. B: AMO Phys.
Journal of the Optical Society of America B|J. Opt. Soc. Am. B
Nano Letters|Nano Lett.
Nature Communications|Nat. Comm.
Nature Photonics|Nat. Phot.
Nature Physics|Nat. Phys.
New Journal of Physics|New J. Phys.
Physical Review A|Phys. Rev. A
Physical Review Letters|Phys. Rev. Lett.
Reports on Progress in Physics|Rep. Prog. Phys.
Review of Scientific Instruments|Rev. Sci. Instrum.
Reviews of Modern Physics|Rev. Mod. Phys.
Scientific Reports|Sci. Rep.
The Journal of Chemical Physics|J. Chem. Phys.
The Journal of Physical Chemistry A|J. Phys. Chem. A
using Graphs
abbrvs = filter(readlines("abbrvs")) do line
!ismatch(r"^([ ]*)#", line)
entries = map(abbrvs) do abbrv
g = simple_graph(length(entries))
for i in eachindex(entries)
for j in eachindex(entries)
i == j && continue
contains(entries[i][1], entries[j][1]) && add_edge!(g, i, j)
p = topological_sort_by_dfs(g)
permute!(entries, p)
entries = map(entries) do abbrv
a,b = abbrv
title = replace(a, " ", "\\s")
fe = map(["journal","journaltitle","booktitle"]) do field
<map_step map_field_source="$(field)"
map_match = "$(title)"
map_replace = "$(b)"/>"""
join(fe, "\n")
entries = join(entries, "\n")
xml = """<?xml version="1.0" encoding="UTF-8"?>
<sort order="1">
<sortitem order="1">author</sortitem>
<sort order="2">
<sortitem order="1">year</sortitem>
<maps datatype="bibtex">
<map map_overwrite="1">
open("biber.conf", "w") do file
write(file, xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment