emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: citeproc-org and org-ref 3


From: Joseph Vidal-Rosset
Subject: Re: citeproc-org and org-ref 3
Date: Fri, 03 Dec 2021 08:04:44 +0000

Hi John,

A detail about exporting with org-ref 3 in html when the csl style is
for numeric references. With org-ref 2 + citeproc-org, I got this:

[1] R. Descartes, Meditations on First Philosophy: with Selections from
the Objections and Replies. Oxford: OUP Oxford, 2008.

(see the references here :
https://www.vidal-rosset.net/descartess_first_proof_of_gods_existence_in_first-order_logic.html
)

With org-ref 3, with apparently any numeric style, I get this:

[1]
R. Descartes, Meditations on First Philosophy: with Selections from the
Objections and Replies. Oxford: OUP Oxford, 2008.

I mean that each bibliographical reference is below its number link, and
it is not very nice. I wonder about the reason of this difference of
output, and a possible solution.

Best wishes,

Jo.

Le 02/12/2021 à 18:35, John Kitchin a écrit :
> Glad to hear it is working again for you! Best wishes,
>
> Joseph Vidal-Rosset <joseph@vidal-rosset.net> writes:
>
>> Dear all,
>>
>>
>> I just succeeded in solving my problem.
>>
>> l-210-235 of myblogexporter.el, I changed the code for:
>>
>> (defun org-export-head-export-headers (directory-name backend)
>>     "Exports each heading to directory-name using backend"
>>     (if (equal backend "html")
>>         (org-export-head--run-on-each-heading
>>          #'(lambda ()
>>              (org-set-property
>>               "EXPORT_FILE_NAME"
>>               (concat directory-name (org-export-head--escaped-headline)))
>>              (deactivate-mark)
>>              (let ((org-export-before-parsing-hook
>> '(org-ref-csl-preprocess-buffer)))
>>                   (cl-letf (((symbol-function 'org-export-get-reference)
>> (symbol-function 'org-export-get-reference-custom)))
>>                     (if org-export-head-click-toc-h2
>>                         (cl-letf ((
>>                                    ;(symbol-function 'org-html-toc)
>>                                    (symbol-function
>> 'org-export-head--custom-toc)))
>>                           (org-html-export-to-html nil t)))))
>>              (set-buffer-modified-p t)) "-noexport-noreexport"))
>>     (if (equal backend "pdf")
>>         (org-export-head--run-on-each-heading
>>          #'(lambda ()
>>              (org-set-property
>>               "EXPORT_FILE_NAME"
>>               (concat directory-name (org-export-head--escaped-headline)))
>>              (deactivate-mark)
>>              (org-latex-export-to-pdf nil t)
>>              (set-buffer-modified-p t)) "-noexport-noreexport")))
>>
>> and it works with org-ref 3.
>>
>> Best wishes,  I attach myblogexporter.el
>>
>> Jo.
>>
>> Le 02/12/2021 à 14:17, Joseph Vidal-Rosset a écrit :
>>> Dear John (cc. Ivan),
>>>
>>> First, thanks for your help and for your patience, that's very kind of you.
>>>
>>> The good news is that indeed, org-ref 3 exports nicely the  html
>>> bibliography with my CSL file, it works well with your org file and your
>>> bibliography. My error was simple: I did not use the specific org-ref
>>> keys but the ordinary h-o keys.. A stupid mistake.
>>>
>>> The bad news is that this new function for exporting with org-ref 3 is
>>> not included in org-export-head, a nice org mode to blog exporter, made
>>> by Ivan Tadeu Ferreira Antunes Filho, which converts each header to a
>>> different file, I find this exporter very convenient. I had no problem
>>> with this org-ref 2 to use this blog-exporter, but it org-ref 3 is
>>> unfortunately not still adapted to its use. Nevertheless, I believe that
>>> it should be possible to find the lines to include this function
>>> (let  ((org-export-before-parsing-hook '(org-ref-csl-preprocess-buffer)))
>>>        (org-open-file  (org-html-export-to-html)))
>>> in org-export-head. I tried, but without success, because I am simply
>>> not expert enough. I see the best, that is to export both with org-ref 3
>>> (i.e. "r h") and org-export-head, but I am unable to code it.
>>>
>>> No doubt that it should be for you and Ivan a piece of cake, but please
>>> do it only if you think that it is interesting and if you find the time
>>> to do it.
>>>
>>> Best wishes,
>>>
>>> Jo.
>>>
>>> PS in attachment, myblogexporter.el in my ~/.emacs.d/personal  (usual
>>> path with Prelude Emacs).
>>>
>>> Le 01/12/2021 à 23:16, John Kitchin a écrit :
>>>>
>>>> Joseph Vidal-Rosset <joseph@vidal-rosset.net> writes:
>>>>
>>>>> Dear Andras,
>>>>>
>>>>> You are very probably right. I will have a look on this entry in my
>>>>> default bibliography file.
>>>>>
>>>>> The code
>>>>>
>>>>> (let  ((org-export-before-parsing-hook '(org-ref-csl-preprocess-buffer)))
>>>>>            (org-open-file  (org-html-export-to-html)))
>>>>>
>>>>> put in .emacs.d/personal/preload/myorgexport.el
>>>>>
>>>> This code should not go in your init file. It is executed each time, and
>>>> not what you want. I usually put it a src block at the end in a section
>>>> tagged noexport and run it from there.
>>>>
>>>> Alternatively, if this is the only preprocessing you do, I think you can
>>>> do C-c C-e rh to export to html (this runs the org-ref html exporter.
>>>>
>>>> Finally, if you really want something in your init file it should be
>>>> like this:
>>>>
>>>> (defun my-html ()
>>>>      (interactive)
>>>>      (let  ((org-export-before-parsing-hook 
>>>> '(org-ref-csl-preprocess-buffer)))
>>>>        (org-open-file  (org-html-export-to-html))))
>>>>
>>>> and then later you run it with M-x my-html
>>>>
>>>>
>>>>> provokes the request of opening a html file, when emacs --daemon is
>>>>> started; therefore I conclude that it should not be used as I did...
>>>>>
>>>>> Anyway, every  tentative  to export in a bibliography in html fails at
>>>>> the moment, even with a new bibliography file...  :(
>>>>
>>>> See of the one at
>>>> https://github.com/jkitchin/org-ref/blob/master/examples/basic-csl.org
>>>> works. The bib file is in
>>>> https://github.com/jkitchin/org-ref/blob/master/org-ref.bib.
>>>>
>>>>
>>>>
>>>>>
>>>>> Best wishes,
>>>>>
>>>>> Le 01/12/2021 à 17:33, András Simonyi a écrit :
>>>>>> Dear Joseph,
>>>>>>
>>>>>> based on the error message there seems to be a problem with the
>>>>>> 'curley-nil-on-bennet-spinoz' bibliography entry, is it possible that
>>>>>> it contains a 'year = nil' row? If yes then I don't think that is
>>>>>> well-formed, at least citeproc-el cannot currently parse it. Anyhow,
>>>>>> apparently I need to improve/add citeproc-el error messages about
>>>>>> bib(la)tex parsing, because several parsing problems have surfaced
>>>>>> lately and the current error messages aren't helpful at all.
>>>>>>
>>>>>> best wishes,
>>>>>> András
>>>>>>
>>>>>> On Wed, 1 Dec 2021 at 16:50, Joseph Vidal-Rosset
>>>>>> <joseph@vidal-rosset.net> wrote:
>>>>>>>
>>>>>>> Dear John,
>>>>>>>
>>>>>>> I must say that to export references in html with org-ref 3, I meet a
>>>>>>> lot of problems (with LaTeX, it's fine).
>>>>>>>
>>>>>>> I am using prelude emacs and  GNU Emacs 29.0.50 .
>>>>>>>
>>>>>>> Starting emacs --daemon, the code
>>>>>>>
>>>>>>> (let  ((org-export-before-parsing-hook 
>>>>>>> '(org-ref-csl-preprocess-buffer)))
>>>>>>>          (org-open-file  (org-html-export-to-html)))
>>>>>>>
>>>>>>> in my setup provokes this unwanting effect:
>>>>>>>
>>>>>>> [Prelude] Loading personal configuration files in
>>>>>>> /home/joseph/.emacs.d/personal/preload...
>>>>>>> Loading /home/joseph/.emacs.d/personal/preload/myorgexport.el 
>>>>>>> (source)...
>>>>>>> Output file:
>>>>>>>
>>>>>>> and with Enter :
>>>>>>>
>>>>>>> [Prelude] Loading personal configuration files in
>>>>>>> /home/joseph/.emacs.d/personal/preload...
>>>>>>> Loading /home/joseph/.emacs.d/personal/preload/myorgexport.el 
>>>>>>> (source)...
>>>>>>> Output file:
>>>>>>> Warning (initialization): An error occurred while loading
>>>>>>> ‘/home/joseph/.emacs.d/init.el’:
>>>>>>>
>>>>>>> Wrong type argument: stringp, nil
>>>>>>>
>>>>>>> To ensure normal operation, you should investigate and remove the
>>>>>>> cause of the error in your initialization file.  Start Emacs with
>>>>>>> the ‘--debug-init’ option to view a complete error backtrace. Disable
>>>>>>> showing Disable logging
>>>>>>> Starting Emacs daemon.
>>>>>>>
>>>>>>> With --debug-init, I get:
>>>>>>>
>>>>>>> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>>>>>>>        string-to-number(nil)
>>>>>>>        citeproc-bt--to-csl-date("nil" nil)
>>>>>>>        citeproc-blt-entry-to-csl((("Url" .
>>>>>>> "http://dx.doi.org/10.1163/9789004246638_005";) ("Doi" .
>>>>>>> "10.1163/9789004246638_005") ("Date_added" . "Mon May 16 19:09:37 2016")
>>>>>>> ("Booktitle" . "Spinoza: Issues and Directions") ("Series" . "Spinoza:
>>>>>>> Issues and Directions") ("Year" . "nil") ("Publisher" . "Brill Academic
>>>>>>> Publishers") ("Pages" . "39-52") ("Author" . "Edwin Curley") ("Title" .
>>>>>>> "ON BENNETTS SPINOZA: THE ISSUE OF TELEOLOGY") ("=type=" . "InBook")
>>>>>>> ("=key=" . "curley-nil-on-bennet-spinoz")) nil nil)
>>>>>>>        #f(compiled-function (key entry) #<bytecode
>>>>>>> -0x7fcb46b5c8e80b3>)("curley-nil-on-bennet-spinoz" (("Url" .
>>>>>>> "http://dx.doi.org/10.1163/9789004246638_005";) ("Doi" .
>>>>>>> "10.1163/9789004246638_005") ("Date_added" . "Mon May 16 19:09:37 2016")
>>>>>>> ("Booktitle" . "Spinoza: Issues and Directions") ("Series" . "Spinoza:
>>>>>>> Issues and Directions") ("Year" . "nil") ("Publisher" . "Brill Academic
>>>>>>> Publishers") ("Pages" . "39-52") ("Author" . "Edwin Curley") ("Title" .
>>>>>>> "ON BENNETTS SPINOZA: THE ISSUE OF TELEOLOGY") ("=type=" . "InBook")
>>>>>>> ("=key=" . "curley-nil-on-bennet-spinoz")))
>>>>>>>        maphash(#f(compiled-function (key entry) #<bytecode
>>>>>>> -0x7fcb46b5c8e80b3>) #<hash-table equal 665/730 0x156f8acb26b7>)
>>>>>>>        
>>>>>>> citeproc-hash-itemgetter-from-any(("~/Dropbox/Orgzly/reforg.bib"))
>>>>>>>        org-ref-process-buffer(html)
>>>>>>>        org-ref-csl-preprocess-buffer(html)
>>>>>>>        run-hook-with-args(org-ref-csl-preprocess-buffer html)
>>>>>>>        org-export-as(html nil nil nil (:output-file "~/test.html"))
>>>>>>>        org-export-to-file(html "~/test.html" nil nil nil nil nil)
>>>>>>>        org-html-export-to-html()
>>>>>>>        (org-open-file (org-html-export-to-html))
>>>>>>>        (let ((org-export-before-parsing-hook
>>>>>>> '(org-ref-csl-preprocess-buffer))) (org-open-file
>>>>>>> (org-html-export-to-html)))
>>>>>>>        eval-buffer(#<buffer  *load*-634240> nil
>>>>>>> "/home/joseph/.emacs.d/personal/preload/myorgexport..." nil t)  ;
>>>>>>> Reading at buffer position 3196
>>>>>>>
>>>>>>> load-with-code-conversion("/home/joseph/.emacs.d/personal/preload/myorgexport..."
>>>>>>> "/home/joseph/.emacs.d/personal/preload/myorgexport..." nil nil)
>>>>>>>        load("/home/joseph/.emacs.d/personal/preload/myorgexport...")
>>>>>>>        mapc(load 
>>>>>>> ("/home/joseph/.emacs.d/personal/preload/myorgexport..."))
>>>>>>>        (progn (message "[Prelude] Loading personal configuration files 
>>>>>>> in
>>>>>>> ..." prelude-personal-preload-dir) (mapc 'load (directory-files
>>>>>>> prelude-personal-preload-dir 't "^[^#.].*el$")))
>>>>>>>        (if (file-exists-p prelude-personal-preload-dir) (progn (message
>>>>>>> "[Prelude] Loading personal configuration files in ..."
>>>>>>> prelude-personal-preload-dir) (mapc 'load (directory-files
>>>>>>> prelude-personal-preload-dir 't "^[^#.].*el$"))))
>>>>>>>        eval-buffer(#<buffer  *load*> nil 
>>>>>>> "/home/joseph/.emacs.d/init.el" nil
>>>>>>> t)  ; Reading at buffer position 4489
>>>>>>>        load-with-code-conversion("/home/joseph/.emacs.d/init.el"
>>>>>>> "/home/joseph/.emacs.d/init.el" t t)
>>>>>>>        load("/home/joseph/.emacs.d/init" noerror nomessage)
>>>>>>>        startup--load-user-init-file(#f(compiled-function () #<bytecode
>>>>>>> 0xec639179d6199fa>) #f(compiled-function () #<bytecode
>>>>>>> -0x1f3c686ddc0dc635>) t)
>>>>>>>        command-line()
>>>>>>>        normal-top-level()
>>>>>>>
>>>>>>> It's too complicated for me.
>>>>>>> org-ref version 2 with citeproc-org by Andras worked well, but now I am
>>>>>>> afraid that to downgrade to org-ref 2 is not necessarily the best
>>>>>>> solution. I am lost.
>>>>>>>
>>>>>>> Best wishes, and thanks for your help.
>>>>>>>
>>>>>>> Jo.
>>>>>>>
>>>>>>>
>>>>>>> Le 30/11/2021 à 18:31, John Kitchin a écrit :
>>>>>>>> See https://www.youtube.com/watch?v=rRR-5NSpKyE
>>>>>>>> <https://www.youtube.com/watch?v=rRR-5NSpKyE> for an overview of what 
>>>>>>>> to
>>>>>>>> do. basically you need a csl file that provides the style you want, and
>>>>>>>> you specify it like this in the org file or in default settings. You 
>>>>>>>> may
>>>>>>>> also need a locale file if you are not blogging in english.
>>>>>>>>
>>>>>>>> #+csl-style: apa-5th-edition.csl
>>>>>>>>
>>>>>>>> #+csl-locale: en-US
>>>>>>>>
>>>>>>>>
>>>>>>>> You can find a basic example org file for html export with CSL at
>>>>>>>> https://github.com/jkitchin/org-ref/blob/master/examples/basic-csl.org
>>>>>>>> <https://github.com/jkitchin/org-ref/blob/master/examples/basic-csl.org>
>>>>>>>>
>>>>>>>> Here is a minimal way to export your blog file I suppose.
>>>>>>>>
>>>>>>>> (let  ((org-export-before-parsing-hook 
>>>>>>>> '(org-ref-csl-preprocess-buffer)))
>>>>>>>>        (org-open-file  (org-html-export-to-html)))
>>>>>>>>
>>>>>>>>
>>>>>>>> John
>>>>>>>>
>>>>>>>> -----------------------------------
>>>>>>>> Professor John Kitchin (he/him/his)
>>>>>>>> Doherty Hall A207F
>>>>>>>> Department of Chemical Engineering
>>>>>>>> Carnegie Mellon University
>>>>>>>> Pittsburgh, PA 15213
>>>>>>>> 412-268-7803
>>>>>>>> @johnkitchin
>>>>>>>> http://kitchingroup.cheme.cmu.edu <http://kitchingroup.cheme.cmu.edu>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Nov 30, 2021 at 12:16 PM András Simonyi
>>>>>>>> <andras.simonyi@gmail.com <mailto:andras.simonyi@gmail.com>> wrote:
>>>>>>>>
>>>>>>>>         Dear Joseph,
>>>>>>>>
>>>>>>>>         unfortunately, my note on the `citeproc-org` page has become 
>>>>>>>> kind of
>>>>>>>>         misleading and has to be updated because org-ref didn't switch 
>>>>>>>> to the
>>>>>>>>         new org-cite citation syntax after all, although this was the 
>>>>>>>> plan for
>>>>>>>>         a while. I think if you wish to use org-ref 3 then you should 
>>>>>>>> simply
>>>>>>>>         remove citeproc-org entirely -- if I understand correctly the 
>>>>>>>> latest
>>>>>>>>         version of org-ref supports the old syntax as well and is 
>>>>>>>> capable of
>>>>>>>>         CSL-based export (among others) on its own.
>>>>>>>>
>>>>>>>>         best regards,
>>>>>>>>         András
>>>>>>>>
>>>>>>>>         On Tue, 30 Nov 2021 at 18:00, Joseph Vidal-Rosset
>>>>>>>>         <joseph@vidal-rosset.net <mailto:joseph@vidal-rosset.net>> 
>>>>>>>> wrote:
>>>>>>>>          >
>>>>>>>>          >
>>>>>>>>          > Dear John, and dear Andras,
>>>>>>>>          >
>>>>>>>>          > Having updated my org-ref to the last version, I see that 
>>>>>>>> the html
>>>>>>>>          > export of bibliography does not work any longer for my blog.
>>>>>>>>          >
>>>>>>>>          > Reading Andras's note here
>>>>>>>>          > https://github.com/andras-simonyi/citeproc-org
>>>>>>>>         <https://github.com/andras-simonyi/citeproc-org>
>>>>>>>>          > I confess that I am lost.
>>>>>>>>          >
>>>>>>>>          > What have I to do to not waste too much time with this 
>>>>>>>> problem?
>>>>>>>>          >
>>>>>>>>          > Best wishes,
>>>>>>>>          >
>>>>>>>>          > Jo.
>>>>>>>>          >
>>>>>>>>
>>>>>>>
>>>>
>>>>
>>>> --
>>>> Professor John Kitchin
>>>> Doherty Hall A207F
>>>> Department of Chemical Engineering
>>>> Carnegie Mellon University
>>>> Pittsburgh, PA 15213
>>>> 412-268-7803
>>>> @johnkitchin
>>>> http://kitchingroup.cheme.cmu.edu
>>>> Pronouns: he/him/his
>>>>
>>
>> [2. text/x-emacs-lisp; myblogexporter.el]...
>
>
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
> Pronouns: he/him/his
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]