oc-biblatex: Allow native biblatex options in CITE_EXPORT

* lisp/oc-biblatex.el: (org-cite-biblatex--package-options) Add support
for options in the native biblatex package format.
* doc/org-manual.org: Document the added format and add an example.
* etc/ORG-NEWS: Announce new format for #+cite_export biblatex options.
This commit is contained in:
Pedro A. Aranda 2024-04-25 07:21:45 +02:00 committed by Ihor Radchenko
parent e4ab416fcc
commit f124b616d9
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
3 changed files with 31 additions and 17 deletions

View File

@ -17631,9 +17631,14 @@ your LaTeX installation, it won't export to anything but PDF.
specifies the =biblatex= export processor with the default =numeric=
style and the =bibtex= backend. Always define the style first and then
the rest of load-time options for the =biblatex=
package. Alternatively, use the ~org-cite-biblatex-options~ variable
in your Emacs configuration. It will only export to PDF, since it
relies on the ~biblatex~ processor of your LaTeX installation;
package. Alternatively, you can use the ~key=val,key=val~ format for
the options as documented in the =biblatex= package documentation:
: #+cite_export: biblatex backend=bibtex,style=numeric
The ~org-cite-biblatex-options~ variable in your Emacs configuration
uses this format. It will only export to PDF, since it relies on the
~biblatex~ processor of your LaTeX installation.
** Bibliography printing

View File

@ -1021,6 +1021,12 @@ The option can be customized either by
group or
2. by setting the file local keyword =LATEX_FOOTNOTE_COMMAND=
*** Options for ~#+cite_export: biblatex~ can use the package's option syntax
When using =biblatex= to export bibliographies, you can use the format
as specified in the =biblatex= package documentation as
=key=val,key=val,...=
** New features
*** =ob-lua=: Support all types and multiple values in results

View File

@ -190,20 +190,23 @@ INITIAL is an initial style of comma-separated options, as a string or nil.
STYLE is the style definition as a string or nil.
Return a string."
(let ((options-no-style
(and initial
(let ((re (rx string-start (or "bibstyle" "citestyle" "style"))))
(seq-filter
(lambda (option) (not (string-match re option)))
(split-string (org-unbracket-string "[" "]" initial)
"," t " \t")))))
(style-options
(cond
((null style) nil)
((not (string-match "/" style)) (list (concat "style=" style)))
(t
(list (concat "bibstyle=" (substring style nil (match-beginning 0)))
(concat "citestyle=" (substring style (match-end 0))))))))
(let* ((options-no-style
(and initial
(let ((re (rx string-start (or "bibstyle" "citestyle" "style"))))
(seq-filter
(lambda (option) (not (string-match re option)))
(split-string (org-unbracket-string "[" "]" initial)
"," t " \t")))))
;; Check whether the string is in key=val,...
(biblatex-options-p (and (stringp style) (string-match-p "\\`[^,=]+=[^,]+\\(,[^=]+=[^,]+\\)\\'" style)))
(style-options
(cond
((null style) nil)
;; Assume it is a valid options string for biblatex if it is in key=val,... format
((not (string-match "/" style)) (list (if biblatex-options-p style (concat "style=" style))))
(t
(list (concat "bibstyle=" (substring style nil (match-beginning 0)))
(concat "citestyle=" (substring style (match-end 0))))))))
(if (or options-no-style style-options)
(format "[%s]"
(mapconcat #'identity