emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matthew Lundin <mdl@imapmail.org>
To: Matt Lundin <mdl@imapmail.org>
Cc: emacs-orgmode@gnu.org, andrea Crotti <andrea.crotti.0@gmail.com>
Subject: Re: to bookmarks
Date: Sat, 26 Sep 2009 15:48:19 -0400	[thread overview]
Message-ID: <m2eiptv664.fsf@fastmail.fm> (raw)
In-Reply-To: <m2ljk1ts0y.fsf@fastmail.fm> (Matt Lundin's message of "Sat, 26 Sep 2009 15:39:09 -0400")

Matt Lundin <mdl@imapmail.org> writes:

> 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,

Here's a better version of the function:

--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)
  (unless (eq major-mode 'org-mode) 
    (error "Not in an org buffer"))
  (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 (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---

      reply	other threads:[~2009-09-26 19:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-26 13:59 to bookmarks andrea Crotti
2009-09-26 18:35 ` Andreas Burtzlaff
2009-09-26 19:39 ` Matt Lundin
2009-09-26 19:48   ` Matthew Lundin [this message]

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=m2eiptv664.fsf@fastmail.fm \
    --to=mdl@imapmail.org \
    --cc=andrea.crotti.0@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).