[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Re: to bookmarks
From: |
Matt Lundin |
Subject: |
[Orgmode] Re: to bookmarks |
Date: |
Sat, 26 Sep 2009 15:39:09 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (darwin) |
andrea Crotti <address@hidden> writes:
> Bookmarks from org-mode:
>
> I insert many many links inside my orgmode but sometimes I would also like
> to have them in my
> browsers (safari and firefox sometimes).
>
> Is there already something working out of the box?
>
> The hierarchy like
> <file.org>
> * level1
> ** level2
> [[http://sito.com][sito]]
>
> Should maybe create directories, for a cleaner view..
I've been looking for similar functionality for a while so I hacked up a
simple function to export the bookmarks of an org file as an html file,
which can then -- at least theoretically ;) -- be imported into your
favorite web browser. I'm an elisp novice, but it seems to work:
--8<---------------cut here---------------start------------->8---
(defun org-export-html-bookmarks ()
"Extract bookmarks from the current org file and create an html file that
can be imported into a web browser."
(interactive)
(let ((file (file-name-nondirectory (buffer-file-name)))
bookmarks)
(save-excursion
(goto-char (point-min))
(while (re-search-forward org-bracket-link-analytic-regexp nil t)
(when (equal (match-string 2) "http")
(let ((url (concat (match-string 1)
(match-string 3)))
(desc (org-substring-no-properties (match-string 5))))
(push (concat "<DT><A HREF=\"" url "\">" desc "</A>\n") bookmarks))))
(with-temp-buffer
(insert
"<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
"<HTML>\n"
"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;
charset=UTF-8\">\n"
"<Title>Bookmarks</Title>\n"
"<H1>Bookmarks</H1>\n"
"<DT><H3 FOLDED>" file " (" (format-time-string "%Y-%m-%d") ")</H3>\n"
"<DL><p>\n")
(apply 'insert (nreverse bookmarks))
(insert
"</DL><p>\n"
"</HTML>")
(write-file (concat (file-name-sans-extension file)
"-bookmarks.html"))))))
--8<---------------cut here---------------end--------------->8---
I'll put it up in the "hacks" section on Worg.
Regards,
Matt