jekyll-org-to-html 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/jekyll-org-to-html.rb +71 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 82b60fed533bc0dc9d1cc010e80af0c8c7dd768c291d672bd867918a3d279b70
|
4
|
+
data.tar.gz: 43baf79b79250077a61bc013b44c42fe4af9a86b8ac232f484d547c2bea37136
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 24b43e4acdf150b7c97936705c0d849f1ade746175ea17ea95a3fb06529ba10fae106f2ee327d8d48656774d9b15a0f25d2b3975aa76d19ade436439248157d8
|
7
|
+
data.tar.gz: 7d495c6d0a797c876fc323f6684e6913bf7d71ceba1c3835d4d7f6dbf983970c4a528aea0a9c696e09132e5b6177fef18a139305fa57136d62e6c4ba2eadb742
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
ELISP = <<END
|
5
|
+
(package-initialize)
|
6
|
+
|
7
|
+
(require 'org)
|
8
|
+
(require 'cl)
|
9
|
+
|
10
|
+
(setq org-html-postamble nil)
|
11
|
+
|
12
|
+
(defun org->html-impl (org-text)
|
13
|
+
(with-temp-buffer
|
14
|
+
(insert org-text)
|
15
|
+
(org-html-export-as-html nil nil nil nil '(:with-toc nil :with-latex t :with-smart-quotes t :with-author nil :with-date nil :with-footnotes t :with-special-strings t :with-tables t))
|
16
|
+
(set-buffer
|
17
|
+
(cl-find-if #'(lambda (b) (equal "*Org HTML Export*" (buffer-name b)))
|
18
|
+
(buffer-list)))
|
19
|
+
(substring-no-properties (buffer-string))))
|
20
|
+
|
21
|
+
(defun org->html-temp-file (org-text)
|
22
|
+
(with-temp-file "/tmp/org-to-html"
|
23
|
+
(insert (org->html-impl org-text))))
|
24
|
+
|
25
|
+
(defun org->html (org-file)
|
26
|
+
(with-temp-buffer
|
27
|
+
(insert-file-contents org-file)
|
28
|
+
(org->html-temp-file (buffer-string))))
|
29
|
+
END
|
30
|
+
|
31
|
+
module Jekyll
|
32
|
+
class OrgModeConverter < Converter
|
33
|
+
safe true
|
34
|
+
priority :low
|
35
|
+
|
36
|
+
def matches(ext)
|
37
|
+
ext =~ /^\.org$/i
|
38
|
+
end
|
39
|
+
|
40
|
+
def output_ext(ext)
|
41
|
+
".html"
|
42
|
+
end
|
43
|
+
|
44
|
+
def convert(content)
|
45
|
+
elisp_script = Tempfile.new 'org-to-html-elisp'
|
46
|
+
elisp_script.write ELISP
|
47
|
+
elisp_script.rewind
|
48
|
+
|
49
|
+
content_as_file = Tempfile.new
|
50
|
+
content_as_file.write content
|
51
|
+
content_as_file.rewind
|
52
|
+
|
53
|
+
# Run our elisp script and receive any errors from stdout
|
54
|
+
out = `emacs --batch --load '#{elisp_script.path}' --eval '(org->html \"#{content_as_file.path}\")' 2>&1`
|
55
|
+
# 2>&1 means redirect stderr to stdout
|
56
|
+
# Emacs in `--batch` mode sends output to stderr instead of stdout
|
57
|
+
raise "Emacs rejected your org-mode file: #{out}" unless
|
58
|
+
$?.exitstatus.zero?
|
59
|
+
|
60
|
+
# Remove the temp files
|
61
|
+
elisp_script.unlink
|
62
|
+
content_as_file.unlink
|
63
|
+
|
64
|
+
# The elisp script saves the output in this named temp file
|
65
|
+
# Warning: possible race condition if Jekyll ever parallelizes conversion
|
66
|
+
# Don't change the name of this temp file without also changing
|
67
|
+
# it in the elisp code above.
|
68
|
+
File.open("/tmp/org-to-html", "r").read
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-org-to-html
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zelly Snyder
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Jekyll org-mode converter
|
14
|
+
email: zelly@outlook.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/jekyll-org-to-html.rb
|
20
|
+
homepage: https://github.com/hackharmony/jekyll-org-to-html
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Converts org-mode (Emacs) markup to html for Jekyll
|
44
|
+
test_files: []
|