* org and htmlfontify
@ 2009-09-19 22:41 David O'Toole
0 siblings, 0 replies; only message in thread
From: David O'Toole @ 2009-09-19 22:41 UTC (permalink / raw)
To: emacs-orgmode
Hello orgmoders. I thought I would share my custom publishing function
for using htmlfontify together with org-publish to automatically convert
Lisp source code files into HTML with my own custom-inserted anchors.
The lisp snippet is below. This was used to make the HTML links in my
developer documentation properly jump to particular headings in the
HTMLfontified output (try the page and see what I mean:
http://dto.github.com/notebook/developers-guide.html
I am also working something else org-related:
http://dto.github.com/notebook/folio.html
(defun spaces-to-underscores (string)
(save-match-data
(with-temp-buffer
(insert string)
(goto-char (point-min))
(while (re-search-forward " \\|-" nil t) ;; and dashes!
(replace-match "_"))
(buffer-substring-no-properties (point-min) (point-max)))))
(defun publish-lisp-to-html (plist filename pub-dir)
(interactive)
(let* ((dir (file-name-directory filename))
(base (file-name-sans-extension (file-name-nondirectory filename)))
(target (expand-file-name (concat base ".html") pub-dir))
(html nil)
(hfy-src-doc-link-style "color: #a020f0; font-weight: bold;")
(hfy-sec-doc-link-unstyle " color: #4d4d4d;"))
(with-current-buffer (find-file-noselect filename)
(hfy-force-fontification)
(setf html (hfy-fontify-buffer dir filename)))
(with-current-buffer html
;; add anchors for all three-semicolon headings
(goto-char (point-min))
(while (re-search-forward ";;;[^@]*@@ \\([^<>]*\\)" nil t)
(message "matched %s" (match-string-no-properties 1))
(replace-match (format ";;; <a name=\"%s\">@@ %s</a>"
(spaces-to-underscores (match-string-no-properties 1))
(match-string-no-properties 1))))
(write-file target nil))
(kill-buffer html)))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-19 22:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-19 22:41 org and htmlfontify David O'Toole
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).