Skip to content

Commit

Permalink
Add an option to preserve the buffer file path in the exported html
Browse files Browse the repository at this point in the history
If the buffer file path is "/a/b/c.txt", the exported html file name becomes
"!a!b!c.txt.html".

That file is still exported to `htmlize-r2f-output-directory'.
  • Loading branch information
kaushalmodi committed Jan 4, 2017
1 parent 6d8d007 commit 7f55142
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion elisp/htmlize-r2f/htmlize-r2f.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"misc/css/leuven_theme.css")
"CSS file to be embedded in the exported html file.")

(defvar htmlize-r2f-preserve-file-path-in-name nil
"When non-nil, the generated html file name contains the full path.
If the buffer file path is \"/a/b/c.txt\", the exported html file name becomes
\"!a!b!c.txt.html\". That file is still exported to `htmlize-r2f-output-directory'.")

(defun htmlize-r2f (option)
"Export the selected region/whole buffer to an html file.
Expand All @@ -34,7 +39,9 @@ prefix), do the above and also open the html file in the default browser."
(org-html-htmlize-font-prefix "org-")
(fname (concat htmlize-r2f-output-directory
(if (buffer-file-name)
(file-name-nondirectory (buffer-file-name))
(if htmlize-r2f-preserve-file-path-in-name
(replace-regexp-in-string "/" "!" (buffer-file-name))
(file-name-nondirectory (buffer-file-name)))
"temp")
".html"))
start end html-string)
Expand Down

0 comments on commit 7f55142

Please sign in to comment.