aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Hinman <lee@writequit.org>2016-09-06 19:01:29 -0600
committerLee Hinman <lee@writequit.org>2016-09-06 19:01:29 -0600
commitfe7e7cec0559acdaeb89d6dc99e50ad698723207 (patch)
treef1a09a0e180c9db17dadab92a6b6cfe9a2fbca2b
parent921289bc2c84915fe3bf3724f1ca94a5eb816510 (diff)
downloadox-tufte-fe7e7cec0559acdaeb89d6dc99e50ad698723207.tar.gz
ox-tufte-fe7e7cec0559acdaeb89d6dc99e50ad698723207.zip
Correctly render non-inline footnotes in Tufte style
Footnotes that weren't inline included extra `<p>` and `</p>` tags that messed up tufte css. This strips those from footnotes and margin notes so any format of footnote works. Resolves #4
-rw-r--r--ox-tufte.el21
1 files changed, 12 insertions, 9 deletions
diff --git a/ox-tufte.el b/ox-tufte.el
index dea1901..5aca601 100644
--- a/ox-tufte.el
+++ b/ox-tufte.el
@@ -33,6 +33,7 @@
;;; Code:
(require 'ox)
+(require 'ox-html)
;;; User-Configurable Variables
@@ -118,10 +119,12 @@ plist holding contextual information."
"<span class=\"sidenote\">%s</span>")
(org-export-get-footnote-number footnote-reference info)
(org-export-get-footnote-number footnote-reference info)
- (org-trim
- (org-export-data
- (org-export-get-footnote-definition footnote-reference info)
- info))))
+ (let ((fn-data (org-trim
+ (org-export-data
+ (org-export-get-footnote-definition footnote-reference info)
+ info))))
+ ;; footnotes must have spurious <p> tags removed or they will not work
+ (replace-regexp-in-string "</?p.*>" "" fn-data))))
(defun org-tufte-maybe-margin-note-link (link desc info)
"Render LINK as a margin note if it starts with `mn:', for
@@ -139,7 +142,7 @@ link. INFO is a plist holding contextual information."
"<input type=\"checkbox\" id=\"%s\" class=\"margin-toggle\"/>"
"<span class=\"marginnote\">%s</span>")
(cadr path) (cadr path)
- desc)
+ (replace-regexp-in-string "</?p.*>" "" desc))
(org-html-link link desc info))))
(defun org-tufte-src-block (src-block contents info)
@@ -226,10 +229,10 @@ publishing directory.
Return output file name."
(org-publish-org-to 'tufte-html filename
- (concat "." (or (plist-get plist :html-extension)
- org-html-extension
- "html"))
- plist pub-dir))
+ (concat "." (or (plist-get plist :html-extension)
+ org-html-extension
+ "html"))
+ plist pub-dir))
(provide 'ox-tufte)