Skip to content

Instantly share code, notes, and snippets.

@raulrpearson
Last active July 7, 2017 14:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raulrpearson/43f19505e1995564248d6869ad67b7a9 to your computer and use it in GitHub Desktop.
Save raulrpearson/43f19505e1995564248d6869ad67b7a9 to your computer and use it in GitHub Desktop.
Org-mode subtree to HTML for Modelica documentation
(defun myelisp-subtree-to-html ()
"Create buffer with HTML export from org subtree at point."
(interactive)
;; Setup
(split-window-right)
(org-html-export-as-html nil 1 nil 1)
(html-mode)
;; Substitutions
(replace-regexp
"[\.]+/Resources"
"modelica://PVSystems/Resources"
nil (point-min) (point-max))
(replace-string "\"" "\\\"" nil (point-min) (point-max))
(replace-string "<i>" "<em>" nil (point-min) (point-max))
(replace-string "</i>" "</em>" nil (point-min) (point-max))
(replace-string "<b>" "<strong>" nil (point-min) (point-max))
(replace-string "</b>" "</strong>" nil (point-min) (point-max))
(goto-char (point-min))
(insert "<html>\n")
(goto-char (point-max))
(insert "</html>")
;; Formatting
(set-fill-column 60)
;; (setq fill-prefix " ")
(indent-region (point-min) (point-max))
(fill-region (point-min) (point-max))
(indent-region (point-min) (point-max))
(fill-region (point-min) (point-max))
(kill-new (buffer-string)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment