-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathox-750words.el
63 lines (56 loc) · 2.08 KB
/
ox-750words.el
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
;;; ox-750words.el --- Org mode exporter for 750words.com -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2021 Diego Zamboni
;;
;; Author: Diego Zamboni <https://github.com/zzamboni>
;; Maintainer: Diego Zamboni <[email protected]>
;; Created: June 10, 2021
;; Modified: June 10, 2021
;; Version: 0.0.1
;; Keywords: files, org, writing
;; Homepage: https://github.com/zzamboni/750words-client
;; Package-Requires: ((emacs "24.4") (750words "0.0.1"))
;;
;; This file is not part of GNU Emacs.
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; https://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;
;;; Commentary:
;;
;; An Org exporter which converts Org to Markdown and posts it to 750words.com.
;;
;; See https://github.com/zzamboni/750words-client for full usage instructions.
;;
;;; Code:
(require '750words)
(require 'ox-md)
(org-export-define-derived-backend '750words 'md
:menu-entry
'(?m 1
((?7 "Post to 750words.com"
(lambda (_a s v _b) (org-750words-export-to-750words s v))))))
(defun org-750words-export-to-750words (subtreep visible-only)
"Post Org text to 750words.com.
The Org buffer is first converted to Markdown using ox-md, and
the result posted to 750words.com.
When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.
When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements."
(let* ((outfile (make-temp-file "ox-750words"))
(org-export-with-smart-quotes nil))
(org-export-to-file 'md outfile nil subtreep visible-only)
(750words-file outfile)))
(provide 'ox-750words)
;;; ox-750words.el ends here