From: David O'Toole <dto1138@gmail.com>
To: emacs-orgmode@gnu.org
Subject: org and htmlfontify
Date: Sat, 19 Sep 2009 18:41:15 -0400 [thread overview]
Message-ID: <1253400075.3121.9.camel@vomac> (raw)
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)))
reply other threads:[~2009-09-19 22:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1253400075.3121.9.camel@vomac \
--to=dto1138@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).