Search code examples
textemacsorg-mode

Org-mode export to text: citations exported with HTML tags


I am trying to generate text files from org files(originally intended for latex>PDF outputs), for submissions that require plain text.

org-file:

#+TITLE: Foo

#+latex_class: article-no-defaults
#+OPTIONS: |:nil toc:nil author:nil
#+latex_class_options: [11pt,a4paper]
#+latex_header: \usepackage{fontspec}
#+latex_header: \setmainfont{Times New Roman}
#+latex_header: \usepackage{float}
#+latex_header: \usepackage{latexsym}
#+latex_header: \usepackage{graphicx}
#+latex_header: \usepackage{url}
#+latex_header: \usepackage{cleveref}

#+EXPORT_EXCLUDE_TAGS: noexport
#+DRAWERS: NOTES
\date{}
\maketitle

*Document Begins
text text

sentence 1 cite:Ohala1997. sentence 2 cite:Ohala1983, cite:Ham1998. Previous studies on sentence 3 cite:hankamer1988, cite:Ghosh2015, cite:banerjee2018.  sentence 4 cite:recasens1997. sentence 5 cite:banerjee2018.

bibliography:file.bib
bibliographystyle:plain

I tried ‘apalike’ ‘plain’ and ‘natbib’ to check if the problem persisted with different bibliography styles. When I exported this file to text(c-c c-e t U/A) in unicode and ASCII, this was the output:

       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
           Foo
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━


\date{} \maketitle

sentence 1 [Ohala1997]. sentence 2 [Ohala1983], [Ham1998]. Previous studies on sentence 3 [hankamer1988], [Ghosh2015], [banerjee2018].  sentence 4 [recasens1997]. sentence 5 [banerjee2018].

Bibliography ============= [Ohala1997] John Ohala, Aerodynamics of
phonology, <i>{Proc. 4th Seoul International Conference on Linguistics
[SICOL]}</i>, <b>()</b>, 92--97 (1997). <a href="">link</a>. <a
href="http://dx.doi.org/">doi</a>.  [Ohala1983] John Ohala, PHONETIC
EXPLANATIONS FOR SOUND PATTERNS: IMPLICATIONS FOR GRAMMARS OF
COMPETENCE., <i>{Historical linguistics: Problems and perspectives}</i>,
<b>()</b>, 237--278 (1993). <a href="">link</a>. <a
href=“http://dx.doi.org/">doi</a>.

Here, the in-line references are rendered as intended, but the bibliography has HTML codes, and “\date{} \maketitle” are also being read as is(this is a problem I’ve seen in Git repos sometimes). Is there a way to generate a text file(templates, packages) with the bibliography section rendered correctly, and without at org-mode tags?

Thanks in advance.


Solution

  • Using pandoc together with pandoc-citeproc will get you pretty close. Pandoc doesn't understand the syntax used by org-ref, so you'd have to change the last two lines to

    #+bibliography: file.bib
    # OPTIONAL, uncomment if you'd like a different citation style,
    # see https://citationstyles.org/.
    # #+csl: <your-preferred-style>
    

    Run pandoc by calling

    pandoc YOURFILE.org --to=plain
    

    in your terminal. Pandoc-citeproc is called automatically in the process. This will give you plain ASCII and will include a bibliography and references.