pkg update and first config fix
org-brain not working, add org-roam
This commit is contained in:
@@ -47,6 +47,8 @@
|
||||
(defvar hfy-user-sheet-assoc) ; to quiet compiler
|
||||
|
||||
(require 'ox-org)
|
||||
(if (executable-find "pandoc")
|
||||
(require 'ox-pandoc))
|
||||
|
||||
(require 'citeproc)
|
||||
|
||||
@@ -56,14 +58,15 @@
|
||||
(md . plain)
|
||||
(org . org)
|
||||
(ascii . plain)
|
||||
(odt . org-odt))
|
||||
(odt . org-odt)
|
||||
(docx . org))
|
||||
"Mapping of export backend to csl-backends."
|
||||
:type '(alist :key-type (symbol) :value-type (symbol))
|
||||
:group 'org-ref)
|
||||
|
||||
|
||||
(defcustom org-ref-cite-internal-links 'auto
|
||||
"Should be on of
|
||||
"Should be one of
|
||||
- 'bib-links :: link cites to bibliography entries
|
||||
- 'no-links :: do not link cites to bibliography entries
|
||||
- nil or 'auto :: add links based on the style."
|
||||
@@ -120,6 +123,19 @@ See https://github.com/citation-style-language/documentation/blob/master/specifi
|
||||
:group 'org-ref)
|
||||
|
||||
|
||||
(defcustom org-ref-export-suppress-affix-types
|
||||
'("citet"
|
||||
"citet*"
|
||||
"citetitle"
|
||||
"citeyear"
|
||||
"citeauthor"
|
||||
"citenum"
|
||||
"textcite")
|
||||
"List of cite types to suppress affixes (usually parentheses) on."
|
||||
:type '(list (repeat string))
|
||||
:group 'org-ref)
|
||||
|
||||
|
||||
(defun org-ref-dealias-label (alias)
|
||||
"Return the full, de-aliased label for ALIAS.
|
||||
Looked up from `org-ref-csl-label-aliases'.
|
||||
@@ -164,17 +180,18 @@ REF is a plist data structure returned from `org-ref-parse-cite-path'."
|
||||
;; e.g. {5, 6 and 12}, because he had 3 books.
|
||||
|
||||
(if (and (string-match
|
||||
(rx
|
||||
;; optional label
|
||||
(group-n 1 (optional
|
||||
(regexp (regexp-opt (cl-loop for (abbrvs . full)
|
||||
in org-ref-csl-label-aliases
|
||||
append (append abbrvs (list full)))))))
|
||||
(optional (one-or-more space))
|
||||
;; number or numeric ranges
|
||||
(group-n 2 (one-or-more digit) (optional "-" (one-or-more digit)))
|
||||
;; everything else
|
||||
(group-n 3 (* ".")))
|
||||
(rx-to-string
|
||||
`(seq
|
||||
;; optional label
|
||||
(group-n 1 (optional
|
||||
(regexp ,(regexp-opt (cl-loop for (abbrvs . full)
|
||||
in org-ref-csl-label-aliases
|
||||
append (append abbrvs (list full)))))))
|
||||
(optional (one-or-more space))
|
||||
;; number or numeric ranges
|
||||
(group-n 2 (one-or-more digit) (optional "-" (one-or-more digit)))
|
||||
;; everything else
|
||||
(group-n 3 (* "."))))
|
||||
full-suffix)
|
||||
(match-string 2 full-suffix)
|
||||
(not (string= "" (match-string 2 full-suffix))))
|
||||
@@ -233,7 +250,7 @@ BACKEND is the org export backend."
|
||||
((file-exists-p style)
|
||||
style)
|
||||
;; In a user-dir
|
||||
((and (boundp 'org-cite-csl-styles-dir)
|
||||
((and (bound-and-true-p org-cite-csl-styles-dir)
|
||||
(file-exists-p (f-join org-cite-csl-styles-dir style)))
|
||||
(f-join org-cite-csl-styles-dir style))
|
||||
;; provided by org-ref
|
||||
@@ -249,15 +266,13 @@ BACKEND is the org export backend."
|
||||
(error "%s not found" style)))
|
||||
;; item-getter
|
||||
;; (citeproc-itemgetter-from-bibtex (org-ref-find-bibliography))
|
||||
(citeproc-hash-itemgetter-from-any (org-ref-find-bibliography))
|
||||
(citeproc-hash-itemgetter-from-any (org-ref-find-bibliography) t)
|
||||
;; locale getter
|
||||
(citeproc-locale-getter-from-dir (cond
|
||||
((boundp 'org-cite-csl-locales-dir)
|
||||
org-cite-csl-locales-dir)
|
||||
(t
|
||||
(citeproc-locale-getter-from-dir (if (bound-and-true-p org-cite-csl-locales-dir)
|
||||
org-cite-csl-locales-dir
|
||||
(f-join (file-name-directory
|
||||
(locate-library "org-ref"))
|
||||
"citeproc/csl-locales"))))
|
||||
"citeproc/csl-locales")))
|
||||
;; the actual locale
|
||||
locale))
|
||||
|
||||
@@ -292,12 +307,9 @@ BACKEND is the org export backend."
|
||||
;; https://github.com/andras-simonyi/citeproc-el#creating-citation-structures
|
||||
(citeproc-citation-create
|
||||
:cites cites
|
||||
;; TODO: proof of concept, incomplete if this is
|
||||
;; true, the citation is not parenthetical
|
||||
:suppress-affixes (let ((type (org-element-property :type cl)))
|
||||
(when (member type '("citet"
|
||||
"citet*"
|
||||
"citenum"))
|
||||
(when (member type
|
||||
org-ref-export-suppress-affix-types)
|
||||
t))
|
||||
|
||||
;; TODO: this is proof of concept, and not complete.
|
||||
@@ -324,14 +336,17 @@ BACKEND is the org export backend."
|
||||
(org-element-property :type cl) 0 1))
|
||||
;; I don't know where this information would come from.
|
||||
:note-index nil
|
||||
:ignore-et-al nil))))
|
||||
:ignore-et-al nil
|
||||
:grouped nil))))
|
||||
|
||||
(rendered-citations (progn (citeproc-append-citations cites proc)
|
||||
(citeproc-render-citations proc csl-backend org-ref-cite-internal-links)))
|
||||
;; I only use the returned bibliography string. citeproc returns a
|
||||
;; bunch of other things related to offsets and linespacing, but I
|
||||
;; don't know what you do with these, so just ignore them here.
|
||||
(rendered-bib (car (citeproc-render-bib proc csl-backend)))
|
||||
(bibdata (citeproc-render-bib proc csl-backend))
|
||||
(rendered-bib (car bibdata))
|
||||
(bib-parameters (cdr bibdata))
|
||||
;; The idea is we will wrap each citation and the bibliography in
|
||||
;; org-code so it exports appropriately.
|
||||
(cite-formatters '((html . "@@html:%s@@")
|
||||
@@ -357,6 +372,42 @@ BACKEND is the org export backend."
|
||||
(org-element-property :post-blank cl) 0)
|
||||
? )))))
|
||||
|
||||
;; Decorate the bibliography for different outputs adapted from
|
||||
;; `org-cite-csl-render-bibliography' in oc-csl I don't know what all
|
||||
;; these do or how to use them in the CSS for html, or LaTeX. This is to
|
||||
;; fix an annoying HTML feature that has an extra line in the numbering.
|
||||
;; This seems to do the right thing. I don't support hanging-indent like
|
||||
;; oc-csl does, and I don't currently support LaTeX here. It already does
|
||||
;; a good job there.
|
||||
;;
|
||||
;; (find-library "oc-csl")
|
||||
;;
|
||||
;; Here are some examples of what is in the bib-parameters.
|
||||
;; (max-offset . 2) (hanging-indent) (second-field-align . flush)
|
||||
;; (entry-spacing . 0)
|
||||
;; (line-spacing . 2)
|
||||
;;
|
||||
;; Here we add style css for html output.
|
||||
(cond
|
||||
((eq 'html backend)
|
||||
(let ((s1 "")
|
||||
(s2 ""))
|
||||
(when (cdr (assq 'second-field-align bib-parameters))
|
||||
(setq s1 (format
|
||||
"<style>.csl-left-margin{float: left; padding-right: 0em;}
|
||||
.csl-right-inline{margin: 0 0 0 %dem;}</style>"
|
||||
;; I hard coded this factor of 0.6 from the oc-csl code.
|
||||
(* 0.6 (or (cdr (assq 'max-offset bib-parameters)) 0)))))
|
||||
|
||||
;; hard-coded the hanging indent. oc-csl uses a variable for this. I
|
||||
;; guess we could too, but this seems simpler.
|
||||
(when (cdr (assq 'hanging-indent bib-parameters))
|
||||
(setq s2 "<style>.csl-entry{text-indent: -1.5em; margin-left: 1.5em;}</style>"))
|
||||
|
||||
(setq rendered-bib (concat
|
||||
s1 s2
|
||||
rendered-bib)))))
|
||||
|
||||
;; replace the bibliography
|
||||
(org-element-map (org-element-parse-buffer) 'link
|
||||
(lambda (lnk)
|
||||
@@ -391,6 +442,7 @@ VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
(extensions '((html . ".html")
|
||||
(latex . ".tex")
|
||||
(ascii . ".txt")
|
||||
(md . ".md")
|
||||
(odt . ".odf")))
|
||||
(cp (point))
|
||||
(mm) ;marker to save place
|
||||
@@ -407,7 +459,6 @@ VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
(org-export-expand-include-keyword)
|
||||
(goto-char (marker-position mm))
|
||||
(org-ref-process-buffer backend subtreep)
|
||||
(message-box (buffer-substring (line-beginning-position) (line-end-position)))
|
||||
(set-marker mm nil)
|
||||
|
||||
(pcase backend
|
||||
@@ -415,6 +466,11 @@ VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
('odt (org-open-file (org-odt-export-to-odt async subtreep visible-only
|
||||
info)
|
||||
'system))
|
||||
;; for pandoc, we mean make a docx via pandoc
|
||||
('docx (org-open-file (plist-get (org-pandoc-export-to-docx async subtreep visible-only
|
||||
body-only info)
|
||||
'output-file)
|
||||
'system))
|
||||
(_
|
||||
(org-open-file (org-export-to-file backend export-name
|
||||
async subtreep visible-only
|
||||
@@ -443,14 +499,25 @@ VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
body-only info))
|
||||
|
||||
|
||||
(defun org-ref-export-to-md (&optional async subtreep visible-only
|
||||
body-only info)
|
||||
"Export the buffer to md and open.
|
||||
See `org-export-as' for the meaning of ASYNC SUBTREEP
|
||||
VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
(org-ref-export-to 'md async subtreep visible-only
|
||||
body-only info))
|
||||
|
||||
|
||||
(defun org-ref-export-to-pdf (&optional async subtreep visible-only
|
||||
body-only info)
|
||||
"Export the buffer to PDF via LaTeX and open.
|
||||
See `org-export-as' for the meaning of ASYNC SUBTREEP
|
||||
VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
(let ((org-export-before-parsing-hook '(org-ref-csl-preprocess-buffer)))
|
||||
(let ((org-export-before-parsing-hook (append
|
||||
org-export-before-parsing-hook
|
||||
'(org-ref-csl-preprocess-buffer))))
|
||||
(org-open-file (org-latex-export-to-pdf async subtreep visible-only
|
||||
body-only info))))
|
||||
body-only info))))
|
||||
|
||||
|
||||
(defun org-ref-export-to-latex (&optional async subtreep visible-only
|
||||
@@ -473,6 +540,15 @@ VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
body-only info))
|
||||
|
||||
|
||||
(defun org-ref-export-to-docx (&optional async subtreep visible-only
|
||||
body-only info)
|
||||
"Export the buffer to docx via pandoc and open.
|
||||
See `org-export-as' for the meaning of ASYNC SUBTREEP
|
||||
VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
(org-ref-export-to 'docx async subtreep visible-only
|
||||
body-only info))
|
||||
|
||||
|
||||
(defun org-ref-export-as-org (&optional _async subtreep visible-only
|
||||
body-only info)
|
||||
"Export the buffer to an ORG buffer and open.
|
||||
@@ -510,12 +586,14 @@ VISIBLE-ONLY BODY-ONLY and INFO."
|
||||
:menu-entry
|
||||
'(?r "Org-ref export"
|
||||
((?a "to Ascii" org-ref-export-to-ascii)
|
||||
(?m "to markdown" org-ref-export-to-md)
|
||||
(?h "to html" org-ref-export-to-html)
|
||||
(?l "to LaTeX" org-ref-export-to-latex)
|
||||
(?p "to PDF" org-ref-export-to-pdf)
|
||||
(?o "to ODT" org-ref-export-to-odt)
|
||||
(?O "to Org buffer" org-ref-export-as-org)
|
||||
(?e "to email" org-ref-export-to-message))))
|
||||
(?e "to email" org-ref-export-to-message)
|
||||
(?w "to docx" org-ref-export-to-docx))))
|
||||
|
||||
;; An alternative to this exporter is to use an `org-export-before-parsing-hook'
|
||||
;; (add-hook 'org-export-before-parsing-hook 'org-ref-csl-preprocess-buffer)
|
||||
|
||||
Reference in New Issue
Block a user