[PATCH] oc-csl: New custom option `org-cite-csl-sentence-case-bibtex-titles'

2024-05-11 Thread András Simonyi
Dear All,

since bibtex and biblatex requires title fields to be in title case
but CSL assumes that they are in sentence-case, citeproc-el converts
title fields in bib(la)tex bibliography databases into sentence-case
before processing them except for entries with an explicit non-English
langid value. Although this seems to be reasonable behaviour, there
were several requests in the last couple of years to make it possible
to turn this conversion off (see, e.g., citeproc issues  #119 and
#142). The attached patch introduces a new custom option to configure
when to perform the conversion.

I'm a bit unsure about naming the option:
Perhaps `org-cite-csl-sentence-case-bibtex-titles-without-langid'
would be more precise but I found it absurdly long and technical, as
most users are probably unaware of the existence of langid fields.

best wishes,
András
From 031428611c18bb4d97bbdbd11a7549ca2b96ccec Mon Sep 17 00:00:00 2001
From: Andras Simonyi 
Date: Sat, 11 May 2024 11:20:41 +0200
Subject: [PATCH] oc-csl: New custom option
 `org-cite-csl-sentence-case-bibtex-titles'

* lisp/oc-csl.el (org-cite-csl-sentence-case-bibtex-titles): New
variable.
(org-cite-csl--processor): Create the itemgetter using the new option.
* etc/ORG-NEWS (New option
~org-cite-csl-sentence-case-bibtex-titles~): Announce the change.
---
 etc/ORG-NEWS   |  9 +
 lisp/oc-csl.el | 18 +-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 36eeddda1..9ca71d0a2 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1128,6 +1128,15 @@ blocks that do not specify any ~:formatter~ parameter. Its default
 value (the new function ~org-columns-dblock-write-default~) yields the
 previous (fixed) formatting behaviour.
 
+*** New option ~org-cite-csl-sentence-case-bibtex-titles~
+
+When this option is non-nil then title fields in bibtex bibliography
+entries are converted to sentence-case before being formatted
+according to a CSL style, except for entries with a =langid= field
+specifying a non-English language.  When nil, this conversion is
+limited to entries having a =langid= field specifying a variant of
+English.  The defult value is ~t~.
+
 ** New features
 *** =ob-lua=: Support all types and multiple values in results
 
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 9bbe5e29d..7234174d0 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -321,6 +321,21 @@ in the bibliography measured in characters."
   :type 'string
   :package-version '(Org . "9.7"))
 
+(defcustom org-cite-csl-sentence-case-bibtex-titles t
+  "Convert bibtex title fields to sentence-case by default.
+
+When non-nil, title fields in bibtex bibliography entries are
+converted to sentence-case before being formatted according to a
+CSL style, except for entries with a `langid' field specifying a
+non-English language.
+
+When nil, this conversion is limited to entries having a `langid'
+field specifying a variant of English."
+  :group 'org-cite
+  :package-version '(Org . "9.7")
+  :type 'boolean
+  :safe #'booleanp)
+
 
 ;;; Internal variables
 (defconst org-cite-csl--etc-dir
@@ -584,7 +599,8 @@ property in INFO."
  (processor
   (citeproc-create
(org-cite-csl--style-file info)
-   (citeproc-hash-itemgetter-from-any bibliography)
+   (citeproc-hash-itemgetter-from-any
+bibliography (not org-cite-csl-sentence-case-bibtex-titles))
(org-cite-csl--locale-getter)
locale)))
 (plist-put info :cite-citeproc-processor processor)
-- 
2.34.1



Re: [PATCH] org-manual: Rewrite opening section in Citation handling

2024-05-10 Thread András Simonyi
Dear Ihor,

thanks for working on this, I agree that the current version,
especially the introduction, was too technical, so that is a  very
good direction to take. Some comments on the proposed changes:

> Org mode will gather citation metadata from =#+bibliography= database
> and use it to typeset the exported document in arbitrary formats.
> For example, below snippet shows ASCII export output.

Hopefully native speakers will chime in, but the phrase "below
snippet" sounds strange to me, I feel that "the snippet below"  would
be a better solution. Also, maybe a "the" could be inserted before
"=#+bibliography= database".

> Org mode ships with several built-in citation processors tailored to
> work with LaTeX export and BiBTeX bibliographies (=bibtex=,
> =biblatex=, and =natbib= processors), or with more generic Citation
> Style Language bibliographies (=csl= processor).

Perhaps the second part of the sentence would be a bit more precise
along the following lines:
"or with more generic bibliography and citation formats described
using/in the Citation Style Language (=csl= processor)"
and maybe "Citation Style Language" could link to the CSL site
https://citationstyles.org/.

> The default citation processor is =basic= - it works with arbitrary
> export formats and recognized both BiBTeX and CSL bibliographies.

Here I think there is a typo as "recognized" should be "recognizes".

> At least one =PRINT_BIBLIOGRAPHY= keyword must be present in the
> document to render citations on export.

That is not true in general, as the csl processor and most probably
some others too can render citations without a bibliography; there are
even citation styles (typically, note-based ones) that are designed to
work without a bibliography and specify all bibliographic data in
citations. Because of this I suggest removing or at least rewriting
this sentence.

best wishes,
András

On Mon, 6 May 2024 at 10:44, Ihor Radchenko  wrote:
>
> Hi,
>
> The current version of Citation handling section of the manual is rather
> technical. I tried to rewrite it aiming for ordinary users not familiar
> with Org mode internals.
>
> Please, let me know if it reads better.
>
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: [PATCH] oc-csl: Remove spaces before citations in superscript

2024-05-05 Thread András Simonyi
Thanks Ihor, I have pushed it to main.
best wishes,
András

On Sun, 5 May 2024 at 14:13, Ihor Radchenko  wrote:
>
> András Simonyi  writes:
>
> > there is a rather peculiar set of numeric citation styles (perhaps
> > most famously, that of Nature's) which sets citation numbers in
> > superscript -- similarly to footnote numbers, these citations should
> > not have any space between them and the previous word. The attached
> > patch checks during export whether a citation is produced by a CSL
> > style belonging to this category and removes any leading space
> > present.
>
> LGTM.
> Feel free to push.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>



[PATCH] oc-csl: Remove spaces before citations in superscript

2024-05-05 Thread András Simonyi
Dear All,

there is a rather peculiar set of numeric citation styles (perhaps
most famously, that of Nature's) which sets citation numbers in
superscript -- similarly to footnote numbers, these citations should
not have any space between them and the previous word. The attached
patch checks during export whether a citation is produced by a CSL
style belonging to this category and removes any leading space
present.

Best wishes,
András
From fe331b9486d4bac31a559067c565b30474246cea Mon Sep 17 00:00:00 2001
From: Andras Simonyi 
Date: Sun, 5 May 2024 11:07:45 +0200
Subject: [PATCH] oc-csl: Remove spaces before citations in superscript

* lisp/oc-csl.el (org-cite-csl--create-structure): Remove spaces before citation
if it is in superscript.
(org-cite-csl--style-cite-superscript-p): New function to check whether the used
CSL style produces citations in superscript.
---
 lisp/oc-csl.el | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index becdaed81..9bbe5e29d 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -134,6 +134,7 @@
 (declare-function citeproc-render-bib "ext:citeproc")
 (declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
 (declare-function citeproc-add-subbib-filters "ext:citeproc")
+(declare-function citeproc-style-cite-superscript-p "ext:citeproc")
 
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-map "org-element" (data types fun  info first-match no-recursion with-affiliated))
@@ -435,6 +436,13 @@ INFO is the export state, as a property list."
(citeproc-proc-style
 (org-cite-csl--processor info
 
+(defun org-cite-csl--style-cite-superscript-p (info)
+  "Non-nil when bibliography style produces citations in superscript.
+INFO is the export state, as a property list."
+  (citeproc-style-cite-superscript-p
+   (citeproc-proc-style
+(org-cite-csl--processor info
+
 (defun org-cite-csl--nocite-p (citation info)
   "Non-nil when CITATION object's style is nocite.
 INFO is the export state, as a property list."
@@ -681,6 +689,9 @@ INFO is the export state, as a property list."
 (when (and (not footnote) (org-cite-csl--note-style-p info))
   (org-cite-adjust-note citation info)
   (setq footnote (org-cite-wrap-citation citation info)))
+;; Remove white space before CITATION when it is in superscript.
+(when (org-cite-csl--style-cite-superscript-p info)
+  (org-cite--set-previous-post-blank citation 0 info))
 ;; Return structure.
 (apply #'citeproc-citation-create
`(:note-index
-- 
2.34.1



Re: Question about citation formatting

2024-03-27 Thread András Simonyi
Dear All,

On Wed, 27 Mar 2024 at 04:17, Christian Wittern  wrote:

> This paper is discussing and comparing translations to the same text. So
> when I mention publications in the text, I want to have the keyword to
> be the translator, rather than the author.

I think your best bet is modifying (the citation part of) the CSL
style you are using. The format is well documented (see
https://docs.citationstyles.org/en/stable/specification.html) and
there is even an online visual CSL editor
(https://editor.citationstyles.org/visualEditor/).

best wishes,
András



Re: Basic citations: should default citation style have a name and style code?

2024-01-14 Thread András Simonyi
Dear All,

On Sun, 14 Jan 2024 at 06:39, William Denton  wrote:

> > While we're talking about citations, I'm stuck on something else. If I run 
> > "C-c C-x @" to insert a citation into a file, I'm shown a list of 
> > bibliography entries and I can go up and down and hit RET on any I chose. 
> > That works well. But---the prompt says, "Key (empty input exits)." What 
> > makes empty input? I can't figure it out.

I'm not an active Ivy user (although I was in the past) but now I
tried it out with the basic cite-insert processor and  "C-u C-j" seems
to be working as "empty input".

best wishes,
András



Re: A small contribution to the doc

2023-12-24 Thread András Simonyi
Dear All,

On Sun, 24 Dec 2023 at 19:12, Ihor Radchenko  wrote:
>
> Pedro Andres Aranda Gutierrez  writes:
>
> > Just to submit a small addition to the org-mode documentation. This not
> > being the best of times, I would have needed this pointer,
>
> Thanks!
> Applied, onto main, adding a commit message.

just out of curiosity: isn't the "backend=biber" option unnecessary,
as the default backend of biblatex is biber?

best wishes,
András



Re: Citation bug with print_bibliography :filter "keyword phrase" with spaces

2023-11-26 Thread András Simonyi
Dear All,

On Thu, 23 Nov 2023 at 17:54, William Denton  wrote:

> I think I've found another bug with citations, this time about filtering on
> keywords when printing bibliographies with the CSL processor.  Either that
> or I'm wrong about how it works.

Thanks for reporting, I've managed to reproduce the problem and it
turned out to be a citeproc-el bug,
which is now fixed in the master branch. The updated version should be
available in MELPA soonish.

best wishes,
András

> Here's a test .bib file; note the "keyword phrase" keywords.  Filtering 
> doesn't
> work on them.
>
> Test.bib:
>
>@article{article1,
>  title = {Title Here},
>  author = {Denton, William},
>  date = {2020-01-01},
>  journaltitle = {Journal Title},
>  issue = {1},
>  keywords = {keyword phrase}
>}
>
>@article{article2,
>  title = {Title Here Too},
>  author = {Denton, William},
>  date = {2023-11-01},
>  journaltitle = {Journal Title Too},
>  issue = {2},
>  keywords = {keyword phrase}
>}
>
>@book{book1,
>  title = {Mastering Emacs},
>  author = {Petersen, Mickey},
>  date = {2022},
>  keywords = {emacs}
>  }
>
>
> And here's an Org file.  For exporting I'm using CSL, referring to a style in 
> my
> Zotero directory.  Any Zotero user will have this, but I don't know how to 
> make
> it easily reproducible for others.
>
> ### - Org file starts
>
> #+bibliography: Test.bib
>
> #+cite_export: csl ~/Zotero/styles/chicago-author-date.csl
>
> * Text
>
> One article: [cite:@article1].  Another article: [cite:@article2].  And a 
> real book: [cite:@book1].
>
> * Everything
>
> #+print_bibliography:
>
> * Emacs
>
> #+print_bibliography: :keyword emacs
>
> * Keyword phrase
>
> #+print_bibliography: :keyword "keyword phrase"
>
> ### -- Org file ends
>
> When exported to LaTeX, the complete bibliography and the Emacs bibliography 
> are
> there, but the "keyword phrase" one isn't.  The manual says, "Values including
> spaces must be surrounded with double quotes."  I did that, but based on this 
> it
> doesn't seem to be working.
>
> (I'm running Org from the development branch.)
>
> Bill
>
> --
> William Denton
> https://www.miskatonic.org/
> Librarian, artist and licensed private investigator.
> Toronto, Canada
> CO₂: 421.56 ppm (Mauna Loa Observatory, 2023-11-22)



Re: [BUG] HTML-export citation suffix rendering with CSL [9.6 (9.6-??-bed47b437 @ /home/romeo/.emacs.d/.local/straight/build-28.2.50/org/)]

2023-02-28 Thread András Simonyi
Dear All,

On Wed, 25 Jan 2023 at 12:53, Ihor Radchenko  wrote:
> Confirmed, after replacing the .bib key with 
> abnarQuantifyingAttentionFlow2020a.
>
> András, may you take a look?

First of all, apologies for reacting that late, unfortunately, I've
had way less time to work on Org-mode and citeproc related problems
than I'd have wished or expected. I've managed to look into the issue
now and merged two PRs (#137 and #138) into citeproc-el's main branch
which should fix Problem 1.

As for the second problem, this is more difficult, because in this
case the behavior is along the expected lines:
the org-cite suffix ", Thm. 1" is further parsed by oc-csl into the
prefix ", Thm. " and the locator "1", with the implicit label "page".
If the used CSL style doesn't use a rendered label for pages (like
Chicago author-date) than an (admittedly ugly) workaround is to use an
explicit "page" label, that is,
[cite:@abnarQuantifyingAttentionFlow2020a page Thm. 1] is rendered as
(Abdar et al. 2021, Thm. 1) in Chicago.

We might want to change parsing to automatically parse everything as
CSL suffix if the org-cite suffix starts with a comma, but before
considering that I'd like to raise issue of treating Theorem/Thm. and
similar terms (Lemma etc.) as valid CSL locator labels in their own
right, which would be, I think, a more principled solution. I don't
know whether this was considered by CSL developers (CC-ing Bruce and
Denis).

best wishes,
András

> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: Hiding citations

2023-02-27 Thread András Simonyi
Dear All,

On Sat, 25 Feb 2023 at 18:19, M. ‘quintus’ Gülker
 wrote:

> Not yet, and it certainly looks nice, but the CSL style I use uses
> footnotes, and those are quite verbose. Rendering them (or rather, their
> content) into the text would expand it even more.

there is no assumption that the CSL style used for rendering should be
identical to the one used for export,
in fact, the default is just to use Chicago author-date. I typically
use it with an even more compressed author-date style.

best wishes,
András

>   -quintus
>
> --
> Dipl.-Jur. M. Gülker | https://mg.guelker.eu | PGP: Siehe Webseite
> Passau, Deutschland  | kont...@guelker.eu| O<
>



Re: [PATCH][oc-csl] Improve reference parsing

2023-01-25 Thread András Simonyi
Dear All,

On Thu, 19 Jan 2023 at 11:15, M. ‘quintus’ Gülker
 wrote:

> That is, the macro has to work both in a citation and in> normal text. Even 
> if a @@csl: construct would be ignored in normal text,> I cannot see how to 
> write the macro then, because something like
>
> #+MACRO: name @@csl:$1latex:\textsc{$1}html: class="name">$1@@
>
> would still transfer the @@latex: and @@html: constructs into the
> footnote. They would have to be expressly ignored by the citation
> processor.

If we take the approach I suggested the macro definition you suggested
should work correctly both for LaTeX and HTML export combined with the
CSL citation processor, because in the case of citation locators and
affixes Citeproc would receive only the output produced by the planned
CSL ox backend, which would remove the non-CSL export snippets and
keep only the content of the csl snippet.  Citeproc would parse the
produced text into the appropriate
small-caps CSL representation and then format the citation with
small-caps using the Citeproc formatter corresponding to the export
format.

best wishes,
András

>
>   -quintus
>
> --
> Dipl.-Jur. M. Gülker | https://mg.guelker.eu | PGP: Siehe Webseite
> Passau, Deutschland  | kont...@guelker.eu| O<



Re: [PATCH] oc-natbib: Provide a fallback bibliography style

2023-01-25 Thread András Simonyi
Dear All,

On Wed, 25 Jan 2023 at 16:10, Ihor Radchenko  wrote:

> If we do not specify a bibliography style, LaTeX export will fail.
> With the attached patch, the following simple-minded Org document will
> export without errors:

Thanks, I think that is an important improvement -- when I tried the
natbib exporter I expected it to do
something sensible without specifying a style.

> Also, should we provide some commonly available natbib styles in the
> defcustom?

What would this look like?

best wishes,
András



Re: Patch for \usepackage[ ... natbib = true ...]{...biblatex} with org-cite

2023-01-22 Thread András Simonyi
Dear All,

On Sun, 22 Jan 2023 at 12:15, Ihor Radchenko  wrote:

> Also, note that `org-cite-biblatex--package-options' combines INITIAL
> option list from the \usepackage declaration already present with
> options dictated by STYLE. However, only certain options are considered.
> After applying your patch, things may be broken in this area.

There is also the customizable variable `org-cite-biblatex-options' to
pass additional options,
which could be used with #bind+ if document-specific options are needed.

best wishes,
András

> P.S. Could you please send patches as plain text? They are easier to
> view then.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>



Re: [PATCH][oc-csl] Improve reference parsing

2023-01-19 Thread András Simonyi
Dear All,

On Thu, 19 Jan 2023 at 09:35, M. ‘quintus’ Gülker
 wrote:

> I am not sure this targets the usecase I am pursuing, which is to use
> macros to produce @@latex: escape constructs in order to have small-caps
> markup in the citation footnotes:
>
> #+MACRO: name @@latex:\textsc{$1}html:$1@@
>
> If the macro resolves, but the @@latex construct does not, that would be
> problematic.

hopefully somebody more knowledgeable than me can comment on how
viable this is, but would a @@csl like export snippet construct help
with the problem?
In that case your macro could be along the lines of

#+MACRO: name @@csl:$1@@

and -- assuming the custom export backend approach I proposed in the
patch -- we would only need to make sure that the inline @@csl export
snippets are exported as is by this "csl"  backend.

best wishes,
András



Re: [PATCH][oc-csl] Improve reference parsing

2023-01-18 Thread András Simonyi
Dear All,

apologies for replying that late. If I understand the situation
correctly, we could handle the question of allowing macros in
citations independently of the handling of other constructs, because
macros are resolved before processing citations, so they have no
effect on the input of Citeproc-el.  In light of this, maybe there
could be a separate patch for just allowing macros?

As for the question of other elements, I proposed the custom
backend-based approach because CSL has its own rich-text markup (which
is actually not simply a subset of Org's, for example, it contains
small-caps, which is not in Org), and, consequently, Citeproc-el has
its own internal rich-text representations (ASTs), on which it
performs the operations that are prescribed by the various CSL styles.
When the rich text citation/bibliography is finalized, it can be
"serialized" or "formatted" (analogously to Org's exporting a parse
tree) using one of the Citeproc formatters, e.g. into LaTeX, HTML or
Org. As the prefix, suffix and the locator also need to be operated on
by the processor (concatenated to other rich text elements etc.,),
they also have to be parsed into CIteproc el's internal rich-text
representations. Since this is a given, the only question is in what
format should they be passed, and the simple HTML-like standard which
is already supported by Citeproc-el (see
https://www.zotero.org/support/kb/rich_text_bibliography) seems to be
the simplest solution.

Ihor Radchenko  wrote:
> Could you please explain in more details why CSL require special
> export of the prefix/suffix? What will happen if we simply pass the Org
> markup verbatim?

Since Citeproc-el assumes that all formatting in the prefix/suffix is
in the HTML-like markup mentioned above, any Org markup would be
treated as plain text which should be preserved as is, and not
interpreted as formatting, so, for example, when an Org document with
underlined text in a citation prefix were exported to LaTeX then the
Citeproc LaTeX formatter would escape the underscore characters ("\_")
to preserve them in the output and the citation would be inserted in
this form into the resulting LaTeX document.

> I am asking because org-cite-csl-render-citation uses
> org-cite-parse-objects so, unless citeproc does something terrible with
> the original Org syntax, we can re-parse the output string and export
> appropriately according to the current export backend.

See above, unfortunately, this wouldn't work, at least not in a
general and safe way.

best wishes,
András


On Sun, 15 Jan 2023 at 09:56, Ihor Radchenko  wrote:
>
> M. ‘quintus’ Gülker  writes:
>
> > I probably have not much to contribute to this rather technical thread,
> > but Ihor has redirected me here two times for my citation formatting
> > questions[1][2]. So I would like to ask if there is something I can do to
> > accelerate its inclusion into org so that I can start using macros in
> > citations?
>
> András is the author of citeproc.el. I am not sure who else would be in
> position to help us to move this forward.
>
> My understanding of CSL is non-existing. I can only tell that
> citeproc.el has its own implementation of citation export
> (`citeproc-render-citations'), which expects some limited kind of html
> as input. I am hoping that we can somehow work around limited markup
> support of citeproc's implementation and instead leverage ox.el to do
> the job. Otherwise, we will keep stumbling upon citeproc.el limitations
> when exporting bibliography items.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: Org-cite (oc-csl) tip: Filtering bibliography for language

2023-01-18 Thread András Simonyi
Dear All,

first of all, sorry for replying that late.

On Tue, 20 Dec 2022 at 11:46, Christian Moe  wrote:
> Arbitrary sexps would give us more flexibility. Alternately, one could
> achieve more or less the same by letting :filter collect any additional
> arguments and pass them as  to the user's predicate function,
> something like:
>
>   #+PRINT_BIBLIOGRAPHY: :filter bibitem-lang-p nb nn no :type article

I like this proposal a lot -- it seems to strike a good balance with
regard to safety and flexibility.
I'll try to make the required changes on the citeproc-el side and then
propose a patch here.

> Alternatively, I think there is a case for adding a user-friendly
> :language property to the print_bibliography keyword. On my bookshelf it
> vies with primary/secondary sources as the most common criterion for
> separate bibliographies.

> I was going to say that this is the only extension I can think of that
> is needed beside :(not)(csl)type and :(not)keyword, but of course people
> are sooner or later going to want easy-to-use properties to filter by
> author, publication date ranges, and probably other criteria I cannot
> think of right now, so it's a strategic decision for the maintainer(s)
> if you want to go that way. :-)

this is also a useful suggestion, although with the added difficulty
of having to support both
bib(la)tex and csl-json, which use, I think, different sets of language codes.

best wishes,
András

> Yours,
> Christian



Re: [PATCH] oc-csl: Improve LaTeX bibliography formatting

2022-12-29 Thread András Simonyi
Dear All,

On Thu, 29 Dec 2022 at 11:14, Ihor Radchenko  wrote:
> LGTM!
> Feel free to push upstream.

thanks Ihor, I've pushed the changes to main as commit
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=29103fc60
best wishes,
András



Re: [PATCH] oc-csl: Improve LaTeX bibliography formatting

2022-12-27 Thread András Simonyi
Dear All,
I have attached a new version of the patch with added ascii "illustrations".
best wishes,
András

On Tue, 13 Dec 2022 at 20:03, András Simonyi  wrote:
>
> Dear All,
>
> On Tue, 13 Dec 2022 at 17:07, Timothy  wrote:
>
> > Perhaps an ASCII approximation in an example block could work? Even if it’s
> > exaggerated to give the idea.
>
> yes, I'm also thinking of first trying to produce something in ASCII
> as the docstring will probably need it anyway,
> and we can think about the image version afterwards -- it might turn
> out that the text version is already sufficient for the news (and
> maybe later on for the manual).
>
> best wishes,
> András
>
> > All the best,
> > Timothy
> >
> > --
> > Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
> > Learn more about Org mode at <https://orgmode.org/>.
> > Support Org development at <https://liberapay.com/org-mode>,
> > or support my work at <https://liberapay.com/tec>.
From 2bdbb02901b9831f3bb6b3d29ff8050eadd69e46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Tue, 27 Dec 2022 23:15:34 +0100
Subject: [PATCH] oc-csl: Improve LaTeX bibliography formatting

* lisp/oc-csl.el (org-cite-csl--output-format): Use the dedicated
'org-latex' citeproc formatter to export references in LaTeX.
(org-cite-csl-latex-preamble, org-cite-csl--generate-latex-preamble,
org-cite-csl-finalizer): Insert a preamble fragment compatible with
the 'org-latex' citeproc formatter.
(org-cite-csl-latex-label-separator,
org-cite-csl-latex-label-width-per-char): Introduce additional
variables to control bibliography formatting.

* etc/ORG-NEWS: Describe the introduced new options.
---
 etc/ORG-NEWS   |  27 +
 lisp/oc-csl.el | 145 +++--
 2 files changed, 155 insertions(+), 17 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index d4e9b4368..1185a51b2 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -13,6 +13,33 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
 * Version 9.7 (not released yet)
 ** New options
+*** New custom settings for the "csl" citation export processor's LaTeX output
+
+The settings ~org-cite-csl-latex-label-separator~ and
+~org-cite-csl-latex-label-width-per-char~ allow the user to control
+the indentation of entries for labeled bibliography styles when the
+"csl" citation processor is used for LaTeX export.  The indentation
+length is computed as the sum of ~org-cite-csl-latex-label-separator~
+and the maximal label width, for example:
+
+#+begin_example
+indentation length
+<->
+max. label width  separator
+<---><>
+[Doe22]John Doe. A title...
+[DoeSmithJones19]  John Doe, Jane Smith and...
+[SmithDoe02]   Jane Smith and John Doe...
+#+end_example
+
+The maximal label width, in turn, is calculated as the product of
+~org-cite-csl-latex-label-width-per-char~ and the maximal label length
+measured in characters.
+
+The setting ~org-cite-csl-latex-preamble~ makes it possible to
+customize the entire LaTeX fragment that the "csl" citation processor injects
+into the preamble.
+
 *** New ~org-latex-listings-src-omit-language~ customization for LaTeX export
 
 The ~org-latex-listings-src-omit-language~ customization variable
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 1ccb74e92..11194b9b4 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -214,6 +214,111 @@ Used only when `second-field-align' is activated by the used CSL style."
   :type 'string
   :safe #'stringp)
 
+(defcustom org-cite-csl-latex-label-separator "0.6em"
+  "Distance between citation label and bibliography item for LaTeX
+output in valid LaTeX units.  Used only when `second-field-align'
+is activated by the used CSL style.
+
+The indentation length in these cases is computed as the sum of
+`org-cite-csl-latex-label-separator' and the maximal label width,
+for example,
+
+indentation length
+<->
+max. label width  separator
+<---><>
+[Doe22]John Doe. A title...
+[DoeSmithJones19]  John Doe, Jane Smith and...
+[SmithDoe02]   Jane Smith and John Doe...
+
+The maximal label width, in turn, is calculated as the product of
+`org-cite-csl-latex-label-width-per-char' and the maximal label
+length measured in characters."
+  :group 'org-cite
+  :package-version '(Org . "9.7")
+  :type 'string
+  :safe #'stringp)
+
+(defcustom org-cite-csl-latex-label-width-per-char "0.45em"
+  "Character width in LaTeX units for calculating entry label widths.
+Used only when `second-field-align' is activated by the used CSL
+style.
+
+See the documentation of `org-cite-csl-latex-label-separator' for
+detail

Re: Org-cite (oc-csl) tip: Filtering bibliography for language

2022-12-20 Thread András Simonyi
On Tue, 20 Dec 2022 at 09:22, Denis Maier  wrote:

> allowing lambda expressions would
> probably be quicker to implement, and it would also allow for predicates
> not anticipated by DSL designers.

Yes, on the other hand, we will have to be very careful with regard to
security if we choose this route, treating filters basically as elisp
source code blocks.

András



Re: Org-cite (oc-csl) tip: Filtering bibliography for language

2022-12-19 Thread András Simonyi
... I've forgotten to add that another (probably more user friendly)
option would be to design and implement some kind of  filtering DSL.

András

On Mon, 19 Dec 2022 at 23:05, András Simonyi  wrote:
>
> Dear All,
>
> On Mon, 19 Dec 2022 at 15:49, Christian Moe  wrote:
>
> > Refinements welcome. I'm especially wondering what would be an elegant
> > way to generalize this for more languages without defining a predicate
> > for each language (given that we cannot pass the language as an
> > additional argument in the print_bibliography line).
>
> Thanks for describing this usage! As for the problem of generalizing
> to more languages, one relatively simple solution would be to allow
> arbitrary sexps as filters. Then one could write something like
>
> #+print_bibliography: :filter (lambda (item) (bibitem-has-language item 
> "en")))
>
> Would this type of extension be helpful? One (not necessarily
> important)  consequence would be that filters of this type would be
> obviously unusable with the biblatex exporter.
>
> best wishes,
> András



Re: Org-cite (oc-csl) tip: Filtering bibliography for language

2022-12-19 Thread András Simonyi
Dear All,

On Mon, 19 Dec 2022 at 15:49, Christian Moe  wrote:

> Refinements welcome. I'm especially wondering what would be an elegant
> way to generalize this for more languages without defining a predicate
> for each language (given that we cannot pass the language as an
> additional argument in the print_bibliography line).

Thanks for describing this usage! As for the problem of generalizing
to more languages, one relatively simple solution would be to allow
arbitrary sexps as filters. Then one could write something like

#+print_bibliography: :filter (lambda (item) (bibitem-has-language item "en")))

Would this type of extension be helpful? One (not necessarily
important)  consequence would be that filters of this type would be
obviously unusable with the biblatex exporter.

best wishes,
András



Re: [PATCH] oc-csl: Improve LaTeX bibliography formatting

2022-12-13 Thread András Simonyi
Dear All,

On Tue, 13 Dec 2022 at 17:07, Timothy  wrote:

> Perhaps an ASCII approximation in an example block could work? Even if it’s
> exaggerated to give the idea.

yes, I'm also thinking of first trying to produce something in ASCII
as the docstring will probably need it anyway,
and we can think about the image version afterwards -- it might turn
out that the text version is already sufficient for the news (and
maybe later on for the manual).

best wishes,
András

> All the best,
> Timothy
>
> --
> Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at .



Re: [PATCH] oc-csl: Improve LaTeX bibliography formatting

2022-12-12 Thread András Simonyi
Dear All,

On Mon, 12 Dec 2022 at 10:07, Ihor Radchenko  wrote:

> Would it be possible
> to provide an example of bibliography output and how it is affected by
> the new custom variables?
> In the news, it could be example image indicating the distances,

Hm, I tried to find an image in the ORG-NEWS file and even in the
Manual but couldn't find any, so I'm
unsure how to do this in concrete terms (where to put the embedded
image file etc.). Is there an example
I could follow?

thanks & best wishes,
András

> in the docstrings you can schematically indicate the spacings using text
> example.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: [PATCH] oc-csl: Improve LaTeX bibliography formatting

2022-12-11 Thread András Simonyi
Dear All,

first of all, apologies for the delay, unfortunately, I haven't been
able to work on my WIP patches for a while. Now I've attached a new
version of the patch, which hopefully addresses all issues discussed
earlier.

best wishes,
András

On Tue, 8 Nov 2022 at 06:26, Ihor Radchenko  wrote:
>
> András Simonyi  writes:
>
> >> Also, it would be nice to describe CSL usage and tweaks in the manual.
> >
> > Time permitting I may try to add something, but wouldn't it be a
> > problem if the CSL export processor was discussed in much more detail
> > than the others?
> > I was also thinking about providing a list of available citation
> > substyles but I do not want to make the manual very unbalanced.
>
> Maybe not in the release, but otherwise we need to finish the citation
> section of the manual one way or another. May as well start from CSL
> part.
>
> >> I have two comments here:
> >> 1. Where are all these new commands coming from? They are not used
> >>directly in the code. Are you tweaking citeproc.el output this way? May
> >>it be better to use customizations provided by citeproc.el itself?
> >
> > Yes, the citeproc org-latex formatter, which I added specifically for
> > Org, uses these commands in the LaTeX code produced for the
> > bibliography. As citeproc doesn't have customizable variables by
> > design (if I recall correctly, the only exception is 2 hooks), and
> > oc-csl already had some variables concerned with very similar
> > formatting settings (org-cite-csl-latex-hanging-indent,
> > org-cite-csl-html-hanging-indent,
> > org-cite-csl-html-label-width-per-char) I think it is more consistent
> > to have the new ones also in Org.
>
> Thanks for the clarification. I'd prefer to see a similar explanation
> and the details about what the LaTeX variables/commands do in the
> docstring.
>
> >> 2. You are declaring this variable as defcustom, but it is not clear
> >>what is going to happen if the user changes it. It is not how to
> >>change this template in meaningful ways either.
> >
> > Right, I can try to detail a bit in the docstring what type of
> > commands and environments have to be provided by the preamble (are
> > expected by citeproc). I tried to follow Timothy's handling of the
> > ox-latex engraved preamble, but a simpler alternative would be to
> > treat it simply as a constant template, at least for the time being --
> > WDYT?
>
> Note that `org-latex-engraved-preamble' explains which packages need to
> be loaded and which commands need to be defined in the preamble. This at
> least make it more clear what the users may change and not break the
> export.
>
> I see not problem keeping this a defcustom, but we definitely need to
> explain the default value and what is required to be in there. At least,
> to make the code readable for future contributors.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
From 7f02881ff1ef9c3dd3eca0cd63a91936dcb90a45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Sun, 11 Dec 2022 18:03:39 +0100
Subject: [PATCH] oc-csl: Improve LaTeX bibliography formatting

* lisp/oc-csl.el (org-cite-csl--output-format): Use the dedicated
'org-latex' citeproc formatter to export references in LaTeX.
(org-cite-csl-latex-preamble, org-cite-csl--generate-latex-preamble,
org-cite-csl-finalizer): Insert a preamble fragment compatible with
the 'org-latex' citeproc formatter.
(org-cite-csl-latex-label-separator,
org-cite-csl-latex-label-width-per-char): Introduce additional
variables to control bibliography formatting.

* etc/ORG-NEWS: Describe the introduced new options.
---
 etc/ORG-NEWS   |  11 +
 lisp/oc-csl.el | 126 ++---
 2 files changed, 120 insertions(+), 17 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 5d5e726e0..6441cdc1f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -12,6 +12,17 @@ See the end of the file for license conditions.
 Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
 * Version 9.7 (not released yet)
+
+** New options
+*** New custom settings for the "csl" citation export processor's LaTeX output
+
+The settings ~org-cite-csl-latex-label-separator~ and
+~org-cite-csl-latex-label-width-per-char~ allow the user to control
+the horizontal positioning of entry labels for labeled bibliography
+styles, and the setting ~org-cite-csl-latex-preamble~ makes it
+possible to customize the entire fragment that is injected into the
+preamble when 

Re: [PATCH] oc-csl: Improve LaTeX bibliography formatting

2022-11-07 Thread András Simonyi
Dear All,

On Mon, 7 Nov 2022 at 03:47, Ihor Radchenko  wrote:

>  Please, document the new customization in ORG-NEWS.

Dear Ihor, thanks for the comments! I'm going to update the NEWS file
shortly in a new version of the patch.

> Also, it would be nice to describe CSL usage and tweaks in the manual.

Time permitting I may try to add something, but wouldn't it be a
problem if the CSL export processor was discussed in much more detail
than the others?
I was also thinking about providing a list of available citation
substyles but I do not want to make the manual very unbalanced.

> I have two comments here:
> 1. Where are all these new commands coming from? They are not used
>directly in the code. Are you tweaking citeproc.el output this way? May
>it be better to use customizations provided by citeproc.el itself?

Yes, the citeproc org-latex formatter, which I added specifically for
Org, uses these commands in the LaTeX code produced for the
bibliography. As citeproc doesn't have customizable variables by
design (if I recall correctly, the only exception is 2 hooks), and
oc-csl already had some variables concerned with very similar
formatting settings (org-cite-csl-latex-hanging-indent,
org-cite-csl-html-hanging-indent,
org-cite-csl-html-label-width-per-char) I think it is more consistent
to have the new ones also in Org.

> 2. You are declaring this variable as defcustom, but it is not clear
>what is going to happen if the user changes it. It is not how to
>change this template in meaningful ways either.

Right, I can try to detail a bit in the docstring what type of
commands and environments have to be provided by the preamble (are
expected by citeproc). I tried to follow Timothy's handling of the
ox-latex engraved preamble, but a simpler alternative would be to
treat it simply as a constant template, at least for the time being --
WDYT?

best wishes,
András

> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



[PATCH] oc-csl: Improve LaTeX bibliography formatting

2022-11-06 Thread András Simonyi
Dear All,

the attached patch substantially improves the formatting of CSL-based
bibliographies in LaTeX export by supporting in-style formatting
settings that were previously ignored, most importantly,
'second-field-align', which is typically used for numeric styles such
as ieee.csl.

I'm sending this while another oc-csl patch (about affix and locator
formatting) is still under discussion because I consider it a priority
for the 9.6 release. (Not supporting those formatting settings
rendered a large number of styles, some of them pretty popular, close
to being unusable.)

Thanks in advance for your feedback!

best wishes,
András
From bc92683a6326e7f97093b401caf453a76b76ba46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Sun, 2 Oct 2022 19:20:36 +0200
Subject: [PATCH] oc-csl: Improve LaTeX bibliography formatting

* lisp/oc-csl.el (org-cite-csl--output-format): Use the dedicated
'org-latex' citeproc formatter to export references in LaTeX.
(org-cite-csl-latex-preamble, org-cite-csl--generate-latex-preamble,
org-cite-csl-finalizer): Insert a preamble fragment compatible with
the 'org-latex' citeproc formatter.
(org-cite-csl-latex-label-separator,
org-cite-csl-latex-label-width-per-char): Introduce additional
variables to control bibliography formatting.
---
 lisp/oc-csl.el | 98 ++
 1 file changed, 83 insertions(+), 15 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 1ccb74e92..1807efaea 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -214,6 +214,68 @@ Used only when `second-field-align' is activated by the used CSL style."
   :type 'string
   :safe #'stringp)
 
+(defcustom org-cite-csl-latex-label-separator "0.6em"
+  "Distance between citation label and bibliography item for LaTeX
+output in valid LaTeX units.  Used only when `second-field-align'
+is activated by the used CSL style."
+  :group 'org-cite
+  :package-version '(Org . "9.6")
+  :type 'string
+  :safe #'stringp)
+
+(defcustom org-cite-csl-latex-label-width-per-char "0.45em"
+  "Character width in LaTeX units for calculating entry label widths.
+Used only when `second-field-align' is activated by the used CSL
+style."
+  :group 'org-cite
+  :package-version '(Org . "9.6")
+  :type 'string
+  :safe #'stringp)
+
+;; The following was inspired by and mostly follows how Pandoc's
+;; () default LaTeX template handles
+;; CSL output.  Many thanks to the author, John MacFarlane!
+(defcustom org-cite-csl-latex-preamble
+  "\\usepackage{calc}
+\\newlength{\\cslhangindent}
+\\setlength{\\cslhangindent}{[CSL-HANGINDENT]}
+\\newlength{\\csllabelsep}
+\\setlength{\\csllabelsep}{[CSL-LABELSEP]}
+\\newlength{\\csllabelwidth}
+\\setlength{\\csllabelwidth}{[CSL-LABELWIDTH-PER-CHAR] * [CSL-MAXLABEL-CHARS]}
+\\newenvironment{citeprocbib}[2] % 1st arg. is hanging-indent, 2nd entry spacing.
+ {% By default, paragraphs are not indented.
+  \\setlength{\\parindent}{0pt}
+  % Hanging indent is turned on when first argument is 1.
+  \\ifodd #1
+  \\let\\oldpar\\par
+  \\def\\par{\\hangindent=\\cslhangindent\\oldpar}
+  \\fi
+  % Set entry spacing based on the second argument.
+  \\setlength{\\parskip}{\\parskip +  #2\\baselineskip}
+ }%
+ {}
+\\newcommand{\\cslblock}[1]{#1\\hfill\\break}
+\\newcommand{\\cslleftmargin}[1]{\\parbox[t]{\\csllabelsep + \\csllabelwidth}{#1}}
+\\newcommand{\\cslrightinline}[1]
+  {\\parbox[t]{\\linewidth - \\csllabelsep - \\csllabelwidth}{#1}\\break}
+\\newcommand{\\cslindent}[1]{\\hspace{\\cslhangindent}#1}
+\\makeatletter
+\\newcommand{\\citeprocitem}[2]
+ {\\protect\\hyper@linkstart{cite}{citeproc_bib_item_#1}#2\\hyper@linkend}
+\\makeatother"
+  "LaTeX preamble content inserted by the `csl' citation processor.
+
+The placeholders [CSL-HANGINDENT], [CSL-LABELSEP],
+[CSL-LABELWIDTH-PER-CHAR] and [CSL-MAXLABEL-CHARS] are replaced,
+respectively, by the contents of the customizable variables
+`org-cite-csl-latex-hanging-indent', `org-cite-csl-latex-label-separator',
+`org-cite-csl-latex-label-width-per-char', and the maximal label length
+in the bibliography measured in characters."
+  :group 'org-cite
+  :type 'string
+  :package-version '(Org . "9.6"))
+
 
 ;;; Internal variables
 (defconst org-cite-csl--etc-dir
@@ -413,7 +475,7 @@ corresponding to one of the output formats supported by Citeproc: `html',
   (let ((backend (plist-get info :back-end)))
 (cond
  ((org-export-derived-backend-p backend 'html) 'html)
- ((org-export-derived-backend-p backend 'latex) 'latex)
+ ((org-export-derived-backend-p backend 'latex) 'org-latex)
  (t 'org
 
 (defun org-cite-csl--style-file (info)
@@ -670,6 +732,21 @@ value is the bibliography as rendered by Citeproc."
 (plist-put info :cite-citeproc-rendered-bibliographies result)
 result)
 
+(defun org-cite-csl--generate-latex-preamble (info)
+  "Generate the CSL-related part of the LaTeX preamble.
+INFO is the export state, as a 

Re: [PATCH][oc-csl] Improve reference parsing

2022-11-02 Thread András Simonyi
Dear All,

On Wed, 2 Nov 2022 at 07:28, Ihor Radchenko  wrote:

> I do not think that CSL limitations are really limiting us.
>
> - Allowing macros will be handled by ox.el itself automatically
> - Export snippets can also be processed without much issue (consider
>   direct LaTeX code)
> - inline-babel-call and inline src blocks may be useful with :exports
>   results when some auto-generation of text is needed. They will also be
>   handled automatically by ob-exp.
> - latex-fragments are either equivalent to direct LaTeX or to inserting
>   an image
> - timestamps could be exported as text, although I do not see any
>   obvious utility of timestamps inside references.

I'm not really familiar with the internals of the Org exporter but,
looking at the ox.el code, macros and babel calls are processed and
resolved before processing citations, so they seemingly have no
bearing on the org-cite-csl--parse-reference function my patch is
concerned with.

> However, oc-csl should not ignore the export processor to support all
> the above. I am not sure why you need a dedicated export processor
> instead of passing the string to current processor (or derivative)
> instead.

> If you really need to mark certain constructs specially for CSL, you can
> create a derived export backend for the current backend and replace the
> transcoders for the object types that must be treated specially.

Other than macros and babel calls, e.g., timestamps, LaTeX  fragments
etc. the problem is that citeproc-el expects and needs the affixes and
locator to be passed in the very limited html-like markup supported by
CSL (see https://www.zotero.org/support/kb/rich_text_bibliography for
a rudimentary description), and, crucially, the assumption is that
everything else is plain text, which, if necessary, will be escaped
according to the target format, i.e., '$' signs are escaped by
citeproc-el's own LaTeX formatter. The reason for this limitation is
that the affixes and especially the locator have to be parsed into
citeproc-el's internal rich-text representation for further processing
according to the used CSL style. (Affixes are only concatenated to
other elements but locators can be the subject of any type of
formatting.)  As a consequence, I think the only real alternatives are
using a custom backend as I do in the current patch or a backend
derived from the plain text Org exporter -- I don't have a strong
preference as to which solution we choose, just went with the
seemingly more minimalist option. (The proper way of dealing with
LaTeX fragments in this context, in particular with LaTeX math
fragments, would be to support those in citeproc-el's internal
representation and markup, which is planned but not implemented yet.)

> > +(defconst org-cite-csl--export-backend
> > +  (org-export-create-backend
> > +   :transcoders
> > +   '((bold . (lambda (_bold contents _info) (format "%s" contents)))
> > + (code . org-cite-csl--element-value)
> > + (entity . (lambda (entity _contents _info)
> > + (format "\\%s" (org-element-property :name entity
>
> Why :name, but not :html?

Good point, thinking about it a bit more, :utf-8 would probably be a
slightly better solution (in keeping with citeproc-el's 'plain text'
requirement), I'will change this when we will have sorted out the
other details.

best wishes,
András



Re: [PATCH][oc-csl] Improve reference parsing

2022-11-01 Thread András Simonyi
Dear All,

On Thu, 27 Oct 2022 at 06:10, Ihor Radchenko  wrote:
> This will render e.g. strike-through empty.
> Note that citation references may contain the following Org markup objects:
> '(bold code entity italic
>   latex-fragment strike-through subscript
>   superscript underline verbatim)

thanks for pointing out the problem!! I've attached a new version of
the patch, in which the custom exporter backend has an (in many cases
trivial) translator for all currently allowed objects.

> And we may add more, as discussed in
> https://orgmode.org/list/87k04xhhw3.fsf@localhost

I don't think that it would make much sense to add a lot more, with
the possible exception of links, since citations are at most
sentence-sized textual units, not to mention the possible
complications arising for the existing export processors. (What type
of objects could the various LaTeX-based exporters support without
complex changes?)  Since CSL has only a few types of formatting
attributes (font-style, font-variant, font-weight, text-decoration and
vertical-align), if the set of allowed object is radically expanded
then it will probably be more reasonable to define a derived backed,
maybe based on the ascii exporter, but I feel that the current set
doesn't require this solution.

thanks & best wishes,
András

>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
From 5dfbb8ef9291f906014800013cdb9a9d5569b728 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Wed, 26 Oct 2022 12:15:42 +0200
Subject: [PATCH] oc-csl.el: Improve reference parsing

* lisp/oc-csl.el (org-cite-csl--export-backend): New constant to
provide a trivial export back-end for exporting reference affixes and
locators with the simple html-based markup expected by citeproc.
(org-cite-csl--parse-reference): Do not construct the reference
locator and include it in the result, since citeproc does not make use
of it.  Start the suffix immediately after the locator's ending,
skipping the ending comma if necessary.  Use
`org-cite-csl--export-backend' to export reference affixes and
locators.
---
 lisp/oc-csl.el | 57 +++---
 1 file changed, 40 insertions(+), 17 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 1ccb74e92..1f40a9e8a 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -140,9 +140,10 @@
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-put-property "org-element" (element property value))
 
-(declare-function org-export-data "org-export" (data info))
+(declare-function org-export-data-with-backend "org-export" (data backend info))
 (declare-function org-export-derived-backend-p "org-export" (backend  backends))
 (declare-function org-export-get-footnote-number "org-export" (footnote info  data body-first))
+(declare-function org-export-create-backend "org-export" ( transcoders))
 
 
 ;;; Customization
@@ -310,8 +311,30 @@ If nil then the Chicago author-date style is used as a fallback.")
   "Regexp matching a label in a citation reference suffix.
 Label is in match group 1.")
 
+(defconst org-cite-csl--export-backend
+  (org-export-create-backend 
+   :transcoders
+   '((bold . (lambda (_bold contents _info) (format "%s" contents)))
+ (code . org-cite-csl--element-value)
+ (entity . (lambda (entity _contents _info)
+ (format "\\%s" (org-element-property :name entity
+ (italic . (lambda (_italic contents _info) (format "%s" contents)))
+ (latex-fragment . org-cite-csl--element-value)
+ (plaintext . (lambda (contents _info) contents))
+ (strike-through . (lambda (_strike-through contents _info) contents))
+ (subscript . (lambda (_subscript contents _info) (format "%s" contents)))
+ (superscript . (lambda (_superscript contents _info) (format "%s" contents)))
+ (underline . (lambda (_underline contents _info)
+(format "%s" contents)))
+ (verbatim . org-cite-csl--element-value)))
+  "Custom backend for exporting citation affixes and locators.")
+
 
 ;;; Internal functions
+(defun org-cite-csl--element-value (element _contents _info)
+  "Return the`:value' property of ELEMENT."
+  (org-element-property :value element))
+
 (defun org-cite-csl--barf-without-citeproc ()
   "Raise an error if Citeproc library is not loaded."
   (unless (featurep 'citeproc)
@@ -476,11 +499,10 @@ property in INFO."
 INFO is the export state, as a property list.
 
 The result is a association list.  Keys are: `id', `prefix',`suffix',
-`location', `locator' and `label'."
-  (let (label location-start locator-start location locator prefix suffix)
+`locator' and `label'."
+  (let (label location-start locator-start locator prefix suffix)
 ;; Parse suffix.  Insert it in a temporary buffer to 

Re: Formatting in citation locator

2022-10-26 Thread András Simonyi
Dear All,

On Tue, 25 Oct 2022 at 13:16, Ihor Radchenko  wrote:
> Maybe file a bug report to citeproc repo?

I've ended up making the necessary changes in citeproc and also posted
a patch here which should enable formatting in locators. Marvin, I'd
appreciate it if you could test it.

best wishes,

András

On Tue, 25 Oct 2022 at 13:16, Ihor Radchenko  wrote:
>
> András Simonyi  writes:
>
> >> No. It is some bug in org-cite-csl--create-structure.
> >> I am CCing the oc-csl maintainer.
> >> András, can you please take a look?
> >
> > first of all, apologies for reacting that late. I had a look now, and
> > the reason of the behaviour is not an oc-csl bug, but rather a
> > citeproc-el limitation: formatting is not supported in locators, so if
> > present it is passed in an unparsed form through the processor and it
> > depends on the used citeproc output formatter what happens to it
> > during finalization. In practice, Org markup seems to go through
> > unchanged when the citeproc output format is set to Org. As a
> > consequence, a possible workaround for making the html export work
> > with formatted locators is to circumvent the citeproc-el html
> > formatter by exporting the Org document first to Org and then the
> > result to html. Of course, this solution might lose some advanced html
> > formatting produced by directly using citeproc such as small caps or
> > style-specific bibliography indentation.
>
> Maybe file a bug report to citeproc repo?
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>



[PATCH][oc-csl] Improve reference parsing

2022-10-26 Thread András Simonyi
Dear All,

the attached patch improves the parsing and exporting of cite
prefixes, suffixes and locators -- the most noticeable change is
probably the  support for formatted locators and of underlining in
general.  Comments are welcome.

best wishes,
András
From 5bec7025f66eb65f13a701dc616aca2440110c1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Wed, 26 Oct 2022 12:15:42 +0200
Subject: [PATCH] oc-csl.el: Improve reference parsing

* lisp/oc-csl.el (org-cite-csl--export-backend): New constant to
provide a trivial export back-end for exporting reference affixes and
locators with the simple html-based markup expected by citeproc.
(org-cite-csl--parse-reference): Do not construct the reference
locator and include it in the result, since citeproc does not make use
of it.  Start the suffix immediately after the locator's ending,
skipping the ending comma if necessary.  Use
`org-cite-csl--export-backend' to export reference affixes and
locators.
---
 lisp/oc-csl.el | 45 -
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 1ccb74e92..30eac9f1a 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -140,9 +140,10 @@
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-put-property "org-element" (element property value))
 
-(declare-function org-export-data "org-export" (data info))
+(declare-function org-export-data-with-backend "org-export" (data backend info))
 (declare-function org-export-derived-backend-p "org-export" (backend  backends))
 (declare-function org-export-get-footnote-number "org-export" (footnote info  data body-first))
+(declare-function org-export-create-backend "org-export" ( transcoders))
 
 
 ;;; Customization
@@ -310,6 +311,16 @@ If nil then the Chicago author-date style is used as a fallback.")
   "Regexp matching a label in a citation reference suffix.
 Label is in match group 1.")
 
+(defconst org-cite-csl--export-backend
+  (org-export-create-backend
+   :transcoders
+   '((plain-text . (lambda (text _info) text))
+ (bold . (lambda (_bold contents _info) (concat "" contents "")))
+ (italic . (lambda (_italic contents _info) (concat "" contents "")))
+ (underline . (lambda (_underline contents _info)
+		(concat "" contents "")
+  "Custom backend for exporting citation affixes and locators.")
+
 
 ;;; Internal functions
 (defun org-cite-csl--barf-without-citeproc ()
@@ -476,11 +487,10 @@ property in INFO."
 INFO is the export state, as a property list.
 
 The result is a association list.  Keys are: `id', `prefix',`suffix',
-`location', `locator' and `label'."
-  (let (label location-start locator-start location locator prefix suffix)
+`locator' and `label'."
+  (let (label location-start locator-start locator prefix suffix)
 ;; Parse suffix.  Insert it in a temporary buffer to find
-;; different parts: pre-label, label, locator, location (label +
-;; locator), and suffix.
+;; different parts: pre-label, label, locator, and suffix.
 (with-temp-buffer
   (save-excursion
 (insert (org-element-interpret-data
@@ -506,12 +516,15 @@ The result is a association list.  Keys are: `id', `prefix',`suffix',
 (let ((re (rx (or "," (group digit)
   (when (re-search-backward re location-start t)
 (goto-char (or (match-end 1) (match-beginning 0)))
-(setq location (buffer-substring location-start (point)))
-(setq locator (org-trim (buffer-substring locator-start (point
+(setq locator
+  (org-cite-parse-objects
+   (buffer-substring locator-start (point))
+   t))
 ;; Skip comma in suffix.
+(when (= (following-char) ?,) (forward-char))
 (setq suffix
   (org-cite-parse-objects
-   (buffer-substring (match-end 0) (point-max))
+   (buffer-substring (point) (point-max))
t)
   (setq prefix
 (org-cite-concat
@@ -525,18 +538,16 @@ The result is a association list.  Keys are: `id', `prefix',`suffix',
(lambda (data)
  (org-string-nw-p
   (org-trim
-   ;; When Citeproc exports to Org syntax, avoid mix and
-   ;; matching output formats by also generating Org
-   ;; syntax for prefix and suffix.
-   (if (eq 'org (org-cite-csl--output-format info))
-   (org-element-interpret-data data)
- (org-export-data data info)))
+   ;; Export the parsed prefix, suffix, and locator  
+   ;; with a custom backend, which produces the simple
+   ;; html markup expected by citeproc.
+   (org-export-data-with-backend
+data org-cite-csl--export-backend info))
   `((id . 

Re: [BUG] [ox-odt] Missing spaces around formatted spans and links

2022-10-25 Thread András Simonyi
Dear Ihor,
thanks a lot for the super-quick fix!
best wishes,
András

On Wed, 26 Oct 2022 at 06:35, Ihor Radchenko  wrote:
>
> András Simonyi  writes:
>
> > using the most recent version of the main branch I've noticed some
> > problems with the spacing of documents exported with the odt exporter:
> > spaces around links and formatted (for instance, italicized) words are
> > missing, for example, the  Org line
> >
> > text1 https://orgmode.org/ text2 /italics/
> >
> > is exported without spaces between text1 and the link and text2 and
> > the italicized word.
> >
> > I've not tested this extensively but my impression is that the bug was
> > introduced by commit
> > 3502ce2db: ox-odt: Fix newlines replaced by spaces in Han script.
> > (I'm using Emacs 28.2.)
>
> Thanks for the heads up!
> Fixed on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=bb40848458512fc26ffa47d20807e3cd0211ccad
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>



[BUG] [ox-odt] Missing spaces around formatted spans and links

2022-10-25 Thread András Simonyi
Dear All,

using the most recent version of the main branch I've noticed some
problems with the spacing of documents exported with the odt exporter:
spaces around links and formatted (for instance, italicized) words are
missing, for example, the  Org line

text1 https://orgmode.org/ text2 /italics/

is exported without spaces between text1 and the link and text2 and
the italicized word.

I've not tested this extensively but my impression is that the bug was
introduced by commit
3502ce2db: ox-odt: Fix newlines replaced by spaces in Han script.
(I'm using Emacs 28.2.)

Thanks & best regards,
András



Re: Formatting in citation locator

2022-10-25 Thread András Simonyi
Dear All,

On Thu, 20 Oct 2022 at 07:23, Ihor Radchenko  wrote:
> M. ‘quintus’ Gülker  writes:
> > Thanks for the hint, but it does not work still even if I change the
> > line to contain the said zero-width space:
> > The buffer is now fontified as expected, but it does not work when
> > exported to HTML:
> No. It is some bug in org-cite-csl--create-structure.
> I am CCing the oc-csl maintainer.
> András, can you please take a look?

first of all, apologies for reacting that late. I had a look now, and
the reason of the behaviour is not an oc-csl bug, but rather a
citeproc-el limitation: formatting is not supported in locators, so if
present it is passed in an unparsed form through the processor and it
depends on the used citeproc output formatter what happens to it
during finalization. In practice, Org markup seems to go through
unchanged when the citeproc output format is set to Org. As a
consequence, a possible workaround for making the html export work
with formatted locators is to circumvent the citeproc-el html
formatter by exporting the Org document first to Org and then the
result to html. Of course, this solution might lose some advanced html
formatting produced by directly using citeproc such as small caps or
style-specific bibliography indentation.

Best wishes,
András



Maintaining oc-csl

2022-08-13 Thread András Simonyi
Dear All,

I'd like to volunteer to maintain oc-csl.el, which currently doesn't
have an official maintainer as far as I can tell. As the author and
maintainer of citeproc-el and the author of oc-csl's precursor,
citeproc-org, I think I'm reasonably well positioned to handle issues
and make improvements.

thanks for your consideration & best wishes,
András



Re: [RFC PATCH] oc-csl: Add support for title, locators and bibentry styles

2022-08-13 Thread András Simonyi
Dear All,

On Tue, 9 Aug 2022 at 17:38, Rudolf Adamkovič  wrote:

> THANK YOU for working on this!  I have tried the "locators" style, and
> it works great.  At last, we can write in the APA style with no hacks!

thanks for your kind words, I'm glad that you find the additions useful.

> P.S.  Not a fan of using "ti" for the title.  I would go for "T" for
> "Title", or "p" for "publication", or "s" for "subject", or something
> like that.

interesting, it didn't occur to me that we could use capital letters
as well, certainly an alternative to consider.
Another solution could be to make the whole mapping customizable as
it's done, I think, in the case of  the biblatex export processor.

best wishes,
András



Re: org-cite-insert + fido-mode

2022-08-12 Thread András Simonyi
Could you try Alt-j?

best wishes,
András

On Sat, 13 Aug 2022 at 03:22, Tyler Grinn  wrote:
>
> "Bruce D'Arcus"  writes:
>
> > You need to use whatever keybinding exits.
>
> I've tried every key in the mode map.
>



[PATCH] oc-csl: Add missing function declaration

2022-08-09 Thread András Simonyi
Dear All,

I've just noticed that there was a missing citeproc function
declaration in oc-csl.el which could cause a compiler warning. The
attached patch adds the required declaration.

best wishes,
András
From e2573d8c858a280922f1dd13d2c49de9b74a9ec1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Tue, 9 Aug 2022 14:47:10 +0200
Subject: [PATCH] oc-csl: Add missing function declaration

* lisp/oc-csl.el (citeproc-add-subbib-filters): Declare function.
---
 lisp/oc-csl.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index c8e61a599..8f88999ef 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -128,6 +128,7 @@
 (declare-function citeproc-render-citations "ext:citeproc")
 (declare-function citeproc-render-bib "ext:citeproc")
 (declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
+(declare-function citeproc-add-subbib-filters "ext:citeproc")
 
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-map "org-element" (data types fun  info first-match no-recursion with-affiliated))
-- 
2.25.1



Re: [RFC PATCH] oc-csl: Add support for title, locators and bibentry styles

2022-08-08 Thread András Simonyi
Dear All,

On Sun, 7 Aug 2022 at 11:45, Ihor Radchenko  wrote:

> LGTM in general, but please add a proper commit message.
[...]
> Also, it would be useful to explain a bit what bibentry stands for.

thanks, I've attached a new patch implementing these recommendations.

best wishes,
András
From 361e78eca47d2a6472064ae37d43e9c1e131faa3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Tue, 2 Aug 2022 11:32:17 +0200
Subject: [PATCH] oc-csl: Add support for title, locators and bibentry citation
 styles

* lisp/oc-csl.el: Register the newly added citation styles "title",
"locators and "bibentry" as supported by the "csl" export processor.
(org-cite-csl--create-structure-params): Add support for the creation
of citation structures with the new citation styles.
---
 lisp/oc-csl.el | 31 +++
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 0b2fe5c41..7fcc1f1f2 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -61,11 +61,16 @@
 ;; - noauthor (na), including bare (b), caps (c) and bare-caps (bc) variants,
 ;; - nocite (n),
 ;; - year (y), including a bare (b) variant,
-;; - text (t). including caps (c), full (f), and caps-full (cf) variants,
+;; - text (t), including caps (c), full (f), and caps-full (cf) variants,
+;; - title (ti), including a bare (b) variant,
+;; - locators (l), including a bare (b) variant,
+;; - bibentry (b), including a bare (b) variant,
 ;; - default style, including bare (b), caps (c) and bare-caps (bc) variants.
 ;;
-;; Using "*" as a key in a nocite citation includes all available items in
-;; the printed bibliography.
+;; Using "*" as a key in a nocite citation includes all available
+;; items in the printed bibliography.  The "bibentry" citation style,
+;; similarly to biblatex's \fullcite, creates a citation which is
+;; similar to the bibliography entry.
 
 ;; CSL styles recognize "locator" in citation references' suffix.  For example,
 ;; in the citation
@@ -349,6 +354,21 @@ a property list."
(pcase variant
 	 ((or "bare" "b") '(:mode year-only :suppress-affixes t))
 	 (_ '(:mode year-only
+  ;; "bibentry" style
+  (`(,(or "bibentry" "b") . ,variant)
+   (pcase variant
+	 ((or "bare" "b") '(:mode bib-entry :suppress-affixes t))
+	 (_ '(:mode bib-entry
+  ;; "locators" style
+  (`(,(or "locators" "l") . ,variant)
+   (pcase variant
+	 ((or "bare" "b") '(:mode locator-only :suppress-affixes t))
+	 (_ '(:mode locator-only
+  ;; "title" style
+  (`(,(or "title" "ti") . ,variant)
+   (pcase variant
+	 ((or "bare" "b") '(:mode title-only :suppress-affixes t))
+	 (_ '(:mode title-only
   ;; "text" style.
   (`(,(or "text" "t") . ,variant)
(pcase variant
@@ -730,7 +750,10 @@ property list."
 (("year" "y") ("bare" "b"))
 (("text" "t") ("caps" "c") ("full" "f") ("caps-full" "cf"))
 (("nil") ("bare" "b") ("caps" "c") ("bare-caps" "bc"))
-(("nocite" "n"
+(("nocite" "n"))
+(("title" "ti") ("bare" "b"))
+(("bibentry" "b") ("bare" "b"))
+(("locators" "l") ("bare" "b"
 
 (provide 'oc-csl)
 ;;; oc-csl.el ends here
-- 
2.25.1



[RFC PATCH] oc-csl: Add support for title, locators and bibentry styles

2022-08-02 Thread András Simonyi
Dear All,

the attached patch adds support for three new citation styles which
recently got supported by citeproc-el:

- cite/title or cite/ti to cite only the title of an item,
- cite/locators or cite/l to cite only the locators, and
- cite/bibentry or cite/b to cite the full bibliography entry.

I put "RFC" in the subject because I'm not entirely sure about naming
the "bibentry" style, since "bibentry" is natbib terminology, I think,
and biblatex's corresponding command is \fullcite, but I find
"bibentry" slightly more adequate. Also, do we need the "ti"
abbreviation for the "title" style?

thanks and best wishes,
András
From 09b3619693cf4979212d828a0452741e00fca8a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Tue, 2 Aug 2022 11:32:17 +0200
Subject: [PATCH] oc-csl: Add support for title, locators and bibentry citation
 styles

---
 lisp/oc-csl.el | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 0b2fe5c41..d84c97e69 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -61,7 +61,10 @@
 ;; - noauthor (na), including bare (b), caps (c) and bare-caps (bc) variants,
 ;; - nocite (n),
 ;; - year (y), including a bare (b) variant,
-;; - text (t). including caps (c), full (f), and caps-full (cf) variants,
+;; - text (t), including caps (c), full (f), and caps-full (cf) variants,
+;; - title (ti), including a bare (b) variant,
+;; - locators (l), including a bare (b) variant,
+;; - bibentry (b), including a bare (b) variant,
 ;; - default style, including bare (b), caps (c) and bare-caps (bc) variants.
 ;;
 ;; Using "*" as a key in a nocite citation includes all available items in
@@ -349,6 +352,21 @@ a property list."
(pcase variant
 	 ((or "bare" "b") '(:mode year-only :suppress-affixes t))
 	 (_ '(:mode year-only
+  ;; "bibentry" style
+  (`(,(or "bibentry" "b") . ,variant)
+   (pcase variant
+	 ((or "bare" "b") '(:mode bib-entry :suppress-affixes t))
+	 (_ '(:mode bib-entry
+  ;; "locators" style
+  (`(,(or "locators" "l") . ,variant)
+   (pcase variant
+	 ((or "bare" "b") '(:mode locator-only :suppress-affixes t))
+	 (_ '(:mode locator-only
+  ;; "title" style
+  (`(,(or "title" "ti") . ,variant)
+   (pcase variant
+	 ((or "bare" "b") '(:mode title-only :suppress-affixes t))
+	 (_ '(:mode title-only
   ;; "text" style.
   (`(,(or "text" "t") . ,variant)
(pcase variant
@@ -730,7 +748,10 @@ property list."
 (("year" "y") ("bare" "b"))
 (("text" "t") ("caps" "c") ("full" "f") ("caps-full" "cf"))
 (("nil") ("bare" "b") ("caps" "c") ("bare-caps" "bc"))
-(("nocite" "n"
+(("nocite" "n"))
+(("title" "ti") ("bare" "b"))
+(("bibentry" "b") ("bare" "b"))
+(("locators" "l") ("bare" "b"
 
 (provide 'oc-csl)
 ;;; oc-csl.el ends here
-- 
2.25.1



Re: [PATCH] oc-csl: Add support for sub-bibliographies

2022-08-02 Thread András Simonyi
Dear All,

On Sun, 31 Jul 2022 at 04:32, Ihor Radchenko  wrote:

> Can we then change the oc-biblatex et al defaults to output
> \printbibliography[heading=none]
> ?
>
> Best,
> Ihor

unfortunately, IUC, for bibtex suppressing the heading requires the
(possibly local) redefinition of some commands, e.g.
\thebibliography or \section which I find too intrusive.  For natbib
there seems to be a similar situation regarding \bibsection. Because
of this I think it'd be more viable to change the "csl" and "basic"
processors to produce a section heading by default and provide options
to set the title and depth or to suppress it, even if this breaks some
extensions/configurations. (BTW, the predecessor of oc-csl,
citeproc-org added a section heading and org-ref might be doing so
too.)

best wishes,
András



Re: [PATCH] oc-csl: Add support for sub-bibliographies

2022-07-29 Thread András Simonyi
Dear All,

On Fri, 29 Jul 2022 at 03:32, Ihor Radchenko  wrote:

> This is an important point. I think that we should describe this gotcha
> in the "Bibliography printing". oc-basic and oc-csl just print the list
> of bibliography entries, while oc-bibtex/oc-natbib/oc-biblatex insert a
> separate section. It is a very important information and users should be
> aware of it.

I agree, so I've attached a new version in which a sentence is added
about this difference in behaviour.

Also, this is kind of annoying - this way mixing oc-bibtex
> and oc-basic for LaTeX and non-LaTeX export gets awkward.

Yes, in the long run we might want to unify the behaviour of the
processors in this respect. OTOH changing "basic" and "csl" to
automatically print a heading would be a breaking change, e.g., AFAIK,
ox-hugo currently adds a heading on its own when org-cite is used for
bibliography printing with the "csl" processor.

best wishes,
András

> Best,
> Ihor
From b765d8bd65ece076041b8c280c0a7f076a376338 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Thu, 28 Jul 2022 22:50:26 +0200
Subject: [PATCH] * doc/org-manual.org: Document "PRINT_BIBLIOGRAPHY" options

---
 doc/org-manual.org | 63 +-
 1 file changed, 62 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 596ab3723..9ec49c14e 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16818,11 +16818,72 @@ conformant to the Harvard style and the specification of the
 Wolkers-Kluwer publisher; since it relies on the ~bibtex~ processor of
 your LaTeX installation, it won't export to anything but PDF.
 
+** Bibliography printing
+
 The =PRINT_BIBLIOGRAPHY= keyword specifies where the bibliography
-should print.
+should be printed (note the colon):
 
 : #+print_bibliography:
 
+The bibliography printed by the LaTeX-based export processors
+"bibtex", "natbib" and "biblatex" has a chapter or section heading by
+default, while the "basic" and "csl" processors print the list of
+bibliography entries without a heading.
+
+A document may contain more than one =PRINT_BIBLIOGRAPHY= keywords.
+Each of the keywords will trigger printing the bibliography.
+
+The keywords can be used with or without additional options.  Options
+can be used, for example, to print only entries that belong to a
+certain category or to control formatting.  The set of supported
+=PRINT_BIBLIOGRAPHY= options and their interpretation varies between
+the different citation export processors.  Some export processors do
+not support passing options.
+
+*** Bibliography options in the "biblatex" and "csl" export processors
+
+The "biblatex" and "csl" export processors support bibliography
+options through a property list attached to the =PRINT_BIBLIOGRAPHY=
+keyword.  For example,
+
+: #print_bibliography: :keyword algebra :type book
+
+Values including spaces must be surrounded with double quotes.  If you
+need to use a key multiple times, you can separate its values with
+commas, but without any space in-between:
+
+: #print_bibliography: :keyword "algebraic logic" :nottype article,book
+
+The "biblatex" export processor accepts all options supported by
+BibLaTeX's ~\printbibliography~ command, while the "csl" processor
+accepts the following ones:
+
+- =:keyword = :: Print only entries whose
+  keyword field contains all given keywords.
+
+- =:notkeyword = :: Print only entries whose
+  keyword field does not contain any of the given keywords.
+
+- =:type = :: Print only entries whose type is
+  ==.  Entry type is the BibTeX/BibLaTeX entry type if this
+  information is available (the entry was read from a BibTeX/BibLaTeX
+  bibliography) and the CSL entry type otherwise.
+
+- =:nottype = :: Print only entries whose
+  type is not among the given entry types.  Entry type is determined
+  as in the case of =:type=.
+
+- =:csltype = :: Print only entries whose CSL entry type
+  (possibly based on a conversion from BibTeX/BibLaTeX to CSL) is
+  ==.
+
+- =:notcsltype = :: Print only entries whose
+  CSL entry type (possibly based on a conversion from BibTeX/BibLaTeX
+  to CSL) is not among the listed entry types.
+
+- =:filter = :: Print only entries for which the given
+  Emacs Lisp predicate returns a non-~nil~ value.
+
 * Working with Source Code
 :PROPERTIES:
 :DESCRIPTION: Export, evaluate, and tangle code blocks.
-- 
2.25.1



Re: [PATCH] oc-csl: Add support for sub-bibliographies

2022-07-28 Thread András Simonyi
Dear All,

On Tue, 26 Jul 2022 at 07:37, Ihor Radchenko  wrote:
> I am also a non-native speaker, so lets obey the Bruce's judgment.
...
> > yes :title is not supported by the "csl" processor. Should we perhaps
> > replace the example with another one using a multi-word keyword, like

I've attached a new version of the patch with
- "Bibliography printing" as the subsection title,
- an added "the" in the subsubsection title "Bibliography options in
the "biblatex" and "csl" export processors",
- an improved example.

> Though I am wondering why csl does not support :title. It feels like a
> natural thing to have.

The biblatex "title" option is for changing the title of the
bibliography section which is created and printed out by biblatex by
default.
In contrast to the LaTeX-based export processors, the "csl"  and  the
"basic" export processors print out only the list of entries, and it's
up to the user to manually include a bibliography section heading in
the document if they want one, so the "title" option is not really
applicable, at least not in the same way.

best wishes,
András
From 89af0b909b8d16486a488470c5f9dd2d185379b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Thu, 28 Jul 2022 22:50:26 +0200
Subject: [PATCH] * doc/org-manual.org: Document "PRINT_BIBLIOGRAPHY" options

---
 doc/org-manual.org | 58 +-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 596ab3723..c740750a2 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16818,11 +16818,67 @@ conformant to the Harvard style and the specification of the
 Wolkers-Kluwer publisher; since it relies on the ~bibtex~ processor of
 your LaTeX installation, it won't export to anything but PDF.
 
+** Bibliography printing
+
 The =PRINT_BIBLIOGRAPHY= keyword specifies where the bibliography
-should print.
+should be printed (note the colon):
 
 : #+print_bibliography:
 
+A document may contain more than one =PRINT_BIBLIOGRAPHY= keywords.
+Each of the keywords will trigger printing the bibliography.
+
+The keywords can be used with or without additional options.  Options
+can be used, for example, to print only entries that belong to a
+certain category or to control formatting.  The set of supported
+=PRINT_BIBLIOGRAPHY= options and their interpretation varies between
+the different citation export processors.  Some export processors do
+not support passing options.
+
+*** Bibliography options in the "biblatex" and "csl" export processors
+
+The "biblatex" and "csl" export processors support bibliography
+options through a property list attached to the =PRINT_BIBLIOGRAPHY=
+keyword.  For example,
+
+: #print_bibliography: :keyword algebra :type book
+
+Values including spaces must be surrounded with double quotes.  If you
+need to use a key multiple times, you can separate its values with
+commas, but without any space in-between:
+
+: #print_bibliography: :keyword "algebraic logic" :nottype article,book
+
+The "biblatex" export processor accepts all options supported by
+BibLaTeX's ~\printbibliography~ command, while the "csl" processor
+accepts the following ones:
+
+- =:keyword = :: Print only entries whose
+  keyword field contains all given keywords.
+
+- =:notkeyword = :: Print only entries whose
+  keyword field does not contain any of the given keywords.
+
+- =:type = :: Print only entries whose type is
+  ==.  Entry type is the BibTeX/BibLaTeX entry type if this
+  information is available (the entry was read from a BibTeX/BibLaTeX
+  bibliography) and the CSL entry type otherwise.
+
+- =:nottype = :: Print only entries whose
+  type is not among the given entry types.  Entry type is determined
+  as in the case of =:type=.
+
+- =:csltype = :: Print only entries whose CSL entry type
+  (possibly based on a conversion from BibTeX/BibLaTeX to CSL) is
+  ==.
+
+- =:notcsltype = :: Print only entries whose
+  CSL entry type (possibly based on a conversion from BibTeX/BibLaTeX
+  to CSL) is not among the listed entry types.
+
+- =:filter = :: Print only entries for which the given
+  Emacs Lisp predicate returns a non-~nil~ value.
+
 * Working with Source Code
 :PROPERTIES:
 :DESCRIPTION: Export, evaluate, and tangle code blocks.
-- 
2.25.1



Re: [PATCH] org-export: Remove zero-width space escapes during export

2022-07-26 Thread András Simonyi
Dear All,

this might be a very stupid question as I'm not familiar with the
internals of the Org export engine, but couldn't this change lead to
problems with the Org-to-Org export of documents containing these
"semantic separators"?

thanks and best wishes,
András

On Tue, 26 Jul 2022 at 16:52, Timothy  wrote:
>
> Hi Ihor,
>
> > I am attaching a tentative patch that will make Org export remove
> > zero-width spaces when those spaces actually separate the object
> > boundaries.
> >
> > Any objections?
>
> IMO this is an immanently sensible idea. I added an export filter like this to
> my config basically as soon as I found out about zero-width spaces.
>
> One minor quibble, I find the name mildly misleading. When you say “escaped” I
> think of escaped characters, which isn’t really connected to what the zero 
> width
> does. I’d personally be inclined to call the zero width space an “invisible
> semantic separator”.
>
> > +(defun org-export–remove-escaped (data info)
> > +  “Remove escape symbols from plain-text in DATA.
> > +DATA is a parse tree or a secondary string.  INFO is a plist
> > +containing export options.  It is modified by side effect and
> > +returned by the function.”
>
> How about:
>
> ┌
> │ (defun org-export--remove-semantic-separators (data info)
> │   "Remove Org-specific semantic separators from plain-text in DATA.
> │ DATA is a parse tree or a secondary string.  INFO is a plist
> │ containing export options.  It is modified by side effect and
> │ returned by the function."
> └
>
> All the best,
> Timothy



Re: [PATCH] oc-csl: Add support for sub-bibliographies

2022-07-25 Thread András Simonyi
Dear All,

On Sun, 24 Jul 2022 at 09:41, Ihor Radchenko  wrote:
>
> Thanks!
>
> I have made some changes to the patch, mostly fixing grammar issues (the
> ones I can notice). I also changed the sub-section from "Bibliography
> options" to "Bibliography options in "biblatex" and "csl" export processors"
>
> See the attached.

Thanks a lot for the improvements! The only suggested change which I'm
not sure about is the renaming of the section "Bibliography printing"
to "Printing bibliography" Neither of them are ideal but it's
difficult to find a formulation which sounds OK and is noncommittal
regarding the number of bibliographies (a single one vs. several). Of
the two, I feel that "Printing bibliography" is slightly worse because
of the missing determiner before "bibliography", maybe "Printing
bibliographies" would be better? Admittedly, as a non-native user of
English my intuitions do not count for much, so it'd be nice to hear
the opinion of some of the native speaker list members.

> Reading through the patch, I noticed that :title option is not
> documented. Does it mean :title is not supported by csl processor?

yes :title is not supported by the "csl" processor. Should we perhaps
replace the example with another one using a multi-word keyword, like

:  #+print_bibliography: :nottype proceedings,article :keyword "algebraic logic"

WDTY?
best wishes,
András



Re: [PATCH] oc-csl: Add support for sub-bibliographies

2022-07-23 Thread András Simonyi
Dear All,

On Sat, 23 Jul 2022 at 05:59, Ihor Radchenko  wrote:
> Could you please create a dedicated subsection under "15 Citation> handling" 
> instead of documenting PRINT_BIBLIOGRAPHY together with export
> processors? The section should contain a general overview of what
> PRINT_BIBLIOGRAPHY does and that it can appear multiple times. Then,
> further sub-sub-section will detail on CSL and LaTeX-based processors.

Dear Ihor, thanks a lot for your comments, I've attached a new version
in which I tried to implement your suggestions.

best wishes,
András
From d77255421e05f8e1f090e89b17334aed0bdf4fe4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Wed, 20 Jul 2022 23:54:32 +0200
Subject: [PATCH] * doc/org-manual.org: Document "PRINT_BIBLIOGRAPHY" options

---
 doc/org-manual.org | 56 +-
 1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 26d18f533..e45acc0f0 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16810,11 +16810,65 @@ conformant to the Harvard style and the specification of the
 Wolkers-Kluwer publisher; since it relies on the ~bibtex~ processor of
 your LaTeX installation, it won't export to anything but PDF.
 
+** Bibliography printing 
+
 The =PRINT_BIBLIOGRAPHY= keyword specifies where the bibliography
-should print.
+should print (note the colon):
 
 : #+print_bibliography:
 
+A document may contain more than one =PRINT_BIBLIOGRAPHY= keywords,
+and the keyword can be used with or without additional options.
+Options can be used, for example, to print only entries that belong to
+a certain category or control formatting.  The set of supported
+=PRINT_BIBLIOGRAPHY= options and their interpretation varies between
+the different citation export processors, and several of them do not
+support passing options at all.
+
+*** Bibliography options
+
+The "biblatex" and "csl" export processors support bibliography
+options through a property list attached to the =PRINT_BIBLIOGRAPHY=
+keyword.  For example,
+
+: #+print_bibliography: :type book :keyword algebra
+
+Values including spaces must be surrounded with double quotes.  If you
+need to use a key multiple times, you can separate its values with
+commas, but without any space in-between:
+
+: #+print_bibliography: :keyword algebra,logic :title "Primary Sources"
+
+The "biblatex" export processor accepts all options supported by
+BibLaTeX's ~\printbibliography~ command, while the "csl" processor
+accepts the following ones:
+
+- =:keyword = :: Print only entries whose
+  keyword field contains all given keywords.
+
+- =:notkeyword = :: Print only entries whose
+  keyword field does not contain any of the given keywords.
+
+- =:type = :: Print only entries whose type is
+  ==.  Entry type is the BibTeX/BibLaTeX entry type if this
+  information is available (the entry was read from a BibTeX/BibLaTeX
+  bibliography) and the CSL entry type otherwise.
+
+- =:nottype = :: Print only entries whose
+  type is not among the given entry types.  Entry type is determined
+  as in the case of =:type=.
+
+- =:csltype = :: Print only entries whose CSL entry type
+  (possibly based on a conversion from BibTeX/BibLaTeX to CSL) is
+  ==.
+
+- =:notcsltype = :: Print only entries whose
+  CSL entry type (possibly based on a conversion from BibTeX/BibLaTeX
+  to CSL) is not among the listed entry types.
+
+- =:filter = :: Print only entries for which the given
+  Emacs Lisp predicate returns a non-~nil~ value.
+
 * Working with Source Code
 :PROPERTIES:
 :DESCRIPTION: Export, evaluate, and tangle code blocks.
-- 
2.25.1



Re: [PATCH] oc-csl: Add support for sub-bibliographies

2022-07-21 Thread András Simonyi
...of course, I managed to leave a typo in the manual patch, please
ignore the earlier version and consider the attached one.

best wishes,
András

On Thu, 21 Jul 2022 at 00:03, András Simonyi  wrote:
>
> Dear All,
>
> On Sat, 16 Jul 2022 at 10:43, Ihor Radchenko  wrote:
> any Lisp predicate as a filter.
>
> > Thanks! LGTM!
> >
> > Can you please also document the new feature in the manual? Especially,
> > the CLS-specific filter options. It is not clear what are they.
>
> many thanks for looking into the patch! I've attached a rather
> speculative patch documenting "PRINT_BIBLIOGRAPHY" options in the
> manual including the ones added by my first patch. I'm unsure about a
> lot of things (e.g., maybe it's too detailed about the CSL options),
> but perhaps it's a useful starting point.
>
> best wishes,
> András
From c5e7cc0cd30795bead429037216390237382cc38 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Wed, 20 Jul 2022 23:54:32 +0200
Subject: [PATCH] * doc/org-manual.org: Document "PRINT_BIBLIOGRAPHY" options

---
 doc/org-manual.org | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 26d18f533..c43d1d574 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16815,6 +16815,49 @@ should print.
 
 : #+print_bibliography:
 
+The "biblatex" and "csl" export processors support passing additional
+bibliography options through a property list attached to the
+=PRINT_BIBLIOGRAPHY= keyword.  E.g.,
+
+: #+print_bibliography: :type book :keyword algebra
+
+Values including spaces must be surrounded with double quotes.  If you
+need to use a key multiple times, you can separate its values with
+commas, but without any space in-between:
+
+: #+print_bibliography: :keyword algebra,logic :title "Primary Sources"
+
+A document may contain more than one =PRINT_BIBLIOGRAPHY= keywords
+with or without additional options.  The "biblatex" export processor
+accepts all options supported by BibLaTeX's ~\printbibliography~
+command, while the "csl" processor accepts the following ones:
+
+- =:keyword = :: Print only entries whose
+  keyword field contains all given keywords.
+
+- =:notkeyword = :: Print only entries whose
+  keyword field does not contain any of the given keywords.
+
+- =:type = :: Print only entries whose type is
+  ==.  Entry type is the BibTeX/BibLaTeX entry type if this
+  information is available (the entry was read from a BibTeX/BibLaTeX
+  bibliography) and the CSL entry type otherwise.
+
+- =:nottype = :: Print only entries whose
+  type is not among the given entry types.  Entry type is determined
+  as in the case of =:type=.
+
+- =:csltype = :: Print only entries whose CSL entry type
+  (possibly based on a conversion from BibTeX/BibLaTeX to CSL) is
+  ==.
+
+- =:notcsltype = :: Print only entries whose
+  CSL entry type (possibly based on a conversion from BibTeX/BibLaTeX
+  to CSL) is not among the listed entry types.
+
+- =:filter = :: Print only entries for which the given
+  Emacs Lisp predicate returns a non-~nil~ value.
+
 * Working with Source Code
 :PROPERTIES:
 :DESCRIPTION: Export, evaluate, and tangle code blocks.
-- 
2.25.1



Re: [PATCH] oc-csl: Add support for sub-bibliographies

2022-07-20 Thread András Simonyi
Dear All,

On Sat, 16 Jul 2022 at 10:43, Ihor Radchenko  wrote:
any Lisp predicate as a filter.

> Thanks! LGTM!
>
> Can you please also document the new feature in the manual? Especially,
> the CLS-specific filter options. It is not clear what are they.

many thanks for looking into the patch! I've attached a rather
speculative patch documenting "PRINT_BIBLIOGRAPHY" options in the
manual including the ones added by my first patch. I'm unsure about a
lot of things (e.g., maybe it's too detailed about the CSL options),
but perhaps it's a useful starting point.

best wishes,
András
From c77494b8bff82433d4bf23631ab67e5ff3ece581 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Wed, 20 Jul 2022 23:54:32 +0200
Subject: [PATCH] * doc/org-manual.org: Document "PRINT_BIBLIOGRAPHY" options

---
 doc/org-manual.org | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 26d18f533..c4f262dd0 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16815,6 +16815,49 @@ should print.
 
 : #+print_bibliography:
 
+The "biblatex" and "csl" export processors support passing additional
+bibliography options through a property list attached to the
+=PRINT_BIBLIOGRAPHY= keyword.  E.g.,
+
+: #+print_bibliography: :type book :keyword algebra
+
+Values including spaces must be surrounded with double quotes.  If you
+need to use a key multiple times, you can separate its values with
+commas, but without any space in-between:
+
+: #+print_bibliography: :keyword algebra,logic :title "Primary Sources"
+
+A document may contain more than one =PRINT_BIBLIOGRAPHY= keywords
+with or without additional options.  The "biblatex" export processor
+accepts all options supported by BibLaTeX's ~\printbibliography~
+command, while the "csl" processor accepts the following ones:
+
+- =:keyword = :: Print only entries whose
+  keyword field contains all given keywords.
+
+- =:notkeyword = :: Print only entries whose
+  keyword field does not contain any of the given keywords.
+
+- =:type = :: Print only entries whose type is
+  ==.  Entry type is the BibTeX/BibLaTeX entry type if this
+  information is available (the entry was read from a BibTeX/BibLaTeX
+  bibliography) and the CSL entry type otherwise.
+
+- =:nottype = :: Print only entries whose
+  type is not among the given entry types.  Entry type is determined
+  as in the case of =:type=.
+
+- =:csltype = :: Print only entries whose CSL entry type
+  (possibly based on a conversion from BibTeX/BibLaTeX to CSL) is
+  ==.
+
+- =:notcsltype = :: Print only entries whose
+  CSL entry type (possibly based on a conversion from BibTeX/BibLaTeX
+  to CSL) is not among the listed entry types.
+
+- =:filter = :: Print only entries for which the given
+  Emacs Lisp predicate returns a non-~nil~ value.
+
 * Working with Source Code
 :PROPERTIES:
 :DESCRIPTION: Export, evaluate, and tangle code blocks.
-- 
2.25.1



Re: @string abbreviation in bib file not honored in (basic) org-cite [and a minimal working example with natbib]

2022-07-12 Thread András Simonyi
On Tue, 12 Jul 2022 at 13:36, John Kitchin  wrote:

> Maybe it is still needed so the tooltip looks nice.

currently, oc-basic.el contains the single activation (fontification)
processor (called "basic") shipped with Org, the other oc-*.el files
provide only export processors.

best wishes,

András

>> OTOH, a small correction:  as far as I can see, oc-natbib and
>> oc-bibtex (and oc-biblatex) do not parse bib(la)tex files at all,
>> since they simply transform Org citation and bibliography commands to
>> their LaTeX equivalent.
>>
>> best wishes,
>> András
>>
> --
> John
>
> ---
> Professor John Kitchin (he/him/his)
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> https://kitchingroup.cheme.cmu.edu
> https://pointbreezepubs.gumroad.com/ pycse bookstore
>



Re: @string abbreviation in bib file not honored in (basic) org-cite [and a minimal working example with natbib]

2022-07-12 Thread András Simonyi
Dear All,

On Sun, 10 Jul 2022 at 09:17, Ihor Radchenko  wrote:

> AFAIU, oc-natbib/oc-bibtex also do not support @string because they also
> rely upon the built-in Emacs parser for bib files.

> I have submitted a bug report to Emacs devs [1]. Hopefully it can be
> fixed on Emacs side without a need to switch the bibtex parser.

Thanks Ihor for submitting the bug report, I think it will be useful
for Emacs to contain a built-in bibtex parser with proper @string
support.
OTOH, a small correction:  as far as I can see, oc-natbib and
oc-bibtex (and oc-biblatex) do not parse bib(la)tex files at all,
since they simply transform Org citation and bibliography commands to
their LaTeX equivalent.

best wishes,
András



Re: Can citeproc be installed without using MELPA? (was: @string abbreviation in bib file not honored in (basic) org-cite)

2022-07-12 Thread András Simonyi
Dear All,

On Mon, 11 Jul 2022 at 04:05, Ihor Radchenko  wrote:

> >> Then, I am wondering if parsebib can be added to ELPA or at least
> >> non-GNU ELPA. The same can be said for all other dependencies of
> >> citeproc.el and for citeproc itself.

> non-GNU ELPA is also fine. The idea is to avoid asking users to add
> extra package repo configuration.

Since the dash library, which is heavily used in citeproc-el, has been
added to GNU ELPA, if parsebib also becomes available in non-GNU ELPA
then I don't so any serious problem with adding citeproc-el to the
latter as well -- the use of the "s" string processing library would
still need to be eliminated but this would require only relatively
minor changes.

best wishes,
András



[PATCH] oc-csl: Add support for sub-bibliographies

2022-07-11 Thread András Simonyi
Dear All,

the attached patch adds support for filter-based sub-bibliographies in the "csl"
org-cite export processor. It supports the same syntax for specifying
filters as the biblatex processor and supports some of the biblatex
filter types, concretely, entry-type and keyword based filtering. It
also supports filtering based on CSL type (as opposed to bib(la)tex
type) and using any Lisp predicate as a filter.

best wishes,
András
From 50db7f8ae94cf9a3799eccdf3d7ee69a2e7c4505 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Mon, 11 Jul 2022 19:13:48 +0200
Subject: [PATCH] oc-csl.el: Add support for sub-bibliographies

* lisp/oc-csl.el (org-cite-csl--rendered-bibliographies): New function
to collect all #+print_bibliography keywords with their properties and
call Citeproc to render all sub-bibliographies in one go as required
by the API.  Return the formatted bibliographies as values in an alist
in which keys are the #+print_bibliography keyword options as plists.
Cache the return value in the export communication channel.
(org-cite-csl--bibliography-filter): New helper function to convert
plists representing #+print_bibliography options to the alist filter
form expected by Citeproc.
(org-cite-csl--rendered-citations): Call
`org-cite-csl--rendered-bibliographies' before rendering citations to
make sure that the complete sub-bibliography information is added to
the processor and, therefore, citation numbers are correct.
(org-cite-csl--render-bibliography): Instead of directly calling
Citeproc to render the bibliography, call
`org-cite-csl--rendered-bibliographies' and retrieve the formatted
bibliography from its return value based on the options passed as the
`props' argument.
---
 etc/ORG-NEWS   | 13 +++-
 lisp/oc-csl.el | 83 +-
 2 files changed, 88 insertions(+), 8 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 4cda357f1..ce8675dea 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -239,7 +239,7 @@ This behaviour can be changed by supplying a =:align= parameter.
 
 The tabbing environment can be useful when generating simple tables which
 can be span multiple pages and when table cells are allowed to overflow.
-*** Support for =nocite= citations in the "csl" export processor
+*** Support for =nocite= citations and sub-bibliographies in the "csl" export processor
 
 The "csl" citation export processor now supports =nocite= style
 citations that add items to the printed bibliography without visible
@@ -251,6 +251,17 @@ instance,
 #+end_src
 
 includes all available items in the printed bibliography.
+
+The "csl" export processor now also supports sub-bibliographies that
+show only a subset of the references based on some criterion.  For
+example,
+
+#+begin_src org
+#+print_bibliography: :type book :keyword ai
+#+end_src
+
+prints a sub-bibliography containing the book entries with =ai= among
+their keywords.
 ** New functions and changes in function arguments
 
 *** New function ~org-element-cache-map~ for quick mapping across Org elements
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index a2bd6653c..0b2fe5c41 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -90,11 +90,23 @@
 ;; The part of the suffix before the locator is appended to reference's prefix.
 ;; If no locator term is used, but a number is present, then "page" is assumed.
 
+;; Filtered sub-bibliographies can be printed by passing filtering
+;; options to the "print_bibliography" keywords.  E.g.,
+;;
+;;#+print_bibliography: :type book keyword: emacs
+;;
+;; If you need to use a key multiple times, you can separate its
+;; values with commas, but without any space in-between:
+;;
+;;#+print_bibliography: :keyword abc,xyz :type article
+
 ;; This library was heavily inspired by and borrows from András Simonyi's
 ;; Citeproc Org () library.
 ;; Many thanks to him!
 
 ;;; Code:
+(require 'cl-lib)
+(require 'map)
 (require 'bibtex)
 (require 'json)
 (require 'oc)
@@ -559,6 +571,10 @@ OUTPUT using Citeproc."
 	  (citeproc-append-citations structures processor))
 	(when nocite-ids
 	  (citeproc-add-uncited nocite-ids processor))
+;; All bibliographies have to be rendered in order to have
+;; correct citation numbers even if there are several
+;; sub-bibliograhies.
+(org-cite-csl--rendered-bibliographies info)
 	(let (result
 	  (rendered (citeproc-render-citations
 			 processor
@@ -572,6 +588,62 @@ OUTPUT using Citeproc."
 	  (plist-put info :cite-citeproc-rendered-citations result)
 	  result
 
+(defun org-cite-csl--bibliography-filter (bib-props)
+  "Return the sub-bibliography filter corresponding to bibliography properties.
+
+BIB-PROPS should be a plist representing the properties
+associated with a \"print_bibliography\" keyword, as returned by
+`org-cite-bibliography-properties'."
+  (let (result
+	(remove-keyword-colon (lambda (x) (intern (substring 

Re: @string abbreviation in bib file not honored in (basic) org-cite

2022-07-09 Thread András Simonyi
Dear All,

On Sat, 9 Jul 2022 at 05:55, Ihor Radchenko  wrote:

> The problem with parsebib is that it does not even have license
> (I do not see any in https://github.com/joostkremers/parsebib). If
> parsebib were a part of Emacs core or at least a part of ELPA, we would
> also be able to use it in Org core.

looking into the source code (parsebib.el), the library seems to be
under a BSD-type license.

best wishes,
András



Re: [BUG] @* in [cite/nocite:@*] is a valid special LaTeX bibliography key, but it is highlighted using "error" face by oc.el (was: [PATCH] oc-csl: Add support for nocite citations)

2022-07-04 Thread András Simonyi
Dear All,

On Mon, 4 Jul 2022 at 14:27, Ihor Radchenko  wrote:

> András Simonyi  writes:

> I do not agree.
> If someone sets up natbib for latex export and basic for other formats,
> "*" will not be correctly exported in those other formats (because basic
> does not support @* syntax) - something fontification should better
> highlight for the user.

yes, the basic export processor is, well, basic in certain respects.
But then this is the case with more advanced citation styles, e.g.
"locators" as well, which is supported by the biblatex export
processor and not by "basic"; nonetheless, the "basic" activation
processor's fontification doesn't signal "error" if someone uses the
"locators"  style, in fact it doesn't check whether a used citation
style is supported by any of the processors. It seems to me that "*"
as a key is sophisticated enough that if we have to make a decision
about the default fontification then it is better to err on the side
of supposing that a user using it knows what they are doing, Of
course, others' mileage may vary, and it'd be very interesting to hear
other opinions.

best wishes,
András



> Also, are there any similar non-key constructs in latex in addition to "*"?
>
> Best,
> Ihor



[BUG?] Wrong quote positions in exported CSL bib items when export is done with C-u C-e

2022-07-04 Thread András Simonyi
Dear All,

I'm experiencing the following mysterious problem with the csl
citation export processor: exporting using the export dispatcher
without a prefix argument works fine, but when I repeat the export
action using C-u before C-e the exported bibliography items containing
quotes have the quotes shifted to incorrect places, seemingly with a
fix offset.

Minimal example:

Org document:
--8<---cut here---start->8---
#+cite_export: csl
#+bibliography: bib.bib
[cite:@Hobbs-1985-Ontological]
#+print_bibliography:
--8<---cut here---end--->8---

bib.bib:
--8<---cut here---start->8---
@inproceedings{Hobbs-1985-Ontological,
  title= {Ontological Promiscuity},
  author   = {Hobbs, Jerry R.},
  booktitle= {Proceedings of the 23rd Annual Meeting
of the Association for Computational Linguistics},
  year = {1985},
  location = {Chicago},
  organization = {Association for Computational Linguistics},
  pages= {61--69}
}
--8<---cut here---end--->8---

The single bibliography item is the correct

  Hobbs, Jerry R. 1985. “Ontological Promiscuity.” In /Proceedings of
  the 23rd Annual Meeting of the Association for Computational
  Linguistics/, 61–69. Chicago: Association for Computational
  Linguistics.

when exported with C-e and as an UTF-8 buffer

but contains an incorrectly places quote:

  Hobbs, Jerry R. 1985. “Ontological Promiscuity. In” /Proceedings of
  the 23rd Annual Meeting of the Association for Computational
  Linguistics/, 61–69. Chicago: Association for Computational
  Linguistics.

when exported (again) with C-u C-e.

Emacs version: 28.1
Org version:  9.5.4
(Citeproc version is Melpa 20220702.2132)

is anybody else seeing this behaviour?

thanks & best wishes,

András



Re: [BUG] @* in [cite/nocite:@*] is a valid special LaTeX bibliography key, but it is highlighted using "error" face by oc.el (was: [PATCH] oc-csl: Add support for nocite citations)

2022-07-04 Thread András Simonyi
Dear All,

On Sun, 3 Jul 2022 at 15:09, Ihor Radchenko  wrote:

> Then, oc-natbib, oc-biblatex, and oc-csl should be modified to provide
> an alternative activation function that will not highlight @* as
> non-existing key.
>
> Probably, we can even use an alternative "special" key face, not
> 'org-cite-key.

AFAICS, the situation is rather complex: Org (the main branch)
currently contains five export processors (basic, bibtex, natbib,
biblatex and csl), but only a single activation processor called
"basic". Of the five export processors the three LaTeX-based ones
already support the "*" key in nocite citations, and the CSL processor
could also with my proposed patch, leaving only the "basic" one
without this feature.

I think that the problem with simply adding one or more new activation
processors with different fontification for the "*" key is that Org
has no way of knowing (at least for sure) which export processor will
be used for a exporting a certain Org buffer, since it can depend on
the chosen export backend (see the variable
org-cite-export-processors). E.g., org-cite could be set up to use the
"natbib" processor for "LaTeX" export and the "basic" processor for
any other format.  I think that it'd be more in the spirit of the
"basic" activation processor to be more permissive and not treat "*"
as an error, similarly to citation styles not supported by the "basic"
export processor but supported by others.

best wishes,
András



Re: [PATCH] oc-csl: Add support for nocite citations

2022-07-02 Thread András Simonyi
Dear Ihor,

thanks a lot for your reply!

On Sat, 2 Jul 2022 at 06:37, Ihor Radchenko  wrote:

> By "*", do you mean something like [cite/n:@*]?
> If so, will it be correctly fontified as an existing citation?

Yes I meant exactly that. As for fontification, this is a very good
question! I've checked it now with the built-in "basic"
activation processor and it shows the "*" with an "error" face,
indicating that it's not a key in the bibliography file(s), which
might not be ideal. Nonetheless, this problem is not limited to or
introduced by this patch, because the same construct and
functionality is also supported by the "biblatex" and "natbib" export
processors.  Actually, the possibility of using "*" as a key comes
simply
from a citeproc-el change, not from oc-csl, I just thought that it is
obscure enough to merit an explicit mention in the NEWS file.

> It would help to provide an example how to use "*" key.
> Also, I'd prefer if you follow doc/Documentation_Standards.org. Please
> use Org markup instead of `...' quotes.

Thanks, I have tried to address your comments in the attached new
version of the patch.
Note that the quotes around "csl" follow the manual's "Citation
handling" chapter.

> Why not simply
> (member (car (org-cite-citation-style citation info)) '("nocite" "n"))
> ?

Thanks, that is indeed simpler, I've changed the function's definition
accordingly.


best wishes,
András
From 7d2c6be97258ecbca4929e302d63b760bec078ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Fri, 1 Jul 2022 10:24:17 +0200
Subject: [PATCH] oc-csl.el: Add support for nocite citations

* lisp/oc-csl.el (org-cite-csl--rendered-citations): Collect nocite
style citations in a separate list as required by the citeproc-el
API. Set the output of all nocite citations to the empty string.
(org-cite-csl--nocite-p): New helper predicate for checking whether a
citation is a nocite.
---
 etc/ORG-NEWS   | 11 +++
 lisp/oc-csl.el | 53 --
 2 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 902d70256..4cda357f1 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -239,7 +239,18 @@ This behaviour can be changed by supplying a =:align= parameter.
 
 The tabbing environment can be useful when generating simple tables which
 can be span multiple pages and when table cells are allowed to overflow.
+*** Support for =nocite= citations in the "csl" export processor
 
+The "csl" citation export processor now supports =nocite= style
+citations that add items to the printed bibliography without visible
+references in the text. Using the key =*= in a nocite citation, for
+instance,
+
+#+begin_src org
+[cite/n:@*]
+#+end_src
+
+includes all available items in the printed bibliography.
 ** New functions and changes in function arguments
 
 *** New function ~org-element-cache-map~ for quick mapping across Org elements
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index eb67092dd..a2bd6653c 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -59,9 +59,13 @@
 ;; - author (a), including bare (b), caps (c), bare-caps (bc), full (f),
 ;;   caps-full (cf), and bare-caps-full (bcf) variants,
 ;; - noauthor (na), including bare (b), caps (c) and bare-caps (bc) variants,
+;; - nocite (n),
 ;; - year (y), including a bare (b) variant,
 ;; - text (t). including caps (c), full (f), and caps-full (cf) variants,
 ;; - default style, including bare (b), caps (c) and bare-caps (bc) variants.
+;;
+;; Using "*" as a key in a nocite citation includes all available items in
+;; the printed bibliography.
 
 ;; CSL styles recognize "locator" in citation references' suffix.  For example,
 ;; in the citation
@@ -103,6 +107,7 @@
 (declare-function citeproc-create "ext:citeproc")
 (declare-function citeproc-citation-create "ext:citeproc")
 (declare-function citeproc-append-citations "ext:citeproc")
+(declare-function citeproc-add-uncited "ext:citeproc")
 (declare-function citeproc-render-citations "ext:citeproc")
 (declare-function citeproc-render-bib "ext:citeproc")
 (declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
@@ -296,6 +301,12 @@ INFO is the export state, as a property list."
(citeproc-proc-style
 (org-cite-csl--processor info
 
+(defun org-cite-csl--nocite-p (citation info)
+  "Non-nil when CITATION object's style is nocite.
+INFO is the export state, as a property list."
+  (member (car (org-cite-citation-style citation info))
+  '("nocite" "n")))
+
 (defun org-cite-csl--create-structure-params (citation info)
   "Return citeproc structure creation params for CITATION object.
 STYLE is the citation style, as a string or nil. INFO is the export state, as
@@ -535,20 +546,31 @@ INFO is the export state, as a property list.
 Return an alist (CITATION . OUTPUT) where CITATION object has been rendered as
 OUTPUT using Citeproc."
   (or (plist-get info :cite-citeproc-rendered-citations)
-  (let* ((citations 

[PATCH] oc-csl: Add support for nocite citations

2022-07-01 Thread András Simonyi
Dear All,

the attached patch adds support for nocite citations in the csl
org-cite export processor, including support for using the special key
"*" to include all entries in the bibliography.


best wishes,
András
From 3e6514d2e2f4fa68462a02578880b126e3116739 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Fri, 1 Jul 2022 10:24:17 +0200
Subject: [PATCH] oc-csl.el: Add support for nocite citations

* lisp/oc-csl.el (org-cite-csl--rendered-citations): Collect nocite
style citations in a separate list as required by the citeproc-el
API. Set the output of all nocite citations to the empty string.
(org-cite-csl--nocite-p): New helper predicate for checking whether a
citation is a nocite.
---
 etc/ORG-NEWS   |  5 +
 lisp/oc-csl.el | 53 --
 2 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 902d70256..0f7a9e825 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -239,7 +239,12 @@ This behaviour can be changed by supplying a =:align= parameter.
 
 The tabbing environment can be useful when generating simple tables which
 can be span multiple pages and when table cells are allowed to overflow.
+*** Support for nocite citations in the csl export processor
 
+The csl citation export processor now supports `nocite' style
+citations that add items to the printed bibliography without visible
+references in the text. Using the key `*' in a nocite citation
+includes all available items in the printed bibliography.
 ** New functions and changes in function arguments
 
 *** New function ~org-element-cache-map~ for quick mapping across Org elements
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index eb67092dd..05e4fa976 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -59,9 +59,13 @@
 ;; - author (a), including bare (b), caps (c), bare-caps (bc), full (f),
 ;;   caps-full (cf), and bare-caps-full (bcf) variants,
 ;; - noauthor (na), including bare (b), caps (c) and bare-caps (bc) variants,
+;; - nocite (n),
 ;; - year (y), including a bare (b) variant,
 ;; - text (t). including caps (c), full (f), and caps-full (cf) variants,
 ;; - default style, including bare (b), caps (c) and bare-caps (bc) variants.
+;;
+;; Using "*" as a key in a nocite citation includes all available items in
+;; the printed bibliography.
 
 ;; CSL styles recognize "locator" in citation references' suffix.  For example,
 ;; in the citation
@@ -103,6 +107,7 @@
 (declare-function citeproc-create "ext:citeproc")
 (declare-function citeproc-citation-create "ext:citeproc")
 (declare-function citeproc-append-citations "ext:citeproc")
+(declare-function citeproc-add-uncited "ext:citeproc")
 (declare-function citeproc-render-citations "ext:citeproc")
 (declare-function citeproc-render-bib "ext:citeproc")
 (declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
@@ -296,6 +301,12 @@ INFO is the export state, as a property list."
(citeproc-proc-style
 (org-cite-csl--processor info
 
+(defun org-cite-csl--nocite-p (citation info)
+  "Non-nil when CITATION object's style is nocite.
+INFO is the export state, as a property list."
+  (when-let ((style (car (org-cite-citation-style citation info
+(or (string= style "nocite") (string= style "n"
+
 (defun org-cite-csl--create-structure-params (citation info)
   "Return citeproc structure creation params for CITATION object.
 STYLE is the citation style, as a string or nil. INFO is the export state, as
@@ -535,20 +546,31 @@ INFO is the export state, as a property list.
 Return an alist (CITATION . OUTPUT) where CITATION object has been rendered as
 OUTPUT using Citeproc."
   (or (plist-get info :cite-citeproc-rendered-citations)
-  (let* ((citations (org-cite-list-citations info))
- (processor (org-cite-csl--processor info))
- (structures
-  (mapcar (lambda (c) (org-cite-csl--create-structure c info))
-  citations)))
-(citeproc-append-citations structures processor)
-(let* ((rendered
-(citeproc-render-citations
- processor
- (org-cite-csl--output-format info)
- (org-cite-csl--no-citelinks-p info)))
-   (result (seq-mapn #'cons citations rendered)))
-  (plist-put info :cite-citeproc-rendered-citations result)
-  result
+  (let ((citations (org-cite-list-citations info))
+	(processor (org-cite-csl--processor info))
+	normal-citations nocite-ids)
+	(dolist (citation citations)
+	  (if (org-cite-csl--nocite-p citation info)
+	  (setq nocite-ids (append (org-cite-get-references citation t) nocite-ids))
+	(push citation normal-citations)))
+	(let ((structures
+	   (mapcar (lambda (c) (org-cite-csl--create-structure c info))
+		   (nreverse normal-citations
+	  (citeproc-append-citations structures processor))
+	(when nocite-ids
+	  (citeproc-add-uncited nocite-ids 

Re: How to debug a CSL problem

2022-06-05 Thread András Simonyi
Dear All,

On Mon, 6 Jun 2022 at 03:45, Alan Tyree  wrote:

> A short random test shows that the export chokes when there is a single name 
> for an author. Again an example:
> author = {{Wolfsberg Group}} works fine;
> author = {{Wolfsberg}} chokes.

Alan, could you open an issue in the citeproc-el issue tracker about
this? Definitely looks like a citeproc-el bug and should be rather
easy to fix. Thanks in advance!

best wishes,
András



Re: Yet another browser extension for capturing notes - LinkRemark

2022-01-19 Thread András Simonyi
Dear All,

On Wed, 19 Jan 2022 at 10:56, Ihor Radchenko  wrote:

> As a side note, citeproc-el currently has poor performance on large org
> files. It is unusable for me.

Could you elaborate? In theory, oc-cs.el's performance should depend
only on the number of citations (as opposed to the size of the Org
document) and be in the same ballpark as pandoc's citeproc. It'd be
interesting to know the details since I plan to work on speeding up
citeproc-el's rendering, although you are the first one to actually
complain :-).

best wishes,
András



Re: Yet another browser extension for capturing notes - LinkRemark

2022-01-19 Thread András Simonyi
Dear All,

On Wed, 19 Jan 2022 at 04:24, Ihor Radchenko  wrote:

> > Scientific papers require more work, it is necessary to make them
> > available to org-cite somehow. Some nerds use quite peculiar blog
> > engines and strange setting of metadata. So shopping on some sites might
> > work better than other cases.
>
> I have plans to implement something called oc-org.el The plan is
> using ol-bibtex-compatible Org headings as a source of citations.

Just wanted to note that the CSL-based export processor, oc-csl.el,
already supports this: you can add an Org file as a bibliography, cite
items described by ol-bibtex style headings and export the citations.
It'd be very nice indeed if other built-in processors supported the
format too (e.g., "basic"). As for external ones, the CSL-based
activation processor I wrote
(https://github.com/andras-simonyi/org-cite-csl-activate) also
supports it and there are plans to add support to Citar as well
(through parsebib); see the discussion at
https://github.com/bdarcus/citar/issues/397.

best wishes,
András

> Best,
> Ihor
>



Re: [BUG] org-cite-insert does not like @conference [9.5.2 (release_9.5.2 @ ~/.emacs.d/git/org-mode/lisp/)]

2022-01-01 Thread András Simonyi
Dear All,

On Sat, 1 Jan 2022 at 14:53, Julien Chastang
 wrote:

> I have been experimenting with org-cite. I noticed that I can insert 
> (org-cite-insert) all bibtex types *except* for @conference. [...]
> yet I believe @conference is a valid bibtex type. I noticed that 
> org-bibtex-types has an empty description for the conference type, but I 
> don't know if that has anything to do with it. I hope I have not missed 
> anything obvious.

it seems that 'conference' is indeed a valid BibTeX entry type, but is
only an alias of 'inproceedings' and was included for some (nowadays
obscure?) compatibility reasons, while biblatex doesn't support it at
all.
Consequently, you can simply use 'inproceedings' instead. If this is
not an option, then you can force org-cite to parse a bibliography as
a (strict) BibTeX bibliography instead of the default biblatex parsing
by using the 'bibtex' extension in the file's name, this should cause
'conference' entries to be treated as valid.

best wishes,
András



Re: org-cite and export to ODT

2021-12-09 Thread András Simonyi
Dear All,

On Thu, 9 Dec 2021 at 10:54, Xianwen Chen (陈贤文)  wrote:

> Thinking about the new org-cite, which is orgmode's native citation solution, 
> I'm wondering if it would be easier to use org-cite within orgmode and export 
> to ODT? A small example with configuration suggestion will be highly 
> appreciated!
>
> Xianwen

org-cite contains two citation export processors which are able to
export citations to ODT: oc-basic and oc-csl. A minimal example using
oc-csl could be along the following lines:

[ cut here ]
#+bibliography: /path/to/my.bib
#+cite_export: csl

[cite:@smith1998]

* References
#+print_bibliography:
[ cut here ]

details can be found in the Org manual
(https://orgmode.org/manual/Citation-handling.html#Citation-handling).

best wishes,
András



Re: From macros to elisp programming?

2021-12-06 Thread András Simonyi
Dear All,

On Mon, 6 Dec 2021 at 14:43, Ypo  wrote:

> I am able to make macros, but I think I am far away from Lisp programming. 
> [...]
> Is there a path to go from macros to elisp programming?

there is a package called 'elmacro' (https://github.com/Silex/elmacro)
which you can look into. Apparently, it can convert  (most?) macros
into interactive Elisp functions, and might even provide a good
starting point  for learning Elisp.

best wishes,
András



Re: citeproc-org and org-ref 3

2021-12-01 Thread András Simonyi
y-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(# 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 () # 0xec639179d6199fa>) #f(compiled-function () # -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
> > mailto:andras.simo...@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
> > mailto:jos...@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.
> >  >
> >
>



Re: citeproc-org and org-ref 3

2021-11-30 Thread András Simonyi
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
 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
> I confess that I am lost.
>
> What have I to do to not waste too much time with this problem?
>
> Best wishes,
>
> Jo.
>



Re: Bibliographies on export with ox-context and ox-epub

2021-11-25 Thread András Simonyi
On Thu, 25 Nov 2021 at 12:21, juh  wrote:

> After I fixed my installation I now use org-mode 9.5.1 but still
> citations are not rendered in no export format neither with basic nor
> with csl.

> test.bib in same directory:
>
>
> @article{doe,
>  author={org, mode and Syntax, Citation and List, Mailing and Effort, 
> Time},
>  journal={Journal of Plain Text Formats},
>  title={Elegant Citations with Org-Mode},
>  year={2021},
>  month={7},
>  volume={42},
>  number={1},
>  pages
>
if that's the entire content then it is not a well-formed bib(la)tex
bibliography file: the value of the pages field and the entry's
closing bracket are missing.

best wishes,
András



Re: Bibliographies on export with ox-context and ox-epub

2021-11-24 Thread András Simonyi
Dear All,
On Wed, 24 Nov 2021 at 16:49, juh  wrote:
> The error disappears but the bibliography still is not rendered.
>
> I get the plain code:
>
> [@doe 45]
>
> [cite/t:@doe 45]
>
> juh
is the rendering OK when you export using the built-in, standard
backends, e.g., html or txt? As a data point, on my system org-cite
export with the CSL processor using ox-context works as expected.

best wishes,
András



Re: [org-cite] CSL processor, APA Style, and no-date citations

2021-11-17 Thread András Simonyi
Dear All,

On Wed, 17 Nov 2021 at 16:07, Bruce D'Arcus  wrote:
>
> On Wed, Nov 17, 2021 at 9:59 AM Rudolf Adamkovič  wrote:
>
> > I would like to start using the new citations with the APA Style. To cite 
> > in APA, I use a CSL file. Everything works well with Pandoc, but with Org, 
> > all citations with no "date" BibTeX field render as "$AUTHOR" instead of 
> > "$AUTHOR (n.d.)" both in-text and in the reference list. This renders Org 
> > unusable with APA Style. What can I do?
>
> I'm guessing that's a little bug in citeproc-el.
>
> If Andras doesn't reply here, you might add this to the issue tracker there?
>
> Bruce

this looks like a citeproc-el bug indeed -- could you post a bug
report on the GitHub project page?

thanks in advance,
András



Re: [BUG] Elisp error when exporting citation [9.5 (release_9.5-104-g2b1fc6 @ /home/quintus/.emacs.d/org-mode/lisp/)]

2021-11-06 Thread András Simonyi
Dear All,

On Thu, 4 Nov 2021 at 20:26, M. ‘quintus’ Gülker
 wrote:

> The improper formatting on LaTeX  export I mentioned in the other e-mail[1] 
> however is still persisting,
> both with the @ and without it.

I've pushed a change to citeproc-el which should solve that problem --
thanks for reporting it.
best wishes,

András



Re: [BUG] Elisp error when exporting citation [9.5 (release_9.5-104-g2b1fc6 @ /home/quintus/.emacs.d/org-mode/lisp/)]

2021-11-04 Thread András Simonyi
Dear All,

On Wed, 3 Nov 2021 at 17:02, Nicolas Goaziou  wrote:
> It looks like there's something to repair on the Citeproc side. I'm
> Cc'ing András Simonyi for a better understanding of the problem.

I think this problem has been fixed in citeproc-el (see PR #55) -- you
are probably using an earlier version.

best wishes,
András



[PATCH] oc-csl: Fix footnote status reporting for wrapped citations

2021-11-02 Thread András Simonyi
Dear All,

the attached simple patch fixes a problem in oc-csl.el which led to
missing footnote number information for citations that were
automatically footnote-wrapped based on the used CSL style.

best wishes,
András
From 1423e0f600d8e4e29f275faa9c9117db9b081b19 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Tue, 2 Nov 2021 16:44:37 +0100
Subject: [PATCH] oc-csl: Fix footnote status reporting for wrapped citations

* lisp/oc-csl.el (org-cite-csl--create-structure): Update footnote information
when citation is wrapped in a footnote.
---
 lisp/oc-csl.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 42886dc44..f59b14a88 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -506,7 +506,9 @@ INFO is the export state, as a property list."
 ;; a footnote, but isn't yet.
 (when (and (not footnote) (org-cite-csl--note-style-p info))
   (org-cite-adjust-note citation info)
-  (org-cite-wrap-citation citation info))
+  (org-cite-wrap-citation citation info)
+  (setq footnote (org-element-lineage citation
+  '(footnote-definition footnote-reference
 ;; Return structure.
 (apply #'citeproc-citation-create
`(:note-index
-- 
2.25.1



Re: Citations: position="first" match not properly evaluated

2021-11-02 Thread András Simonyi
Dear All,
I think I found the source of this problem in oc-csl.el -- I'll post a
patch shortly.
best wishes,
András



Re: Could a .bib file be edited and organized in an "org-mode" way and still work as a .bib file?

2021-10-19 Thread András Simonyi
On Tue, 19 Oct 2021 at 16:08, Ihor Radchenko  wrote:

> By the way, do I understand correctly that oc-csl.el requires
> citeproc-el to be installed? It is not clearly stated in the commentary.

Yes, oc-csl.el uses citeproc-el for formatting the citations and the
bibliography. I'm not entirely sure what kind of commentary you are
referring to but the oc-csl.el source code commentary currently says
that

>  The processor relies on the external Citeproc Emacs library, which must be 
> available prior to loading this library.

Should we add something to this? If yes, what is missing in your opinion?

best wishes,
András



Re: Could a .bib file be edited and organized in an "org-mode" way and still work as a .bib file?

2021-10-19 Thread András Simonyi
Dear Ypo,

I also think that the org-bibtex format is pretty close to what you
are looking for. An added benefit could be that the org-cite CSL
export processor has recently gained (admittedly rather experimental)
support for directly using org-bibtex bibliographies, although insert
and follow functionality is missing at the moment.

best wishes,
András

On Tue, 19 Oct 2021 at 15:23, Ihor Radchenko  wrote:
>
> Ypo  writes:
>
> > I have a .bib file with references, and a .org file with annotations. Like:
> > ...
> > Could I write on the .bib file using the orgmode power? Something like
> > this could work as a .bib file, or is it a no-no?
>
> M-x org-bibtex (you need a special format for Org headings).  org-bibtex
> is a part of ol-bibtex.el.
>
> Also, I wrote a set of helpers to capture bibliographic data into Org
> mode headings: https://github.com/yantar92/org-capture-ref
>
> The format is something like:
>
> *** DONE [#A] Nix [Scripta Materialia] (1998) Yielding and strain 
> hardening of thin metal films on substrates :FLAGGED:BOOKMARK:article:ATTACH:
> SCHEDULED: <2021-03-08 Mon>
> :PROPERTIES:
> :TITLE:Yielding and strain hardening of thin metal films on substrates
> :BTYPE:article
> :AUTHOR:   Nix, William D
> :JOURNAL:  Scripta Materialia
> :VOLUME:   39
> :NUMBER:   4-5
> :PAGES:545-554
> :YEAR: 1998
> :URL:  
> https://scholar.googleusercontent.com/scholar.bib?q=info:sVHrZR2RlwsJ:scholar.google.com/=citation=CgXarAaXEL216MPM490:AAGBfm0AYD3J-917MgTBuwvpZNL09BcZoHmF8au_=AAGBfm0AYD3J-ytYquMZbiTcC-Jxg3itxnjKSZfQ=4=citation=-1=en
> :CREATED:  [2021-03-02 Tue 13:25]
> :HOWPUBLISHED: Scholar.Googleusercontent
> :NOTE: Online; accessed 02 March 2021
> :PUBLISHER: Pergamon
> :ID:   2c5b442a-c8fa-43d2-86f0-c160b496eb4d
> :Effort:   0:05
> :SHOWFROMDATE: 2021-03-08
> :END:
>
>  #CLS #dislocation #misfit #theory
>
> - !! [2021-03-09 Tue] [[id:5cc9cea1-a023-4cc8-9753-277dc474850b][Pant Acta 
> 2003]] showed that the hypothesised dislocation/misfit interaction does not 
> actually happen (at least, in (111) FCC films)
>   - Yet, the shape of the dislocation upon interaction with the misfit is 
> still a "bump", thus general derivation by Nix is still not too terrible. 
> *The Nix's model just overestimate the hardening*
>
> This headings exports to
>
> @article{2c5b442a-c8fa-43d2-86f0-c160b496eb4d,
>   author={Nix, William D},
>   title={Yielding and strain hardening of thin metal films on substrates},
>   journal={Scripta Materialia},
>   year={1998},
>   volume={39},
>   number={4-5},
>   pages={545-554},
>   note={Online; accessed 02 March 2021}
> }
>
> Hope it helps.
>
> Best,
> Ihor
>
>



Re: citeproc-style-parse: Symbol’s function definition is void: libxml-parse-xml-region

2021-10-18 Thread András Simonyi
Dear Joseph,

in theory evaluating

(libxml-available-p)

should tell you whether your Emacs has libxml support -- most probably
it doesn't. Maybe you should try to recompile using the --with-xml2
switch.
best wishes,
András

On Mon, 18 Oct 2021 at 14:42, Joseph Vidal-Rosset
 wrote:
>
>
>
> Le 18/10/2021 à 12:54, John Kitchin a écrit :
> > This could mean you have an emacs that was not compiled with libxml.
> >
> > Type C-h v system-configuration-options
> >
> > and look for --with-xml2
> >
> > to see if your emacs was built with it.
> > John
>
> I have this.
>
> #ifdef HAVE_LIBXML2
>xml_cleanup_parser ();
> #endif
>
> It seems thereofre that emacs was indeed compiled with libxml .
>
> But the message
>
> citeproc-style-parse: Symbol’s function definition is void: libxml
> parse-xml-region
>
> when I run org-export-head persists and my blog engine fails... :(
>
>
>
>
>



Re: Citations: non-page locators placed in front of citation

2021-10-12 Thread András Simonyi
Dear All,

On Tue, 12 Oct 2021 at 07:43, M. ‘quintus’ Gülker
 wrote:

> Das ist ein Test [cite:@saenger2013gsr § 12 Rn. 488].
>
> gives:
>
> Saenger, Gesellschaftsrecht, 2. Aufl. (2013), §§ 12 Rn. 488
[...]
> This is a little confusing. Maybe an error on my part? Do I need to
> signal singular and plural use more explicitely?

No, it's citeproc-el which is supposed to determine whether the passed
locator string represents single vs multiple references, using § vs §§
shouldn't make a difference, because they simply signal that the label
is "section". Apparently, citeproc-el's classifier algorithm doesn't
handle some of your examples correctly -- could you open an issue
about this on the project page? Thanks in advance!

best wishes,
András



Re: Citations: non-page locators placed in front of citation

2021-10-10 Thread András Simonyi
Dear All,

On Sun, 10 Oct 2021 at 22:11, Nicolas Goaziou  wrote:
>
> Then, this may be a bug in Citeproc library itself. I suggest to report
> it upstream.

looks like an Org (oc-csl) side locator parsing problem to me, because
using the alternative [cite:@saenger2013gsr para. 12 Rn. 488] form I
seem to get the correct result. Can it be a regex matching problem
with the paragraph symbols?

best wishes,
András



Re: Citations: Locale specific adaptions?

2021-10-08 Thread András Simonyi
Dear All,

setting the `org-cite-csl-locales-dir' variable to a directory
containing the German CSL locale file I indeed get the localized

Akbarian, Samira, An einen, der vorüberfuhr, Stand: 14. Dezember 2020,
https://verfassungsblog.de/an-einen-der-voruberfuhr/ (besucht am
02.01.2021).

version of the bibliography entry,

best wishes,
András





> I think you need to provide locales in addition to the style file, see
> `org-cite-csl-locales-dir'.
>
> Regards,
> --
> Nicolas Goaziou
>



Re: [BUG] Citations: exporting with csl crashes [9.5 (9.5-g0a86ad @ /home/quintus/.emacs.d/elpa/org-9.5/)]

2021-10-04 Thread András Simonyi
Dear Marvin,

thanks for the bug report! I was able to reproduce the issue and it
seems to be indeed a problem in citeproc-el -- I'll investigate and
respond to the citeproc-el ticket.

best wishes,
András

On Mon, 4 Oct 2021 at 19:29, Nicolas Goaziou  wrote:
>
> Hello,
>
> M. ‘quintus’ Gülker  writes:
>
> > Ah, I see. Thank you for the pointer. I created an issue ticket with a
> > copy of the OP here:
> > 
>
> Great! Thank you.
>
> Regards,
> --
> Nicolas Goaziou
>



[PATCH] manual: Remove a couple of stray words from the citation handling section

2021-09-28 Thread András Simonyi
Dear All,

the patch which I attached removes some stray/leftover words from the
manual's section on citations.

best wishes,
András
From 1936c8a3e4668192cb279f417d980fa353fc6bbb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Tue, 28 Sep 2021 23:13:07 +0200
Subject: [PATCH] doc/org-manual.org: Remove a couple of stray words

* doc/org-manual.org (Citation handling): Remove a pair of unnecessary words.
---
 doc/org-manual.org | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 4ebc315cb..2002a05f3 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16515,9 +16515,9 @@ keywords.
 :END:
 #+cindex: citation
 
-As of Org 9.5, a includes a new library =oc.el= provides tooling to
-handle citations in Org via "citation processors" that offer some or
-all of the following capabilities:
+As of Org 9.5, a new library =oc.el= provides tooling to handle
+citations in Org via "citation processors" that offer some or all of
+the following capabilities:
 
 - "activate" :: Fontification, tooltip preview, etc.
 - "follow" :: At-point actions on citations via ~org-open-at-point~.
-- 
2.25.1



Re: [PATCH] oc-csl: Add support for the text and year citation styles

2021-09-28 Thread András Simonyi
Dear All,

I've attached a patch with the pcase pattern refactored following
Nicolas's example -- hopefully this solves the problem.

best wishes,
András

On Tue, 28 Sept 2021 at 17:16, András Simonyi  wrote:
>
> Thanks, I'll try to put together a patch fixing the problem and send it 
> shortly.
> best wishes,
> András
>
> On Tue, 28 Sept 2021 at 17:03, Max Nikulin  wrote:
> >
> > On 28/09/2021 21:40, Bastien wrote:
> > > András Simonyi writes:
> > >
> > >> the attached patch adds support for the text (textual) and year
> > >> (year-only) citation styles in the CSL org-cite processor.
> > >
> > > Applied, thank you very much!
> >
> > This patch has a problem similar to ones earlier fixed by Nicolas:
> > https://orgmode.org/list/seomi1$785$1...@ciao.gmane.io "Re: citations: rx
> > problems with emacs-26.3" Sun, 8 Aug 2021 20:34:55 +0700
> >
> > Compiling single /home/ubuntu/org-mode/lisp/oc-csl.el...
> >
> > In toplevel form:
> > oc-csl.el:330:10:Error: Bytecode overflow
> > Makefile:59: recipe for target 'oc-csl.elc' failed
> > make[2]: [oc-csl.elc] Error 1 (ignored)
> >
> > It is for emacs-26.3 (Ubuntu-18.04 LTS bionic).
From 2ec9af9693c236b6afae7e3d286eb8c6c87283b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Tue, 28 Sep 2021 18:13:11 +0200
Subject: [PATCH 2/2] oc-csl: Refactor code to help byte-compilation

* lisp/oc-csl.el (org-cite-csl--create-structure-params): Refactor pcase pattern
to avoid slow or in some cases non-terminating byte compilation.
---
 lisp/oc-csl.el | 82 +++---
 1 file changed, 38 insertions(+), 44 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 51d3d3d8a..3c77e0354 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -284,50 +284,44 @@ INFO is the export state, as a property list."
   "Return citeproc structure creation params for CITATION object.
 STYLE is the citation style, as a string or nil. INFO is the export state, as
 a property list."
-  (let* ((style (org-cite-citation-style citation info)))
-   (pcase style
- ;; "author" style.
- (`(,(or "author" "a") . ,(or "caps" "c"))
-  '(:mode author-only :capitalize-first t :suppress-affixes t))
- (`(,(or "author" "a") . ,(or "full" "f"))
-  '(:mode author-only :ignore-et-al t :suppress-affixes t))
- (`(,(or "author" "a") . ,(or "caps-full" "cf"))
-  '(:mode author-only :capitalize-first t :ignore-et-al t :suppress-affixes t))
- (`(,(or "author" "a") . ,_)
-  '(:mode author-only :suppress-affixes t))
- ;; "noauthor" style.
- (`(,(or "noauthor" "na") . ,(or "bare" "b"))
-  '(:mode suppress-author :suppress-affixes t))
- (`(,(or "noauthor" "na") . ,(or "caps" "c"))
-  '(:mode suppress-author :capitalize-first t))
- (`(,(or "noauthor" "na") . ,(or "bare-caps" "bc"))
-  '(:mode suppress-author :suppress-affixes t :capitalize-first t))
- (`(,(or "noauthor" "na") . ,_)
-  '(:mode suppress-author))
- ;; "year" style.
- (`(,(or "year" "y") . ,(or "bare" "b"))
-  '(:mode year-only :suppress-affixes t))
- (`(,(or "year" "y") . ,_)
-  '(:mode year-only))
- ;; "text" style.
- (`(,(or "text" "t") . ,(or "caps" "c"))
-  '(:mode textual :capitalize-first t))
- (`(,(or "text" "t") . ,(or "full" "f"))
-  '(:mode textual :ignore-et-al t))
- (`(,(or "text" "t") . ,(or "caps-full" "cf"))
-  '(:mode textual :ignore-et-al t :capitalize-first t))
- (`(,(or "text" "t") . ,_)
-  '(:mode textual))
- ;; Default "nil" style.
- (`(,_ . ,(or "bare" "b"))
-  '(:suppress-affixes t))
- (`(,_ . ,(or "caps" "c"))
-  '(:capitalize-first t))
- (`(,_ . ,(or "bare-caps" "bc"))
-  '(:suppress-affixes t :capitalize-first t))
- (`(,_ . ,_) nil)
- ;; This should not happen.
- (_ (error "Invalid style: %S" style)
+  (let ((style (org-cite-citation-style citation info)))
+(pcase style
+  ;; "author" style.
+  (`(,(or "author" "a") . ,variant)
+   (pcase variant
+	 ((or "caps" "c") '(:mode author-only :capitalize-first t))
+	 ((or "full" "f") '(:mode a

Re: [PATCH] oc-csl: Add support for the text and year citation styles

2021-09-28 Thread András Simonyi
Thanks, I'll try to put together a patch fixing the problem and send it shortly.
best wishes,
András

On Tue, 28 Sept 2021 at 17:03, Max Nikulin  wrote:
>
> On 28/09/2021 21:40, Bastien wrote:
> > András Simonyi writes:
> >
> >> the attached patch adds support for the text (textual) and year
> >> (year-only) citation styles in the CSL org-cite processor.
> >
> > Applied, thank you very much!
>
> This patch has a problem similar to ones earlier fixed by Nicolas:
> https://orgmode.org/list/seomi1$785$1...@ciao.gmane.io "Re: citations: rx
> problems with emacs-26.3" Sun, 8 Aug 2021 20:34:55 +0700
>
> Compiling single /home/ubuntu/org-mode/lisp/oc-csl.el...
>
> In toplevel form:
> oc-csl.el:330:10:Error: Bytecode overflow
> Makefile:59: recipe for target 'oc-csl.elc' failed
> make[2]: [oc-csl.elc] Error 1 (ignored)
>
> It is for emacs-26.3 (Ubuntu-18.04 LTS bionic).



[PATCH] oc-csl: Add support for the text and year citation styles

2021-09-28 Thread András Simonyi
Dear All,

the attached patch adds support for the text (textual) and year
(year-only) citation styles in the CSL org-cite processor.

best wishes,

András
From ce91f9332ed154fd14f36177bc6dd96cdda0690e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Tue, 28 Sep 2021 11:45:13 +0200
Subject: [PATCH] oc-csl: Add support for the text and year citation styles

* lisp/oc-csl.el (org-cite-csl--create-structure-params): Introduce this new
function to map the extended list of supported citation styles and variants to
the corresponding citeproc-el citation structure creation parameters.
(org-cite-csl--no-affixes-p, org-cite-csl--capitalize-p,
org-cite-csl--no-author-p): Remove them since their functionality is provided
now by `org-cite-csl--create-structure-params'.
(org-cite-csl--parse-reference): Don't generate `suppress-author' cite
information as that is treated now by citeproc-el as a citation style.
(org-cite-csl--create-structure): Use `org-cite-csl--create-structure-params' to
generate style-dependent citation structure parameters.
---
 lisp/oc-csl.el | 95 ++
 1 file changed, 64 insertions(+), 31 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 645b1c0f9..51d3d3d8a 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -54,7 +54,10 @@
 
 ;; The library supports the following citation styles:
 ;;
+;; - author (a), including caps (c), full (f), and caps-full (cf) variants,
 ;; - noauthor (na), including bare (b), caps (c) and bare-caps (bc) variants,
+;; - year (y), including a bare (b) variant,
+;; - text (t). including caps (c), full (f), and caps-full (cf) variants,
 ;; - default style, including bare (b), caps (c) and bare-caps (bc) variants.
 
 ;; CSL styles recognize "locator" in citation references' suffix.  For example,
@@ -277,26 +280,54 @@ INFO is the export state, as a property list."
(citeproc-proc-style
 (org-cite-csl--processor info
 
-(defun org-cite-csl--no-affixes-p (citation info)
-  "Non-nil when CITATION should be exported without affix.
-INFO is the export data, as a property list."
-  (pcase (org-cite-citation-style citation info)
-(`(,(or "noauthor" "na" `nil) . ,(or "bare" "b" "bare-caps" "bc")) t)
-(_ nil)))
-
-(defun org-cite-csl--capitalize-p (citation info)
-  "Non-nil when CITATION should be capitalized.
-INFO is the export-data, as a property list."
-  (pcase (org-cite-citation-style citation info)
-(`(,(or "noauthor" "na" `nil) . ,(or "caps" "c" "bare-caps" "bc")) t)
-(_ nil)))
-
-(defun org-cite-csl--no-author-p (reference info)
-  "Non-nil when citation REFERENCE should be exported without author.
-INFO is the export data, as a property list."
-  (pcase (org-cite-citation-style (org-element-property :parent reference) info)
-(`(,(or "noauthor" "na") . ,_) t)
-(_ nil)))
+(defun org-cite-csl--create-structure-params (citation info)
+  "Return citeproc structure creation params for CITATION object.
+STYLE is the citation style, as a string or nil. INFO is the export state, as
+a property list."
+  (let* ((style (org-cite-citation-style citation info)))
+   (pcase style
+ ;; "author" style.
+ (`(,(or "author" "a") . ,(or "caps" "c"))
+  '(:mode author-only :capitalize-first t :suppress-affixes t))
+ (`(,(or "author" "a") . ,(or "full" "f"))
+  '(:mode author-only :ignore-et-al t :suppress-affixes t))
+ (`(,(or "author" "a") . ,(or "caps-full" "cf"))
+  '(:mode author-only :capitalize-first t :ignore-et-al t :suppress-affixes t))
+ (`(,(or "author" "a") . ,_)
+  '(:mode author-only :suppress-affixes t))
+ ;; "noauthor" style.
+ (`(,(or "noauthor" "na") . ,(or "bare" "b"))
+  '(:mode suppress-author :suppress-affixes t))
+ (`(,(or "noauthor" "na") . ,(or "caps" "c"))
+  '(:mode suppress-author :capitalize-first t))
+ (`(,(or "noauthor" "na") . ,(or "bare-caps" "bc"))
+  '(:mode suppress-author :suppress-affixes t :capitalize-first t))
+ (`(,(or "noauthor" "na") . ,_)
+  '(:mode suppress-author))
+ ;; "year" style.
+ (`(,(or "year" "y") . ,(or "bare" "b"))
+  '(:mode year-only :suppress-affixes t))
+ (`(,(or "year" "y") . ,_)
+  '(:mode year-only))
+ ;; "text" style.
+ (`(,(or "text" "t") . ,(or "caps" "c"))
+  '(:mode textual :capitalize-first t))
+ (`(,(or "text" "t") . ,(or "full" "f"))
+  '(:mode textual :ignore-et-al t))
+ (`(,(or "text" "t") . ,(or "caps-full" "cf"))
+  '(:mode textual :ignore-et-al t :capitalize-first t))
+ (`(,(or "text" "t") . ,_)
+  '(:mode textual))
+ ;; Default "nil" style.
+ (`(,_ . ,(or "bare" "b"))
+  '(:suppress-affixes t))
+ (`(,_ . ,(or "caps" "c"))
+  '(:capitalize-first t))
+ (`(,_ . ,(or "bare-caps" "bc"))
+  '(:suppress-affixes t :capitalize-first t))
+ (`(,_ . ,_) nil)
+ ;; This should not happen.
+ (_ (error "Invalid style: %S" style)
 
 (defun 

Re: [PATCH] org-cite: Use citeproc-el to create CSL processor itemgetters

2021-09-20 Thread András Simonyi
Hi Timothy,

> Regarding the content of this patch and the few you have planned that follow —
> would it be fair to say that overall you’re trying to update `oc-csl' based on
> changes you’ve made to `citeproc-el' since `oc-csl' was written?

yes exactly, basically all of my patches are directed towards keeping
oc-csl in sync with the changes/improvements in citeproc-el.
bes wishes,
András



[PATCH] org-cite: Use citeproc-el to create CSL processor itemgetters

2021-09-20 Thread András Simonyi
Dear All,

this is the first item in a series of oc-csl patches which I've
accumulated and am planning to send this week. (My first attempt to
send a patch, so please be patient and forgiving :-) )

This particular change removes the itemgetter constructor function
defined in oc-csl.el and uses the one now provided by citeproc-el
which has the same functionality but also supports org-bibtex
bibliographies. In addition to being a bit more featureful this change
also avoids unnecessary code duplication.

best wishes,
András
From 7cc7047516970d9e7da32e23bb11b35c8dbfae6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A1s=20Simonyi?= 
Date: Mon, 20 Sep 2021 12:41:20 +0200
Subject: [PATCH] oc-csl: Use citeproc-el to create CSL processor
 itemgetters

* lisp/oc-csl.el (org-cite-csl--processor): Citeproc-el now provides an
itemgetter constructor with all the required functionality and some more, so we
use it to create the itemgetter instead of `org-cite-csl--itemgetter' to avoid
code duplication and make use of the additional features, in particular the
ability to access bibliographies in `org-bibtex' format
(see ).
(org-cite-csl--itemgetter): Is removed since it is no longer used.
---
 lisp/oc-csl.el | 31 ++-
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index b5074dcf1..645b1c0f9 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -99,6 +99,7 @@
 (declare-function citeproc-append-citations "ext:citeproc")
 (declare-function citeproc-render-citations "ext:citeproc")
 (declare-function citeproc-render-bib "ext:citeproc")
+(declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
 
 (declare-function org-element-interpret-data "org-element" (data))
 (declare-function org-element-map "org-element" (data types fun  info first-match no-recursion with-affiliated))
@@ -336,34 +337,6 @@ or raise an error if the variable is unset."
 (other
  (user-error "Cannot handle relative style file name" other
 
-(defun org-cite-csl--itemgetter (bibliography)
-  "Return Citeproc's \"itemgetter\" function for BIBLIOGRAPHY files.
-The function handles \".bib\", \".bibtex\" and \".json\" files."
-  (let ((cache (make-hash-table :test #'equal)))
-(dolist (file bibliography)
-  (pcase (file-name-extension file)
-("json"
- (let ((json-array-type 'list)
-   (json-key-type 'symbol))
-   (dolist (item (json-read-file file))
- (puthash (cdr (assq 'id item)) item cache
-((and (or "bib" "bibtex") ext)
- (with-temp-buffer
-	   (insert-file-contents file)
-	   (goto-char (point-min))
-	   (bibtex-set-dialect (if (string= ext "bib") 'biblatex 'BibTeX) t)
-	   (bibtex-map-entries
-	(lambda (key  _)
-  (puthash key
-   (citeproc-bt-entry-to-csl (bibtex-parse-entry))
-   cache)
-(ext
- (user-error "Unknown bibliography extension: %S" ext
-(lambda (itemids)
-  (mapcar (lambda (id)
-(cons id (gethash id cache)))
-  itemids
-
 (defun org-cite-csl--locale-getter ()
   "Return a locale getter.
 The getter looks for locales in `org-cite-csl-locales-dir' directory.  If it
@@ -391,7 +364,7 @@ property in INFO."
  (processor
   (citeproc-create
(org-cite-csl--style-file info)
-   (org-cite-csl--itemgetter bibliography)
+   (citeproc-hash-itemgetter-from-any bibliography)
(org-cite-csl--locale-getter)
locale)))
 (plist-put info :cite-citeproc-processor processor)
-- 
2.25.1



Re: org-cite and pandoc

2021-08-05 Thread András Simonyi
Perhaps a useful workaround would be to first "export to Org" (with
org-org-export-as-org)?
AFAICS this replaces the Org cites with their export
processor-rendered counterparts, e.g.,
with suitable Natbib cite commands when the
#+cite_export: natbib
line is used.

best regards,
András

On Thu, 5 Aug 2021 at 16:41, Eric S Fraga  wrote:

> Indeed but even exporting without error would be good, assuming of
> course that the error I reported is actually due to org-cite.  It might
> not be; I've never exported to pandoc before!  This is for a journal
> that expects submissions in pandoc (never had this before) which (in
> some ways) is nice as at least it's not Word...
> --
> : Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-607-g185706
> : Latest paper written in org: https://arxiv.org/abs/2106.05096
>



Re: ConTeXt exporter for Org Mode

2021-08-05 Thread András Simonyi
Dear Jason,

this is excellent news, thanks for your work! I always wondered why
there is no Org exporter for ConTeXt which seemed such an obvious
target --  can't wait to try it out!

best regards,
András

On Wed, 4 Aug 2021 at 21:44, Juan Manuel Macías  wrote:
>
> Hi Jason,
>
> Jason Ross writes:
>
> > Hello,
> >
> > I have developed a ConTeXt exporter for Org Mode. It is available at
> > https://github.com/Jason-S-Ross/ox-context
> >
> > The exporter provides custom environments for each document element
> > in an effort to make customization easier, in contrast to the Pandoc
> > exporter which uses built-in environments for document elements.
> >
> > I welcome any feedback.
>
> Congratulations on your excellent work. I am not a daily ConTeXt user, and I'm
> afraid I can't help much. But I think a native exporter to ConTeXt
> could be an important addition to Org. It could be interesting for users
> who want to discover this powerful alternative to LaTeX (within the TeX
> ecosystem), as well as for users who want high-quality pdf output without
> the need for get caught up in the complexity of LaTeX packages, since
> ConTeXt has a more monolithic conception than LaTeX.
>
> Very interesting and promising, in any case.
>
> Best regards,
>
> Juan Manuel
>
>
>



Re: TMIO July Post: Introducing Citations

2021-08-03 Thread András Simonyi
Absolutely, thanks for the correction -- I meant Org's master, even
though the question was clearly about Emacs's.
best regards,
András

On Tue, 3 Aug 2021 at 12:23, Eric S Fraga  wrote:
>
> On Tuesday,  3 Aug 2021 at 12:10, András Simonyi wrote:
> > Most of the functionality described in the piece is already in the
> > master branch.
>
> No, not quite.  These latest updates are in the master branch of org
> mode but they have not yet been incorporate into the master branch of
> Emacs itself.
>
> --
> : Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-607-g185706
> : Latest paper written in org: https://arxiv.org/abs/2106.05096



Re: TMIO July Post: Introducing Citations

2021-08-03 Thread András Simonyi
Most of the functionality described in the piece is already in the
master branch.

best regards,
András

On Mon, 2 Aug 2021 at 12:36, Rudolf Adamkovič  wrote:
>
> Does anyone know when this might land in Emacs’ master branch?



Re: org-cite citation commands

2021-07-17 Thread András Simonyi
Dear Vikas,

the CSL-based processor is in a bit of a flux in this respect, but as
for the natbib and biblatex processors I've extracted these
correspondences from the oc source code, which you might find useful.
(With the exception of the first, "fully nil" styles, one always has
to use the "/" separator between "cite" and the listed combinations,
for the default styles this means a double slash, e.g.,  [cite//b@key]
leads to  \citealp{key} using the natbib processor.

* Natbib

;; default style.
--> \citep
/ [bare|b]  --> \citealp
/ [caps|c]  --> \Citep
/ [full|f]  --> \citep*
/ [bare-caps|bc]--> \Citealp
/ [bare-full|bf]--> \citealp*
/ [caps-full|cf]--> \Citep*
/ [bare-caps-full|bcf]  --> \Citealp*

;; author style.
[author|a] / [caps|c]   --> \Citeauthor
[author|a] / [full|f]   --> \citeauthor*
[author|a]  --> \citeauthor

;; noauthor style
[noauthor|na] / [bare|b]--> \citeyear
[noauthor|na]   --> \citeyearpar

;; nocite style.
[nocite|n]  --> \nocite

;; text style.
[text|t] / [bare|b] --> \citealt
[text|t] / [caps|c] --> \Citet
[text|t] / [full|f] --> \citet*
[text|t] / [bare-caps|bc]   --> \Citealt
[text|t] / [bare-full|bf]   --> \citealt*
[text|t] / [caps-full|cf]   --> \Citet*
[text|t] / [bare-caps-full|bcf] --> \Citealt*
[text|t]--> \citet

* biblatex

;; Default nil style.
  --> autocite
/ [bare|b]--> cite
/ [caps|c]--> Autocite
/ [bare-caps|b]   --> Cite

;; author style.
[author|a] / [caps|c])--> Citeauthor*
[author|a] / [full|f])--> citeauthor
[author|a] / [caps-full|cf]   --> Citeauthor
[author|a]--> citeauthor*

;; locators style.
[locators|l] / [bare|b]   --> notecite
[locators|l] / [caps|c]   --> Pnotecite
[locators|l] / [bare-caps|bc] --> Notecite
[locators|l]  --> pnotecite

;; noauthor style.
[noauthor|na] --> autocite*

;; nocite style.
[nocite|n]--> nocite

;; text style.
[text|t] / [caps|c])  --> Textcite
[text|t]  --> textcite

best regards,
András


On Sat, 17 Jul 2021 at 13:41, Vikas Rawal  wrote:
>
> I have been a long time user of org-ref and am excited to see the
> development of org-cite. Thanks a lot for this, Nicholas and others
> who have been working on this. I have been wanting to give it a spin
> for the last few days and finally got down to doing it.
>
> I am aware that the documentation is still in the works and therefore
> my apologies in advance if asking these questions is premature. I have
> looked at Nicholas' mails which provide basic documentation and have
> been trying to follow these.
>
> What is the equivalent here of the various citation commands that something 
> like biblatex or bibtex provide? The two most common citation commands I use 
> are citet and citep (or parencite). These are used to produce the following 
> kind of output using org-ref/biblatex:
>
>
> -
> * citet
>
> citet:john is an excellent resource.
>
> will be exported as:
>
> John (1990) is an excellent resource.
>
> * citep
>
> This is an excellent resource citep:john.
>
> will be exported as
>
> This is an excellent resource (John, 1990).
>
> 
>
> How does one achieve this using org-cite?
>
> I am a bit lost with the citation styles that are inbuilt in oc-biblatex.el. 
> Is it expected that we will have to write additional citation styles for 
> getting these kinds of output?
>
> Apologies if this is a naive or a premature question.
>
> Many thanks to everyone.
>
> Vikas
>



Re: oc-csl/citeproc: suffixes in cite links

2021-07-16 Thread András Simonyi
Dear Matt,

yes, oc-csl has to extract the locator information from the suffix
because CSL processors like citeproc-el work with structured locator
data. To help this extraction, ocl-csl (similarly to citeproc-org and
I think pandoc) defines a list of locator expressions to be used in
the suffix (see the commentary of oc-csl or the citeproc-org README),
for chapter one can currently use "chap.",  "chaps." or "chapter" --
hopefully replacing the citation with
[cite:@GentilcoreTastetomatoItaly2009 chap. 4] will fix the rendering,

best regards,
András

On Fri, 16 Jul 2021 at 22:40, Matt Price  wrote:
>
> (cc:ing Andras in case this issue maybe comes from citeproc)
>
> I'm having some trouble with suffixes in cite: links when the oc-csl exporter 
> is enabled, e.g. with something like this:
>
> #+cite_export: csl "/home/matt/src/styles/apa.csl"
>
> this cite:
> [cite:@GentilcoreTastetomatoItaly2009 ch4]
>
> is rendered as:
>
> (ch Gentilcore, 2009, p. 4)
>
>
> on export to HTML (in a document with no print_bibliography directive).
>
> BY contrast, ob-basic gives:
>
> (Gentilcore, David, 2009 ch4)
>
> Is oc-csl doing some extra work to process suffix, or is this likely an issue 
> with citeproc, or alternatively am I just not really understanding what ought 
> to be happening?
>
>
> Also, are other people seeing this same issue? I don't have a testing setup 
> that would allow me to easily run emacs -Q (given how much has to be 
> imported) so ... well, so, my apologies for not having done that.
>
>
> THanks,
>
> Matt
>
>



Re: Feature request: in org html export, option to disable id & class properties.

2021-07-10 Thread András Simonyi
Hello,
I'm not really familiar with the internals of the built-in html
exporter but the slimhtml exporter
[https://github.com/balddotcat/ox-slimhtml]  might be closer to what
you're looking for.

best regards,
András

On Sat, 10 Jul 2021 at 09:08, Zachary Kanfer  wrote:
>
> When I export this sample org file:
>
> * top-level header
> ** and here we have #2
>
> The body of the generated html has this content:
>
> 
>   top-level header
>   
> and here we have #2
>   
> 
>
> I would prefer the html to not have these id or class properties; something 
> like this:
>
> 
>   top-level header
>   
> and here we have #2
>   
> 
>
> Actually, I'd rather skip the divs entirely, but that is a separate issue. 
> Could there be a configurable way to disable the creation of these 
> properties? I have searched the mailing list, and have not found anything. 
> Perhaps I've missed something; there are a lot of results for "html class id" 
> or similar searches. Thanks.



Re: Citations merged!

2021-07-09 Thread András Simonyi
Amazing news, thank you very much Nicolas and to everybody else who contributed!

András

On Fri, 9 Jul 2021 at 11:47, Bruce D'Arcus  wrote:
>
> Thanks for all your work on this Nicolas: really nice job!
>
> On Fri, Jul 9, 2021, 2:54 AM Nicolas Goaziou  wrote:
>>
>> Hello,
>>
>> It took years, but citations are now full part of Org syntax.
>>
>> Thanks to everyone involved over the time!
>>
>> Now, it needs to be documented, but that will come a bit later.
>>
>> Regards,
>> --
>> Nicolas Goaziou
>>



Re: [wip-cite-new] experimental citeproc-el based activation processor

2021-06-15 Thread András Simonyi
Dear All,

thanks for the positive feedback, and sorry for the late reply.

On Sat, 12 Jun 2021 at 16:46, Nicolas Goaziou  wrote:

> It may make sense to merge it with "oc-csl.el" at some point. If that
> suits you,

Absolutely, thanks for the suggestion!

> In addition, I have a couple of comments:
>
> - As suggested by Bruce D'Arcus, we might move `org-cite-get-boundaries'
>   in `oc.el' proper, since it is also used elsewhere (at least in
>   "oc-basic.el").

sure, it makes more sense there, especially because I took the
fragment from your code IIRC (apologies for the lack of explicit
attribution)

> - Nitpick: (car element) => (org-element-type element)

I was actually wondering about this when I wrote the code and if I may
nitpick on the nitpick, I find the documentation a bit confusing in
this respect. If the list representation is meant to be
internal/private only (I guess that is the case), then maybe this
should be more explicit in the docstrings, because now the docstring
of `org-element-context' says

"Return smallest element or object around point.

Return value is a list like (TYPE PROPS) [...]"

Omitting the second part or having something like "Internally, return
value is [...]" would go a long way toward conveying the message that
one shouldn't rely on the list representation.

> - I think it is inefficient to call `org-element-context' in
>   `org-cite-csl-activate--sensor-fun'. You may as well store the parsed
>   object as a text property on the citation during fontification, and
>   read the property in the function above to know where you are.

Thanks for the suggestion, I'll certainly implement this!

> - I am also wondering about the call of `org-element-parse-buffer' in
>   `org-cite-csl-activate-render-all'. It is not wrong per se, but it is
>   only optimal when citation density in every part of the document is
>   not low. This might not be the most common case. The other option is
>   to `re-search-forward' for `org-element-citation-prefix-re' and then
>   call `org-element-context' at point.

>   Of course, optimizing `org-cite-csl-activate-render-all' may not be
>   the top priority, since some latency is to be expected anyway.

Thanks for this as well, I'll switch to the more efficient approach
you suggested.

Best regards,
András



[wip-cite-new] experimental citeproc-el based activation processor

2021-06-12 Thread András Simonyi
Dear All,

playing with the new citation API (which is already very impressive
and usable!) I cobbled together an "activation processor" which
fontifies Org citations using citeproc-el generated previews (when the
cursor is elsewhere). It also shows the full references as a tooltip
on mouse-over. Currently everything is very experimental, but if any
of you is willing to give it a try it can be found at
https://github.com/andras-simonyi/org-cite-csl-activate, and, of
course, any feedback is welcome.

best regards,
András



Re: [org-cite, oc-basic] Citation disambiguation

2021-06-06 Thread András Simonyi
Thanks, this was the case, now the basic processor disambiguates the citations.

On Sun, 6 Jun 2021 at 14:19, Bruce D'Arcus  wrote:
>
> I believe he rebased it and modified the history? So same branch.
>
> On Sun, Jun 6, 2021, 7:36 AM András Simonyi  wrote:
>>
>> Dear All,
>>
>> On Fri, 4 Jun 2021 at 23:06, Nicolas Goaziou  wrote:
>>
>> > > I think some kind of disambiguation strategy should be implemented for
>> > > the basic citation backend to be really usable with the author-year
>> > > style. WDYT?
>> >
>> > Implemented in latest wip-cite-new branch.
>> >
>> > Regards,
>>
>> Thanks, this is amazing! I was trying to look into it, but the latest
>> commit I see at
>> https://code.orgmode.org/bzg/org-mode/commits/wip-cite-new is from a
>> week ago. Is there a different location from which I can pull this
>> update?
>>
>> thanks again,
>> András
>>



Re: [org-cite, oc-basic] Citation disambiguation

2021-06-06 Thread András Simonyi
Dear All,

On Fri, 4 Jun 2021 at 23:06, Nicolas Goaziou  wrote:

> > I think some kind of disambiguation strategy should be implemented for
> > the basic citation backend to be really usable with the author-year
> > style. WDYT?
>
> Implemented in latest wip-cite-new branch.
>
> Regards,

Thanks, this is amazing! I was trying to look into it, but the latest
commit I see at
https://code.orgmode.org/bzg/org-mode/commits/wip-cite-new is from a
week ago. Is there a different location from which I can pull this
update?

thanks again,
András



[org-cite, oc-basic] Citation disambiguation

2021-06-03 Thread András Simonyi
Dear All,

experimenting with the 'basic' citation backend I noticed that the
default author-year citation style (and its derived variants, like
text and year) does not perform citation disambiguation for items that
have the same author and year. E.g. the Org document
--8<---cut here---start->8---
#+cite_export: basic author-year author-year
First: [cite:@disamb1examp]

Second: [cite:@disamb2examp]
--8<---cut here---end--->8---
is exported as
--8<---cut here---start->8---
First: (Doe, John, 1973)

Second: (Doe, John, 1973)

Doe, John (1973). /Minor Work/, Journal of Philosophy.

Doe, John (1973). /Magnum Opus/, Journal of Philosophy.
--8<---cut here---end--->8---
which makes it impossible to identify the cited item. Perhaps the most
widespread solution to this problem is to add so called year-suffixes
to the year to disambiguate:
--8<---cut here---start->8---
First: (Doe, John, 1973a)

Second: (Doe, John, 1973b)

Doe, John (1973a). /Minor Work/, Journal of Philosophy.

Doe, John (1973b). /Magnum Opus/, Journal of Philosophy.
--8<---cut here---end--->8---
I think some kind of disambiguation strategy should be implemented for
the basic citation backend to be really usable with the author-year
style. WDYT?

best regards,
András



Re: [org-cite, oc-csl] print_bibliography options

2021-05-31 Thread András Simonyi
Dear All,

I think a useful default/baseline for handling the occurrence of
multiple #+print_bibliography keywords  would be to implement the
"chapter use case", which, for each #+print_bibliography, would
collect only the citations occurring after to previous
#+print_bibliography (if there is one) and before the current one, and
print out an independent bibliography corresponding to the citations.
All citations in this section would refer to this bibliography, and
would be disambiguated accordingly.

This could be implemented without any dedicated support on the
processor's side, the basic processor could support this as well.
Sectioned bibliographies, on the other hand, seem to be more
complicated, and require processor-side support.

best regards,
András



Re: [wip-cite-new] Initial implementation of `csl' citation processor

2021-05-31 Thread András Simonyi
Dear All,

On Sat, 29 May 2021 at 18:22, Nicolas Goaziou  wrote:

> Here's another proposal:
>
> `org-cite-export-processor' is now an alist, where keys are export
> back-ends or t, which is the default key.
>
>   '((latex biblatex bibstyle citestyle)
> (beamer natbib nil nil)
> (my-latex natbib bibstyle)
> (t csl nil nil))
> The selected processor is the one associated to the back-ends closest to
> the current one used for export, by `org-export-derived-backend-p'
> order. So if `my-other-latex' is derived from beamer, it will use
> (natbib nil nil).

This looks perfect.

> OTOH, I suggest to stick to a single "cite_export" keyword, which
> overrides any selected processor above. IOW
>
>#+cite_export: basic
>
> will use basic whatever the current export back-end is.
>
> In practice, I think it is sufficient. The only case where it may be
> limiting is if you need to export with two different back-ends with two
> processors different from those set in `org-cite-export-processor'. But
> in that situation, I think swapping the cite_export keyword is
> acceptable.
>
> So overall, I think it is a good compromise between simplicity and
> power.

> WDYT?

I agree, can be revisited later if necessary, but seems to be  a very
strong starting point -- thanks.

best regards,
András



  1   2   >