Skip to content

Commit

Permalink
Fix org formatter's leading superscript rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
andras-simonyi committed May 5, 2024
1 parent 44f90cb commit 725d2ce
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions citeproc-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,18 @@ Performs finalization by removing unnecessary zero-width spaces."
(setq result (citeproc-s-replace-all-seq
result '(("" . " ") ("" . " ") ("​," . ",") ("​;" . ";")
("​:" . ":") ("​." . "."))))
;; Starting and ending z-w spaces are also removed, but not before an
;; asterisk to avoid creating an Org heading.
;; Starting and ending z-w spaces are also removed, but not before an asterisk
;; to avoid creating an Org heading.
(when (and (= (aref result 0) 8203)
(not (= (aref result 1) ?*)))
(setq result (substring result 1)))
(when (= (aref result (- (length result) 1)) 8203)
(setq result (substring result 0 -1))))
(setq result (substring result 0 -1)))
;; Prepend a zero width no-break space when the text starts with
;; superscript to make Org parse it correctly.
;; NOTE: This is a workaround, ideally should be fixed in Org.
(when (= (aref result 0) ?^)
(setq result (concat "" result))))
result))

;; HTML
Expand Down

0 comments on commit 725d2ce

Please sign in to comment.