emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] HTML export and Zotero-friendly headers


From: Christian Moe
Subject: Re: [O] HTML export and Zotero-friendly headers
Date: Wed, 23 Nov 2011 11:37:47 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20110624 Thunderbird/5.0

On 11/22/11 3:44 PM, Erik L. Arneson wrote:
Do I then understand correctly that what you want to do is simply to
generate one COinS snippet with metadata about the document itself
(author, title, etc.)?

Yes, though it doesn't need to be only COinS.  Zotero supports a number
of different formats, but COinS looks like it may be the easiest and the
most concise.


Hi,

Does Org document header data include more than author, title, date, description and keywords. So I'd be inclined to go with Dublin Core for this, and just twin the ordinary META tags (which Zotero doesn't bother with, probably wisely) with DC equivalents.

Doing it as below, with a hook at the end of html export, is more than a little clumsy, but it will do for testing purposes. If people think it's a good idea to do this in HTML exports on a permanent basis, a non-clumsy version could be patched into org-export-as-html.

#+begin_src elisp
  (defun org-export-with-dc ()
   "Add Dublin Core metadata from Org document headers to exported
  HTML. Comma-separated keywords and multiple authors separated
  with ` and ' will be correctly imported into Zotero. Note: For
  testing purposes only. It is only called as a hook from
  org-export-as-html, where it gets TITLE, DATE, AUTHOR,
  DESCRIPTION, and KEYWORDS values."
   (let ((creators (split-string author " and "))
         (subjects (split-string keywords ", ?"))
         fdate)
     (when (string-match "[0-9]+-[0-9]+-[0-9]+" date)
       (setq fdate (match-string 0 date)))
     (goto-char (point-min))
     (when (re-search-forward "</head>")
       (goto-char (match-beginning 0))
       (while creators
         (insert
          (format "<meta name=\"DC.Creator\" content=\"%s\"/>\n"
                  (car creators)))
         (setq creators (cdr creators)))
       (insert
        (format
         "<meta name=\"DC.Title\" content=\"%s\"/>
  <meta name=\"DC.Date\" content=\"%s\"/>
  <meta name=\"DC.Description\" content=\"%s\"/>\n"
         title fdate description))
       (while subjects
         (insert
          (format "<meta name=\"DC.Subject\" content=\"%s\"/>\n"
                  (car subjects)))
         (setq subjects (cdr subjects))))))


  (add-hook 'org-export-html-final-hook 'org-export-with-dc)
#+end_src

Yours,
Christian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]