emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob d7b96b798c85e89a17cd614aca33826472ceda08 6187 bytes (raw)
name: lisp/ox-org.el 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
 
;;; ox-org.el --- Org Back-End for Org Export Engine

;; Copyright (C) 2013  Free Software Foundation, Inc.

;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Keywords: org, wp

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; This library implements an Org back-end for Org exporter.  Since
;; its usage is mainly internal, it doesn't provide any interactive
;; function.

;;; Code:
(require 'ox)
(declare-function htmlize-buffer "htmlize" (&optional buffer))

(defgroup org-export-org nil
  "Options for exporting Org mode files to Org."
  :tag "Org Export Org"
  :group 'org-export
  :version "24.4"
  :package-version '(Org . "8.0"))

(define-obsolete-variable-alias
  'org-export-htmlized-org-css-url 'org-org-htmlized-css-url "24.4")
(defcustom org-org-htmlized-css-url nil
  "URL pointing to the CSS defining colors for htmlized Emacs buffers.
Normally when creating an htmlized version of an Org buffer,
htmlize will create the CSS to define the font colors.  However,
this does not work when converting in batch mode, and it also can
look bad if different people with different fontification setup
work on the same website.  When this variable is non-nil,
creating an htmlized version of an Org buffer using
`org-org-export-as-org' will include a link to this URL if the
setting of `org-html-htmlize-output-type' is 'css."
  :group 'org-export-org
  :type '(choice
	  (const :tag "Don't include external stylesheet link" nil)
	  (string :tag "URL or local href")))

(org-export-define-backend 'org
  '((babel-call . org-org-identity)
    (bold . org-org-identity)
    (center-block . org-org-identity)
    (clock . org-org-identity)
    (code . org-org-identity)
    (comment . (lambda (&rest args) ""))
    (comment-block . (lambda (&rest args) ""))
    (diary-sexp . org-org-identity)
    (drawer . org-org-identity)
    (dynamic-block . org-org-identity)
    (entity . org-org-identity)
    (example-block . org-org-identity)
    (fixed-width . org-org-identity)
    (footnote-definition . org-org-identity)
    (footnote-reference . org-org-identity)
    (headline . org-org-headline)
    (horizontal-rule . org-org-identity)
    (inline-babel-call . org-org-identity)
    (inline-src-block . org-org-identity)
    (inlinetask . org-org-identity)
    (italic . org-org-identity)
    (item . org-org-identity)
    (keyword . org-org-keyword)
    (latex-environment . org-org-identity)
    (latex-fragment . org-org-identity)
    (line-break . org-org-identity)
    (link . org-org-identity)
    (node-property . org-org-identity)
    (paragraph . org-org-identity)
    (plain-list . org-org-identity)
    (planning . org-org-identity)
    (property-drawer . org-org-identity)
    (quote-block . org-org-identity)
    (quote-section . org-org-identity)
    (radio-target . org-org-identity)
    (section . org-org-identity)
    (special-block . org-org-identity)
    (src-block . org-org-identity)
    (statistics-cookie . org-org-identity)
    (strike-through . org-org-identity)
    (subscript . org-org-identity)
    (superscript . org-org-identity)
    (table . org-org-identity)
    (table-cell . org-org-identity)
    (table-row . org-org-identity)
    (target . org-org-identity)
    (timestamp . org-org-identity)
    (underline . org-org-identity)
    (verbatim . org-org-identity)
    (verse-block . org-org-identity)))

(defun org-org-identity (blob contents info)
  "Transcode BLOB element or object back into Org syntax."
  (funcall
   (intern (format "org-element-%s-interpreter" (org-element-type blob)))
   blob contents))

(defun org-org-headline (headline contents info)
  "Transcode HEADLINE element back into Org syntax."
  (unless (plist-get info :with-todo-keywords)
    (org-element-put-property headline :todo-keyword nil))
  (unless (plist-get info :with-tags)
    (org-element-put-property headline :tags nil))
  (unless (plist-get info :with-priority)
    (org-element-put-property headline :priority nil))
  (org-element-headline-interpreter headline contents))

(defun org-org-keyword (keyword contents info)
  "Transcode KEYWORD element back into Org syntax.
Ignore keywords targeted at other export back-ends."
  (unless (member (org-element-property :key keyword)
		  (mapcar
		   (lambda (block-cons)
		     (and (eq (cdr block-cons) 'org-element-export-block-parser)
			  (car block-cons)))
		   org-element-block-name-alist))
    (org-element-keyword-interpreter keyword nil)))

;;;###autoload
(defun org-org-publish-to-org (plist filename pub-dir)
  "Publish an org file to org.

FILENAME is the filename of the Org file to be published.  PLIST
is the property list for the given project.  PUB-DIR is the
publishing directory.

Return output file name."
  (org-publish-org-to 'org filename ".org" plist pub-dir)
  (when (plist-get plist :htmlized-source)
    (require 'htmlize)
    (require 'ox-html)
    (or (find-buffer-visiting filename)
	(find-file filename))
    (font-lock-fontify-buffer)
    (let* ((htmlize-output-type 'css)
	   (newbuf (htmlize-buffer)))
      (with-current-buffer newbuf
	(when org-org-htmlized-css-url
	  (goto-char (point-min))
	  (and (re-search-forward
		"<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*" nil t)
	       (replace-match
		(format
		 "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
		 org-org-htmlized-css-url) t t)))
	(write-file (concat pub-dir (file-name-nondirectory filename) ".html")))
      (kill-buffer newbuf))
    (set-buffer-modified-p nil)))

(provide 'ox-org)

;; Local variables:
;; generated-autoload-file: "org-loaddefs.el"
;; End:

;;; ox-org.el ends here

debug log:

solving d7b96b7 ...
found d7b96b7 in https://yhetil.org/orgmode/87wqtalnlc.fsf@bzg.ath.cx/
found 373589f in https://git.savannah.gnu.org/cgit/emacs/org-mode.git
preparing index
index prepared:
100644 373589fe53cee85e98b94c713ab124f712532dd6	lisp/ox-org.el

applying [1/1] https://yhetil.org/orgmode/87wqtalnlc.fsf@bzg.ath.cx/
diff --git a/lisp/ox-org.el b/lisp/ox-org.el
index 373589f..d7b96b7 100644

Checking patch lisp/ox-org.el...
Applied patch lisp/ox-org.el cleanly.

index at:
100644 d7b96b798c85e89a17cd614aca33826472ceda08	lisp/ox-org.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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).