I was just hesitated to see annoying useful BibTeX ids like: "???_tonejito_???" so I found this page [1] that shows how to mess with the Zotero Firefox plugin, and I came out with the idea of using the md5 of the title as identifier (for me that is better than the other id).
The file in question was <FirefoxProfile>/zotero/translators/BibTeX.js the whole code is javascript so it's easy to modify and play with.
Looking around the web I also found this github:gist [2] to calculate an md5 sum from a given string, I pasted all the code at the end of the file and used the md5_hex function as follows to replace the element key.
$ diff -u /tmp/BibTeX.js BibTeX.js 
--- /tmp/BibTeX.js 2012-10-31 02:51:49.000000000 -0600
+++ BibTeX.js 2012-10-31 02:51:43.000000000 -0600
@@ -2083,7 +2083,8 @@
   if(!type) type = "misc";
   
   // create a unique citation key
-  var citekey = buildCiteKey(item, citekeys);
+  //var citekey = buildCiteKey(item, citekeys);
+  var citekey = hex_md5(buildCiteKey(item, citekeys));
   
   
   // write citation key
I'm currently using the Zotero plugin [3] and the zotero bibtex auto-exporter plugin [4], I tested this using the preferences pane for the autoexporter and run a manual test. After a couple of tries the results were like this:
@misc{20c7358045528f33804340fb6510b8b9,
 title = {tonejito {(Andres} Hernandez) · {GitHub}},
 url = {https://github.com/tonejito/},
 urldate = {2012-10-31},
 howpublished = {https://github.com/tonejito/},
 file = {tonejito (Andres Hernandez) · GitHub:/Users/tonejito/Library/Application Support/Firefox/Profiles/profile.default/zotero/storage/AAAAAAAA/tonejito.html:text/html}
},
@misc{823e4a8551f18d37794d3115226700ba,
 title = {Tonejito},
 url = {http://tonejito.blogspot.com/},
 urldate = {2012-10-31},
 howpublished = {http://tonejito.blogspot.com/},
 file = {Tonejito:/Users/tonejito/Library/Application Support/Firefox/Profiles/profile.default/zotero/storage/BBBBBBBB/tonejito.blogspot.com.html:text/html}
},
@misc{d83e6f346506b44510957a2fa00fff13,
 title = {Andres Hernandez {(Tonejito)} on Twitter},
 url = {https://twitter.com/tonejito},
 urldate = {2012-10-31},
 howpublished = {https://twitter.com/tonejito},
 file = {Andres Hernandez (Tonejito) on Twitter:/Users/tonejito/Library/Application Support/Firefox/Profiles/profile.default/zotero/storage/CCCCCCCC/tonejito.html:text/html}
}
So I can use any of this hashes in a LaTeX document like this and the bibliography entries will be sorted and referenced correctly.
\textbf{Twitter}
\cite{d83e6f346506b44510957a2fa00fff13}
\textbf{Blog}
\cite{823e4a8551f18d37794d3115226700ba}
\textbf{Github}
\cite{20c7358045528f33804340fb6510b8b9}
Thanks LaTeX and BibTeX
[1] http://www.curiousjason.com/zoterotobibtex.html
[2] https://gist.github.com/951664
[3] https://addons.mozilla.org/en-US/firefox/addon/zotero/
[4] https://addons.mozilla.org/en-US/firefox/addon/zotero-bib-autoexport/
--
  = ^ . ^ =
 
No comments:
Post a Comment