andras-simonyi / citeproc-el

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

Remove hyperlinks in footnote citations #141

Closed Quintus closed 5 months ago

Quintus commented 1 year ago

Dear Andras,

I have the questionable pleasure to have to submit my documents in DOCX format, so I usually export from org-mode to ODT and then use LibreOffice to convert that into a DOCX file. Hyperlinks are (for whatever reasons) frowned upon in these documents, so until now I have been patiently deleting each and every hyperlink generated by citeproc-el in the footnotes manually. With longer documents, this is getting annoying. Is it possible to introduce an option to citeproc-el which makes it stop creating hyperlinks in the footnote citations?

(Obviously, I am using a footnote-based citation style)

-quintus

andras-simonyi commented 1 year ago

Dear Marvin, unfortunately, this is more complicated than one might think because the ODT export of citations is currently based on first exporting them to Org format and then using the Org exporter to further export to ODT, and, as far as I know, Org automatically links URLs during export, even if they are not proper Org links syntactically. Moreover, I think there is no option to turn this functionality off. Since wrapping URLs into a pair of "="-s (for verbatim) prevents autolinking, you might try to redefine Citeproc-el's Org formatter to automatically put all link anchors into verbatim with the following code (should be run after loading Citeproc), but this will remove links from citations for all other export formats that rely on the Org formatter (fortunately, LaTeX and html-based ones do not):

 (setq my/citeproc-fmt--org-alist
      `((unformatted . identity)
        ;; Export href anchors as verbatim.
    (href . ,(lambda (x y) (concat "=" x "=")))
    (cited-item-no . ,(lambda (x y) (concat "[[citeproc_bib_item_" y "][" x "]]")))
    (bib-item-no . ,(lambda (x y) (concat "<<citeproc_bib_item_" y ">>" x)))
    ;; Warning: The next four formatter lines put protective zero-width spaces
    ;; around the Org format characters ('/' etc.).
    (font-style-italic . ,(lambda (x) (concat "​/" x "/​")))
    (font-style-oblique . ,(lambda (x) (concat "​/" x "/​")))
    (font-weight-bold . ,(lambda (x) (concat "​*" x "*​")))
    (text-decoration-underline . ,(lambda (x) (concat "​_" x "_​")))
    ;; End of zero-width space protected formatters.
    (font-variant-small-caps . ,(lambda (x) (upcase x)))
    (vertical-align-sub . ,(lambda (x) (concat "_{" x "}")))
    (vertical-align-sup . ,(lambda (x) (concat "^{" x "}")))
    (display-left-margin . ,(lambda (x) (concat x " ")))))
(setq citeproc-fmt--org-format-rt-1
      (citeproc-formatter-fun-create my/citeproc-fmt--org-alist))
Quintus commented 11 months ago

Apologies for replying, again, much too slowly. I think I was not entirely clear. I am not talking about links to online resources (think @online in Biblatex lingo), but I am talking about the cross-references made in exported footnote citations. That is, when I first cite something, the exported footnote simply contains the expanded citation. The next time I cite the same work, the footnote expansion contains a link to the first expansion. That’s what I want to suppress. Suppressing hyperlinks to online resources is a nice addition, but since in my field nearly no online resources are cited, the work generated by that is negligable, I can well do that by hand.

I do use the disambiguate condition of CSL, though, at least for articles I write. All I want is that the subsequent footnote citations are not clickable, because the journals don’t want that. Some of them literally print the DOCX format and that would cause an underlined text to appear in the printed document.

andras-simonyi commented 6 months ago

Dear Marvin, apologies for this absurdly late response, but: doesn't setting the variable org-cite-csl-link-cites to nil solve this problem?

Quintus commented 5 months ago

Dear Andras,

Dear Marvin, apologies for this absurdly late response, but: doesn't setting the variable org-cite-csl-link-cites to nil solve this problem?

This variable does not appear to change anything if I set it to nil.By now I also noted that my issue does not really appear to be a CSL problem, because cross-references in real citation footnotes are not actually linked. It turns out that it only happens for the very specific judicial commentaries, because I manually set the footnotes for those and crosslink them with a <<>> target in them, because this nicely gives the footnote number when referenced. It does however happen in relation to CSL when using @online resources with a style that prints the URL.

However, I found a way to work around my problem. I have started to use OTT template files, since they allow nice things like automatic alphanumeric header numbering even in the resulting ODT file (org’s ODT_STYLE_FILE directive). I found out that a special character style called “Internetverknüpfung” in the German version of LibreOffice is always applied to hyperlinks, and it is possible to change that character style via the formatting styles menu. I disabled color change and underlining there, and now hyperlinks even remain clickable, but do not stand out from the text anymore as required. That even works after converting ODT to DOCX. I have not checked with MS Word itself, but I do not expect it behaves differently.

Thanks for taking a look, though.