Skip to content

Commit

Permalink
Merge pull request #161 from andras-simonyi/160-Fix_org_superscript_r…
Browse files Browse the repository at this point in the history
…endering

Fix org formatter's leading superscript rendering
  • Loading branch information
andras-simonyi authored May 5, 2024
2 parents 44f90cb + 725d2ce commit 6e6068b
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 6e6068b

Please sign in to comment.