pkg update and first config fix
org-brain not working, add org-roam
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'let-alist)
|
||||
(require 'subr-x)
|
||||
(require 's)
|
||||
(require 'cl-lib)
|
||||
@@ -137,15 +138,39 @@ If ANCHOR is string= to TARGET then return ANCHOR."
|
||||
(href . ,#'citeproc-fmt--org-link)
|
||||
(cited-item-no . ,(lambda (x y) (concat "[[citeproc_bib_item_" y "][" x "]]")))
|
||||
(bib-item-no . ,(lambda (x y) (concat "<<citeproc_bib_item_" y ">>" x)))
|
||||
(font-style-italic . ,(lambda (x) (concat "/" x "/")))
|
||||
(font-style-oblique . ,(lambda (x) (concat "/" x "/")))
|
||||
;; Warning: The next four formatter lines put protective zero-width spaces
|
||||
;; around the Org format characters ('/' etc.).
|
||||
(font-style-italic . ,(lambda (x) (concat "/" x "/")))
|
||||
(font-style-oblique . ,(lambda (x) (concat "/" x "/")))
|
||||
(font-weight-bold . ,(lambda (x) (concat "*" x "*")))
|
||||
(text-decoration-underline . ,(lambda (x) (concat "_" x "_")))
|
||||
;; End of zero-width space protected formatters.
|
||||
(font-variant-small-caps . ,(lambda (x) (upcase x)))
|
||||
(font-weight-bold . ,(lambda (x) (concat "*" x "*")))
|
||||
(text-decoration-underline . ,(lambda (x) (concat "_" x "_")))
|
||||
(vertical-align-sub . ,(lambda (x) (concat "_{" x "}")))
|
||||
(vertical-align-sup . ,(lambda (x) (concat "^{" x "}")))
|
||||
(display-left-margin . ,(lambda (x) (concat x " ")))))
|
||||
|
||||
(defvar citeproc-fmt--org-format-rt-1
|
||||
(citeproc-formatter-fun-create citeproc-fmt--org-alist)
|
||||
"Recursive rich-text Org formatter.
|
||||
Doesn't do finalization by removing zero-width spaces.")
|
||||
|
||||
(defun citeproc-fmt--org-format-rt (rt)
|
||||
"Convert rich-text RT into Org format.
|
||||
Performs finalization by removing unnecessary zero-width spaces."
|
||||
(let ((result (funcall citeproc-fmt--org-format-rt-1 rt)))
|
||||
(when (> (length result) 2)
|
||||
;; First we remove z-w spaces around spaces and before punctuation.
|
||||
(setq result (citeproc-s-replace-all-seq
|
||||
result '((" " . " ") (" " . " ") ("," . ",") (";" . ";")
|
||||
(":" . ":") ("." . "."))))
|
||||
;; Starting and ending z-w spaces are also removed.
|
||||
(when (= (aref result 0) 8203)
|
||||
(setq result (substring result 1)))
|
||||
(when (= (aref result (- (length result) 1)) 8203)
|
||||
(setq result (substring result 0 -1))))
|
||||
result))
|
||||
|
||||
;; HTML
|
||||
|
||||
(defun citeproc-fmt--xml-escape (s)
|
||||
@@ -251,6 +276,36 @@ CSL tests."
|
||||
(vertical-align-sub . ,(lambda (x) (concat "\\textsubscript{" x "}")))
|
||||
(font-style-oblique . ,(lambda (x) (concat "\\textsl{" x "}")))))
|
||||
|
||||
;; Org-LaTeX
|
||||
|
||||
(defconst citeproc-fmt--org-latex-alist
|
||||
`((unformatted . ,#'citeproc-fmt--latex-escape)
|
||||
(href . ,#'citeproc-fmt--latex-href)
|
||||
(font-style-italic . ,(lambda (x) (concat "\\textit{" x "}")))
|
||||
(font-weight-bold . ,(lambda (x) (concat "\\textbf{" x "}")))
|
||||
(cited-item-no . ,(lambda (x y) (concat "\\cslcitation{" y "}{" x "}")))
|
||||
(bib-item-no . ,(lambda (x y) (concat "\\cslbibitem{" y "}{" x "}")))
|
||||
(font-variant-small-caps . ,(lambda (x) (concat "\\textsc{" x "}")))
|
||||
(text-decoration-underline . ,(lambda (x) (concat "\\underline{" x "}")))
|
||||
(vertical-align-sup . ,(lambda (x) (concat "\\textsuperscript{" x "}")))
|
||||
(display-left-margin . ,(lambda (x) (concat "\\cslleftmargin{" x "}")))
|
||||
(display-right-inline . ,(lambda (x) (concat "\\cslrightinline{" x "}")))
|
||||
(display-block . ,(lambda (x) (concat "\\cslblock{" x "}")))
|
||||
(display-indent . ,(lambda (x) (concat "\\cslindent{" x "}")))
|
||||
(vertical-align-sub . ,(lambda (x) (concat "\\textsubscript{" x "}")))
|
||||
(font-style-oblique . ,(lambda (x) (concat "\\textsl{" x "}")))))
|
||||
|
||||
(defun citeproc-fmt--org-latex-bib-formatter (items bib-format)
|
||||
"Return an Org LaTeX bibliography of ITEMS formatted in BIB-FORMAT."
|
||||
(let-alist bib-format
|
||||
(let ((hanging-indent (if .hanging-indent "1" "0"))
|
||||
(entry-spacing (if (and .entry-spacing (<= 1 .entry-spacing))
|
||||
(number-to-string (- .entry-spacing 1))
|
||||
"0")))
|
||||
(concat "\\begin{cslbibliography}{" hanging-indent "}{" entry-spacing "}\n"
|
||||
(mapconcat #'identity items "\n\n")
|
||||
"\n\n\\end{cslbibliography}\n"))))
|
||||
|
||||
;; Org-ODT
|
||||
|
||||
(defconst citeproc-fmt--org-odt-alist
|
||||
@@ -311,8 +366,10 @@ CSL tests."
|
||||
:bib #'citeproc-fmt--html-bib-formatter
|
||||
:no-external-links t))
|
||||
(raw . ,(citeproc-formatter-create :rt #'identity :bib (lambda (x _) x)))
|
||||
(org . ,(citeproc-formatter-create
|
||||
:rt (citeproc-formatter-fun-create citeproc-fmt--org-alist)))
|
||||
(org . ,(citeproc-formatter-create :rt #'citeproc-fmt--org-format-rt))
|
||||
(org-latex . ,(citeproc-formatter-create
|
||||
:rt (citeproc-formatter-fun-create citeproc-fmt--org-latex-alist)
|
||||
:bib #'citeproc-fmt--org-latex-bib-formatter))
|
||||
(latex . ,(citeproc-formatter-create
|
||||
:rt (citeproc-formatter-fun-create citeproc-fmt--latex-alist)))
|
||||
(plain . ,(citeproc-formatter-create :rt #'citeproc-rt-to-plain
|
||||
|
||||
Reference in New Issue
Block a user