emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] org to static site?


From: Chunyang Xu
Subject: Re: [O] org to static site?
Date: Thu, 01 Jun 2017 01:05:04 +0800
User-agent: Notmuch/0.24.1+73~g523d2b5 (https://notmuchmail.org) Emacs/25.2.1 (x86_64-apple-darwin16.4.0)

Matt Price <address@hidden> writes:

> I'm trying to wean myself off of Wordpress for next year's teaching
> websites, and am wondering what solutions other people are using for
> turning a collection of org pages and/or subtrees into a static html site.
> I am leaning towards Hugo but honestly not for any sensible reason; I've
> seen other people use Jekyll, though the fact that Github doesn't support
> direct conversion from org-mode removes some of Jekyll's appeal; and I know
> there are a number of other solutions too.
>
> So, I would love to hear what you all recommend.

It is said that Nanoc is flexible. You can convert org mode to HTML with
Pandoc or Emacs. Nanoc supports Pandoc out of box. To use Emacs, you
need to write your own "filter" (Nanoc's terminology, i.e., convert one
format into another), for example,

#+BEGIN_SRC ruby
require 'tempfile'

class OrgFilter < Nanoc::Filter
  identifier :org

  def run(content, params = {})
    file = Tempfile.new(['nanoc', '.org'])
    file.write(content)
    file.close
    system("emacs --batch --load init.el #{file.path} --eval 
'(org-html-export-to-html nil nil nil t)'")
    html = "#{File.dirname(file.path)}/#{File.basename(file.path, '.org')}.html"
    file.unlink
    File.read(html)
  end
end
#+END_SRC

I just created my own site <https://xuchunyang.me/> with it last
week. The syntax highlighting on code block is provided by htmlize.el.
I noticed `org-html-export-to-html' produces different HTML every time
even the org file is unchanged at all. It is very annoying to me. I
found a work-around to avoid it,

#+BEGIN_SRC emacs-lisp
;; -*- lexical-binding: t; -*-
(let ((id 0))
  (defun org-export-new-reference--use-persistent-id (references)
    (let ((new id))
      (while (rassq new references)
        (setq new (incf id)))
      new)))

(advice-add 'org-export-new-reference
            :override #'org-export-new-reference--use-persistent-id)
#+END_SRC

[...]

--
Org mode version 9.0.7 (release_9.0.7-496-g3d3e24 @
/Users/xcy/src/org-mode/lisp/)





reply via email to

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