jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.36k stars 242 forks source link

Betterbibtex "From Markdown to Zotero live citations" incorporation with org-ref #1002

Open aminevsaziz opened 2 years ago

aminevsaziz commented 2 years ago

Betterbibtex on its website provide a pandoc Lua filter (https://retorque.re/zotero-better-bibtex/exporting/pandoc ) where it's possible to export clickable citation. This option would be awesome for people who write manuscripts in docx format since not all research fields use latex.

In my opinion combining the power of org-ref + betterbibtex + custom pandoc filter compatible with org-ref for converting to docx format. Any suggestions or thought I like to welcome because I would like to start on this project but require some insights and thoughts.

jkitchin commented 2 years ago

Have you tried the existing export to word with CSL? e.g. https://github.com/jkitchin/org-ref/blob/master/examples/basic-csl.org#ms-word-docx-via-pandoc

I guess this could be a standalone file. Probably you need to iterate over the citations in a preprocessing hook to convert them to pandoc form, then export and process via pandoc.

aminevsaziz commented 2 years ago

Have you tried the existing export to word with CSL? e.g. https://github.com/jkitchin/org-ref/blob/master/examples/basic-csl.org#ms-word-docx-via-pandoc

I guess this could be a standalone file. Probably you need to iterate over the citations in a preprocessing hook to convert them to pandoc form, then export and process via pandoc.

well i did like you suggested in the examples. However, i found out pandoc dont parse org-ref citation as CITE inline but rather as link and you need to run the file inside emacs with pre-processing hook to get them processed. This limit the ability to use filters because citation are not recognized to pandoc unless you run pre-processing inside emacs .

this the test.org file

#+csl-style: elsevier-harvard.csl
#+PANDOC_OPTIONS: bibliography:zotlib.bib
#+BIBLIOGRAPHY: zotlib.bib

[[cite:&nam-2011]]

* Bibliography
bibliographystyle:unsrtnat
bibliography:zotlib.bib

#+BEGIN_SRC emacs-lisp 
(require 'ox-pandoc)
(require 'org-ref-refproc)
(let ((org-export-before-parsing-hook '(org-ref-cite-natmove ;; do this first
                    org-ref-csl-preprocess-buffer
                    org-ref-refproc)))
  (org-open-file (org-pandoc-export-to-docx)))
#+END_SRC

this the zotlib.bib file

@inproceedings{nam-2011,
  title = {Smart City as Urban Innovation: Focusing on Management, Policy, and Context},
  shorttitle = {Smart City as Urban Innovation},
  booktitle = {Proceedings of the 5th {{International Conference}} on {{Theory}} and {{Practice}} of {{Electronic Governance}} - {{ICEGOV}} '11},
  author = {Nam, Taewoo and Pardo, Theresa A.},
  year = {2011},
  pages = {185},
  publisher = {{ACM Press}},
  address = {{Tallinn, Estonia}},
  doi = {10.1145/2072069.2072100},
  abstract = {This paper sees a smart city not as a status of how smart a city is but as a city's effort to make itself smart. The connotation of a smart city represents city innovation in management and policy as well as technology. Since the unique context of each city shapes the technological, organizational and policy aspects of that city, a smart city can be considered a contextualized interplay among technological innovation, managerial and organizational innovation, and policy innovation. However, only little research discusses innovation in management and policy while the literature of technology innovation is abundant. This paper aims to fill the research gap by building a comprehensive framework to view the smart city movement as innovation comprised of technology, management and policy. We also discuss inevitable risks from innovation, strategies to innovate while avoiding risks, and contexts underlying innovation and risks.},
  isbn = {978-1-4503-0746-8},
  langid = {english},
  file = {/home/julia/dotfiles/org/literature/nam_2011.pdf}
}

and this the command i used to generate native pandoc -f org -t native --citeproc --csl=elsevier-harvard.csl --bibliography=zotlib.bib --standalone test.org

the native ouput was

[ RawBlock
(Format "org") "#+csl-style: elsevier-harvard.csl"
, RawBlock
(Format "org") "#+PANDOC_OPTIONS: bibliography:zotlib.bib"
, RawBlock (Format "org") "#+BIBLIOGRAPHY: zotlib.bib"
, Para
[ Link
( "" , [] , [] )
[ Str "cite:&nam-2011" ]
( "cite:&nam-2011" , "" )
]
, Header
1 ( "bibliography" , [] , [] ) [ Str "Bibliography" ]
, Para
[ Str "bibliographystyle:unsrtnat"
, SoftBreak
, Str "bibliography:zotlib.bib"
]
]

the output docx [Uploading test.docx…]()