andras-simonyi / citeproc-el

A CSL 1.0.2 Citation Processor for Emacs.
GNU General Public License v3.0
85 stars 9 forks source link

Bug: Exporting to ODT with a bibliography does not italicise author names as requested in footnotes #94

Closed Quintus closed 2 years ago

Quintus commented 2 years ago

Dear Andreas,

well now this is weird. I was happily exporting my document to both LaTeX and HTML finely, but now in the final phase I need to export to ODT (in order to convert to the beloved DOCX format ultimately). Some of my footnotes came out garbled with slashes in ODT export, and only ODT export. It took me a while, but I have now succeeded in isolating this irritating behaviour into a minimal working example. This phenomenon only happens if 1) a document is exported to ODT and 2) the document contains a #+print_bibliography: statement. If either of these conditions does not hold true, the documents exports fine. But with both conditions met, the footnote citations -- and only the footnote citations! The long bibliography is fine! -- do not apply the italic modification, but instead print slashes.

Here comes the minimal working example:

mwe.org:

#+TITLE: Test
#+AUTHOR: Testauthor
#+LANGUAGE: de
#+cite_export: csl /tmp/mwe/juristische-schulung.csl
#+bibliography: /tmp/mwe/mwe.bib

Test. [cite:@schölch2006cppat p. 973]

#+print_bibliography:

mwe.bib:

@Article{schölch2006cppat,
    author = {Günther Schölch},
    title = {Patentschutz für computergestützte Entwurfsmethoden – ein Kulturbruch?},
    journaltitle = {Gewerblicher Rechtsschutz und Urheberrecht},
    shortjournal = {GRUR},
    year = {2006},
    pages = {969-976},
    langid = {ngerman}
}

juristische-schulung.csl is https://github.com/citation-style-language/styles/blob/e22b8a566bad9b4c7f52720f60dd875057a5d210/juristische-schulung.csl

If the above is exported to ODT, the footnote comes out as follows, literally with the slashes:

/Schölch/, GRUR 2006, 969 (973)

If however the same document is exported to HTML or LaTeX, the footnote exports fine, with “Schölch” being italicised. However, if you remove the #+print_bibliography: statement from mwe.org, then magically the footnote exports correctly to ODT, with “Schölch” being italicised.

I have tested this with citeproc at d1a0804a832a00ff549630321700f3bfa8e08bd3 and with Org mode version 9.5 (release_9.5-402-gdc4b27 @ /home/quintus/.emacs.d/org-mode/lisp/). That is, both are at the current HEAD.

I am rather happy that I discovered that removing the #+print_bibliography: statement works around the problem, otherwise I would have to edit about 200 footnotes manually in Word, removing the slashes and italicising the author names!

-quintus

andras-simonyi commented 2 years ago

Thanks for reporting this! I've pushed a commit (9f78396) which should solve the problem.

Quintus commented 2 years ago

Hmmmm. I tested it, and it does fix some of the slashes, but not all of them. For the exact example given in the OP, the problem appears to be resolved, but in my more complex actual document it persists for commentaries. I have this in my custom CSL style file:

<macro name="commentary">
    <choose>
        <if variable="editor">
            <choose>
                <if variable="title-short">
                    <!-- Commentary is cited by title -->
                    <text variable="title-short" suffix="/"/>
                </if>
                <else>
                    <!-- Commentary is cited by editors -->
                    <names variable="editor" suffix="/">
                        <name form="short" delimiter="/" name-as-sort-order="all"/>
                    </names>
                </else>
            </choose>
        </if>
        <else>
            <!-- Commentary is cited by author (rare, e.g. Fischer on StGB) -->
            <names variable="author" font-style="italic">
                <name form="short" delimiter="/" name-as-sort-order="all"/>
            </names>
        </else>
    </choose>
</macro>
<!-- ... --->
<else-if type="legal_commentary">
    <text macro="commentary"/>
    <names variable="author" font-style="italic">
        <name form="short" delimiter="/" name-as-sort-order="all"/>
    </names>
    <text variable="chapter-number" prefix=" "/>
    <label variable="locator" form="symbol" prefix=" "/>
    <text variable="locator" prefix=" "/>
</else-if>

This should in footnotes evaluate to the entry author(s) being appended in italic after a slash, e.g. “Kühling/Buchner/Klar/Kühling” (“Kühling/Buchner” being the commentary book editors, “Klar/Kühling” the entry authors; please, do not ask me who invented this kind of citing). It however comes out like that only in HTML and LaTeX still, but not in ODT. In ODT it comes out as “Kühling/Buchner//Klar/Kühling/” with the slashes literally.

I will have to see if I can extract this into another minimal working example; not today anymore, it’s too late, but I wanted to give you feedback.

andras-simonyi commented 2 years ago

Thanks, I've pushed a commit to master with a more comprehensive fix, hopefully this solved the problem.

Quintus commented 2 years ago

Exporting my commentary entry document now fails with an error message:

OpenDocument export failed: Wrong type argument: arrayp, nil

Strangely, even executing

(setq debug-on-error t
      debug-on-signal nil
      debug-on-quit nil)

does not yield an error backtrace. Any hints?

andras-simonyi commented 2 years ago

Thanks, I've committed a purported fix... could you try again?

Quintus commented 2 years ago

Thank you! I tried again and I can confirm that it works now as expected.