qiita_org 0.1.7 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/qiita_org.rb +9 -2
- data/lib/qiita_org/check_pc_os.rb +19 -0
- data/lib/qiita_org/get.rb +4 -1
- data/lib/qiita_org/get_template.rb +55 -7
- data/lib/qiita_org/list.rb +4 -1
- data/lib/qiita_org/ox-qmd/ox-qmd.el +313 -0
- data/lib/qiita_org/post.rb +16 -4
- data/lib/qiita_org/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc8dcebbab016c5a866c9527d1497918b9da2022fa20732faba520afcfc5b9a
|
4
|
+
data.tar.gz: d9743b7b4f0fb38e3bec20f78ae4ae7bcbcaab5e298b690e8adf210d0430f96d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb0dc2baf179cbc549640054ab2f04dd8cda57163a4b88224eeb184ebb9cf4b8c08d6616c0c113c63e63cbea5fafd54364e7e8c29d292750c4268c70c6922b49
|
7
|
+
data.tar.gz: fe20e63b677207a424f151675a549bd721ba6683f8646b31d9cbeacee4faa2578742de80755bb16b754e90c9df909d744b1429429ab095b73f6ddafcdd4ce558
|
data/Gemfile.lock
CHANGED
data/lib/qiita_org.rb
CHANGED
@@ -6,6 +6,7 @@ require "qiita_org/config"
|
|
6
6
|
require "qiita_org/get"
|
7
7
|
require "qiita_org/list"
|
8
8
|
require "qiita_org/get_template"
|
9
|
+
require "qiita_org/check_pc_os"
|
9
10
|
#require "qiita_org/qiita_org_thor"
|
10
11
|
|
11
12
|
module QiitaOrg
|
@@ -14,6 +15,12 @@ module QiitaOrg
|
|
14
15
|
# super(*argv)
|
15
16
|
# end
|
16
17
|
#
|
18
|
+
def initialize(*argv)
|
19
|
+
super(*argv)
|
20
|
+
checkos = CheckPcOs.new
|
21
|
+
@os = checkos.return_os()
|
22
|
+
end
|
23
|
+
|
17
24
|
desc "say_hello", "say_hello"
|
18
25
|
|
19
26
|
def say_hello(*name)
|
@@ -27,7 +34,7 @@ module QiitaOrg
|
|
27
34
|
p ["in qiita_org.rb", argv]
|
28
35
|
p file = argv[0] || "README.org"
|
29
36
|
p mode = argv[1] || "private"
|
30
|
-
qiita = QiitaPost.new(file, mode)
|
37
|
+
qiita = QiitaPost.new(file, mode, @os)
|
31
38
|
begin
|
32
39
|
qiita.select_option(mode)
|
33
40
|
rescue RuntimeError => e
|
@@ -59,7 +66,7 @@ module QiitaOrg
|
|
59
66
|
desc "template", "make template.org"
|
60
67
|
|
61
68
|
def template(*argv)
|
62
|
-
template = QiitaGetTemplate.new()
|
69
|
+
template = QiitaGetTemplate.new(@os)
|
63
70
|
end
|
64
71
|
|
65
72
|
desc "all", "post all org file in the directory"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CheckPcOs
|
2
|
+
def initialize()
|
3
|
+
@macos = system "sw_vers"
|
4
|
+
@winos = system "wmic.exe os get caption"
|
5
|
+
end
|
6
|
+
|
7
|
+
def return_os()
|
8
|
+
if @macos
|
9
|
+
return os = "mac"
|
10
|
+
elsif @winos
|
11
|
+
return os = "windows"
|
12
|
+
else
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#p os = CheckPcOs.new.return_os()
|
19
|
+
|
data/lib/qiita_org/get.rb
CHANGED
@@ -3,16 +3,19 @@ require "json"
|
|
3
3
|
require "open-uri"
|
4
4
|
require "io/console"
|
5
5
|
require "colorize"
|
6
|
+
require "qiita_org/search_conf_path.rb"
|
6
7
|
|
7
8
|
class QiitaGet
|
8
9
|
def initialize(mode, id)
|
9
10
|
@mode = mode
|
10
11
|
@get_id = id
|
12
|
+
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
13
|
+
@conf_dir = search.search_conf_path()
|
11
14
|
end
|
12
15
|
|
13
16
|
# set config
|
14
17
|
def set_config()
|
15
|
-
conf_path = File.join(
|
18
|
+
conf_path = File.join(@conf_dir, ".qiita.conf")
|
16
19
|
conf = JSON.load(File.read(conf_path))
|
17
20
|
@access_token = conf["access_token"]
|
18
21
|
@teams_url = conf["teams_url"]
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require "fileutils"
|
2
2
|
require "colorize"
|
3
|
+
require "kconv"
|
3
4
|
require "qiita_org/search_conf_path"
|
4
5
|
|
5
6
|
class QiitaGetTemplate
|
6
|
-
def initialize()
|
7
|
+
def initialize(os)
|
8
|
+
@os = os
|
7
9
|
cp_template()
|
8
10
|
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
9
11
|
@conf_dir = search.search_conf_path()
|
@@ -23,6 +25,32 @@ class QiitaGetTemplate
|
|
23
25
|
File.write("template.org", conts) # + "# {m[1]}: # {m[2]}\n")
|
24
26
|
end
|
25
27
|
|
28
|
+
def get_windowsos_version()
|
29
|
+
system 'wmic.exe os get caption > hoge1.txt'
|
30
|
+
system 'wmic.exe os get osarchitecture > hoge2.txt'
|
31
|
+
version1 = Kconv.tosjis(File.read("hoge1.txt"))
|
32
|
+
version2 = Kconv.tosjis(File.read("hoge2.txt"))
|
33
|
+
m1, m2 = [], []
|
34
|
+
m1 = version1.match(/Caption\nMicrosoft (.+) (.+)/)
|
35
|
+
m2 = version2.match(/OSArchitecture\n(.+)-bit/)
|
36
|
+
system 'rm hoge1.txt'
|
37
|
+
system 'rm hoge2.txt'
|
38
|
+
conts = File.read("template.org")
|
39
|
+
conts << "![#{m1[1]}-#{m1[2]}](https://img.shields.io/badge/#{m1[1].gsub(" ", "")}#{m1[2]}-#{m2[1]}bit-brightgreen) "
|
40
|
+
File.write("template.org", conts) # + "# {m[1]}: # {m[2]}\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_ubuntu_version()
|
44
|
+
system 'cat /etc/issue > hoge.txt'
|
45
|
+
version = File.read("hoge.txt")
|
46
|
+
m = []
|
47
|
+
m = version.match(/(.+) (.+) LTS /)
|
48
|
+
system 'rm hoge.txt'
|
49
|
+
conts = File.read("template.org")
|
50
|
+
conts << "![#{m[1]}-#{m[2]}](https://img.shields.io/badge/#{m[1]}-#{m[2]}-brightgreen) "
|
51
|
+
File.write("template.org", conts)
|
52
|
+
end
|
53
|
+
|
26
54
|
def get_ruby_version()
|
27
55
|
system 'ruby --version > hoge.txt'
|
28
56
|
version = File.read("hoge.txt")
|
@@ -48,12 +76,32 @@ class QiitaGetTemplate
|
|
48
76
|
end
|
49
77
|
|
50
78
|
def check_write_contents()
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
79
|
+
if @os == "mac"
|
80
|
+
["MacOS", "ruby"].each do |src|
|
81
|
+
print "Write #{src} version?(y/n) "
|
82
|
+
ans = STDIN.gets.chomp
|
83
|
+
next if ans == "n"
|
84
|
+
if ans == "y"
|
85
|
+
send("get_#{src.downcase}_version")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
elsif @os == "windows"
|
89
|
+
["ruby"].each do |src|
|
90
|
+
print "Write #{src} version?(y/n) "
|
91
|
+
ans = STDIN.gets.chomp
|
92
|
+
next if ans == "n"
|
93
|
+
if ans == "y"
|
94
|
+
send("get_#{src.downcase}_version")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
else
|
98
|
+
["ruby"].each do |src|
|
99
|
+
print "Write #{src} version?(y/n) "
|
100
|
+
ans = STDIN.gets.chomp
|
101
|
+
next if ans == "n"
|
102
|
+
if ans == "y"
|
103
|
+
send("get_#{src.downcase}_version")
|
104
|
+
end
|
57
105
|
end
|
58
106
|
end
|
59
107
|
end
|
data/lib/qiita_org/list.rb
CHANGED
@@ -2,10 +2,13 @@ require "net/https"
|
|
2
2
|
require "json"
|
3
3
|
require "open-uri"
|
4
4
|
require "colorize"
|
5
|
+
require "qiita_org/search_conf_path.rb"
|
5
6
|
|
6
7
|
class QiitaList
|
7
8
|
def initialize(mode)
|
8
9
|
@mode = mode
|
10
|
+
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
11
|
+
@conf_dir = search.search_conf_path()
|
9
12
|
set_config()
|
10
13
|
select_path()
|
11
14
|
access_qiita()
|
@@ -13,7 +16,7 @@ class QiitaList
|
|
13
16
|
end
|
14
17
|
|
15
18
|
def set_config()
|
16
|
-
conf_path = File.join(
|
19
|
+
conf_path = File.join(@conf_dir, ".qiita.conf")
|
17
20
|
conf = JSON.load(File.read(conf_path))
|
18
21
|
@access_token = conf["access_token"]
|
19
22
|
@teams_url = conf["teams_url"]
|
@@ -0,0 +1,313 @@
|
|
1
|
+
;;; ox-qmd.el --- Qiita Markdown Back-End for Org Export Engine
|
2
|
+
|
3
|
+
;; Copyright (C) 2015-2020 0x60DF
|
4
|
+
|
5
|
+
;; Author: 0x60DF <0x60DF@gmail.com>
|
6
|
+
;; URL: https://github.com/0x60df/ox-qmd
|
7
|
+
;; Version: 1.0.5
|
8
|
+
;; Package-Requires: ((org "8.0"))
|
9
|
+
;; Keywords: wp
|
10
|
+
|
11
|
+
;; This file is not part of GNU Emacs.
|
12
|
+
|
13
|
+
;; This program is free software: you can redistribute it and/or modify
|
14
|
+
;; it under the terms of the GNU General Public License as published by
|
15
|
+
;; the Free Software Foundation, either version 3 of the License, or
|
16
|
+
;; (at your option) any later version.
|
17
|
+
|
18
|
+
;; This program is distributed in the hope that it will be useful,
|
19
|
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
;; GNU General Public License for more details.
|
22
|
+
|
23
|
+
;; You should have received a copy of the GNU General Public License
|
24
|
+
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
25
|
+
|
26
|
+
;;; Commentary:
|
27
|
+
|
28
|
+
;; This library implements a Markdown back-end (qiita flavor) for
|
29
|
+
;; Org exporter, based on `md' back-end and `gfm' back-end.
|
30
|
+
|
31
|
+
;; See http://orgmode.org/ for infomation about Org-mode and `md' back-end.
|
32
|
+
;; See http://github.com/larstvei/ox-gfm for information about `gfm' back-end.
|
33
|
+
|
34
|
+
;;; Code:
|
35
|
+
|
36
|
+
(require 'ox-md)
|
37
|
+
|
38
|
+
|
39
|
+
;;; User-Configurable Variables
|
40
|
+
|
41
|
+
(defvar ox-qmd-language-keyword-alist '(("emacs-lisp" . "el")))
|
42
|
+
(defvar ox-qmd-unfill-paragraph t)
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
;;; Define Back-End
|
47
|
+
|
48
|
+
(org-export-define-derived-backend 'qmd 'md
|
49
|
+
:filters-alist '((:filter-paragraph . org-qmd--unfill-paragraph))
|
50
|
+
:menu-entry
|
51
|
+
'(?9 "Export to Qiita Markdown"
|
52
|
+
((?0 "To temporary buffer"
|
53
|
+
(lambda (a s v b) (org-qmd-export-as-markdown a s v)))
|
54
|
+
(?9 "To file" (lambda (a s v b) (org-qmd-export-to-markdown a s v)))
|
55
|
+
(?o "To file and open"
|
56
|
+
(lambda (a s v b)
|
57
|
+
(if a (org-qmd-export-to-markdown t s v)
|
58
|
+
(org-open-file (org-qmd-export-to-markdown nil s v)))))
|
59
|
+
(?s "To temporary buffer from subtree"
|
60
|
+
(lambda (a s v b) (org-qmd-export-as-markdown a t v)))))
|
61
|
+
:translate-alist '((headline . org-qmd--headline)
|
62
|
+
(inner-template . org-qmd--inner-template)
|
63
|
+
(keyword . org--qmd-keyword)
|
64
|
+
(strike-through . org-qmd--strike-through)
|
65
|
+
(underline . org-qmd--undeline)
|
66
|
+
(src-block . org-qmd--src-block)
|
67
|
+
(latex-fragment . org-qmd--latex-fragment)
|
68
|
+
(latex-environment . org-qmd--latex-environment)
|
69
|
+
(table . org-qmd--table)))
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
;;; Filters
|
74
|
+
|
75
|
+
(defun org-qmd--unfill-paragraph (paragraph backend info)
|
76
|
+
"Unfill PARAGRAPH element.
|
77
|
+
Remove newline from PARAGRAPH and replace line-break string
|
78
|
+
with newline in PARAGRAPH if user-configurable variable
|
79
|
+
`ox-qmd-unfill-paragraph' is non-nil."
|
80
|
+
(if (and (org-export-derived-backend-p backend 'qmd)
|
81
|
+
ox-qmd-unfill-paragraph)
|
82
|
+
(concat (replace-regexp-in-string
|
83
|
+
" \n" "\n" (replace-regexp-in-string
|
84
|
+
"\\([^ ][^ ]\\|[^ ] \\| [^ ]\\)\n" "\\1" paragraph))
|
85
|
+
"\n")
|
86
|
+
paragraph))
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
;;; Transcode Functions
|
91
|
+
|
92
|
+
(defun org-qmd--headline (headline contents info)
|
93
|
+
"Transcode HEADLINE element into Qiita Markdown format.
|
94
|
+
CONTENTS is a content of the HEADLINE. INFO is a plist used
|
95
|
+
as a communication channel."
|
96
|
+
(let* ((info (copy-sequence info))
|
97
|
+
(info (plist-put info :with-toc nil)))
|
98
|
+
(org-md-headline headline contents info)))
|
99
|
+
|
100
|
+
|
101
|
+
(defun org-qmd--inner-template (contents info)
|
102
|
+
"Return body of document after converting it to Qiita Markdown syntax.
|
103
|
+
CONTENTS is the transcoded contents string. INFO is a plist
|
104
|
+
holding export options."
|
105
|
+
(let* ((info (copy-sequence info))
|
106
|
+
(info (plist-put info :with-toc nil)))
|
107
|
+
(org-md-inner-template contents info)))
|
108
|
+
|
109
|
+
|
110
|
+
(defun org-qmd--keyword (keyword contents info)
|
111
|
+
"Transcode a KEYWORD element into Qiita Markdown format.
|
112
|
+
CONTENTS is nil. INFO is a plist used as a communication
|
113
|
+
channel."
|
114
|
+
(let* ((info (copy-sequence info))
|
115
|
+
(info (plist-put info :with-toc nil)))
|
116
|
+
(org-html-keyword keyword contents info)))
|
117
|
+
|
118
|
+
|
119
|
+
(defun org-qmd--src-block (src-block contents info)
|
120
|
+
"Transcode SRC-BLOCK element into Qiita Markdown format.
|
121
|
+
CONTENTS is nil. INFO is a plist used as a communication
|
122
|
+
channel."
|
123
|
+
(let* ((lang (org-element-property :language src-block))
|
124
|
+
(lang (or (cdr (assoc lang ox-qmd-language-keyword-alist)) lang))
|
125
|
+
(name (org-element-property :name src-block))
|
126
|
+
(code (org-export-format-code-default src-block info))
|
127
|
+
(prefix (concat "```" lang (if name (concat ":" name) nil) "\n"))
|
128
|
+
(suffix "```"))
|
129
|
+
(concat prefix code suffix)))
|
130
|
+
|
131
|
+
|
132
|
+
(defun org-qmd--strike-through (strike-through contents info)
|
133
|
+
"Transcode STRIKE-THROUGH element into Qiita Markdown format.
|
134
|
+
CONTENTS is a content of the STRIKE-THROUGH. INFO is a plist
|
135
|
+
used as a communication channel."
|
136
|
+
(format "~~%s~~" contents))
|
137
|
+
|
138
|
+
|
139
|
+
(defun org-qmd--undeline (underline contents info)
|
140
|
+
"Transcode UNDERLINE element into Qiita Markdown format.
|
141
|
+
CONTENTS is a content of the UNDELINE. INFO is a plist used
|
142
|
+
as a communication channel."
|
143
|
+
contents)
|
144
|
+
|
145
|
+
|
146
|
+
(defun org-qmd--latex-fragment (latex-fragment contents info)
|
147
|
+
"Transcode a LATEX-FRAGMENT element into Qiita Markdown format.
|
148
|
+
CONTENTS is nil. INFO is a plist used as a communication
|
149
|
+
channel."
|
150
|
+
(replace-regexp-in-string
|
151
|
+
"^\\\\(\\(.+\\)\\\\)$" "$\\1$"
|
152
|
+
(replace-regexp-in-string
|
153
|
+
"^\\\\\\[\\(.+\\)\\\\\\]$" "$$\\1$$"
|
154
|
+
(let* ((info (copy-sequence info))
|
155
|
+
(info (plist-put info :with-latex 'verbatim)))
|
156
|
+
(org-html-latex-fragment latex-fragment contents info)))))
|
157
|
+
|
158
|
+
|
159
|
+
(defun org-qmd--latex-environment (latex-environment contents info)
|
160
|
+
"Transcode a LATEX-ENVIRONMENT element into Qiita Markdown format.
|
161
|
+
CONTENTS is nil. INFO is a plist used as a communication
|
162
|
+
channel."
|
163
|
+
(replace-regexp-in-string
|
164
|
+
"^.*?\\\\begin{.+}.*?$" "```math"
|
165
|
+
(replace-regexp-in-string
|
166
|
+
"^.*?\\\\end{.+}.*?$" "```"
|
167
|
+
(let* ((info (copy-sequence info))
|
168
|
+
(info (plist-put info :with-latex 'verbatim)))
|
169
|
+
(org-html-latex-environment latex-environment contents info)))))
|
170
|
+
|
171
|
+
|
172
|
+
(defun org-qmd--table (table contents info)
|
173
|
+
"Transcode a TABLE element into Qiita Markdown format.
|
174
|
+
CONTENTS is a content of the table. INFO is a plist used as
|
175
|
+
a communication channel."
|
176
|
+
(letrec ((filter (lambda (p l)
|
177
|
+
(cond ((null l) l)
|
178
|
+
((funcall p (car l)) (funcall filter p (cdr l)))
|
179
|
+
(t (cons (car l) (funcall filter p (cdr l)))))))
|
180
|
+
(zip (lambda (&rest l)
|
181
|
+
(cond ((null (car l)) (car l))
|
182
|
+
(t (cons (mapcar 'car l)
|
183
|
+
(apply zip (mapcar 'cdr l))))))))
|
184
|
+
(let* ((rows (org-element-map table 'table-row 'identity info))
|
185
|
+
(non-rule-rows
|
186
|
+
(funcall filter (lambda (row)
|
187
|
+
(eq 'rule (org-element-property :type row)))
|
188
|
+
rows))
|
189
|
+
(alignments (org-element-map (car non-rule-rows) 'table-cell
|
190
|
+
(lambda (cell)
|
191
|
+
(org-export-table-cell-alignment cell info))
|
192
|
+
info))
|
193
|
+
(widths (mapcar
|
194
|
+
(lambda (column)
|
195
|
+
(let ((max-difference
|
196
|
+
(apply
|
197
|
+
'max (mapcar
|
198
|
+
(lambda (cell)
|
199
|
+
(- (org-element-property :end cell)
|
200
|
+
(org-element-property :begin cell)))
|
201
|
+
column))))
|
202
|
+
(if (< max-difference 4) 3 (- max-difference 1))))
|
203
|
+
(apply
|
204
|
+
zip (mapcar
|
205
|
+
(lambda (row)
|
206
|
+
(org-element-map row 'table-cell 'identity info))
|
207
|
+
non-rule-rows))))
|
208
|
+
(joined-rows
|
209
|
+
(mapcar (lambda (row)
|
210
|
+
(let ((cells
|
211
|
+
(org-element-map row 'table-cell 'identity info)))
|
212
|
+
(mapconcat
|
213
|
+
(lambda (tuple)
|
214
|
+
(let ((alignment (car tuple))
|
215
|
+
(width (cadr tuple))
|
216
|
+
(cell (caddr tuple)))
|
217
|
+
(format (format " %%-%ds" (- width 1))
|
218
|
+
(or (org-export-data
|
219
|
+
(org-element-contents cell)
|
220
|
+
info)
|
221
|
+
""))))
|
222
|
+
(funcall zip alignments widths cells)
|
223
|
+
"|")))
|
224
|
+
non-rule-rows))
|
225
|
+
(joined-rows-with-delimiter-row
|
226
|
+
(cons (car joined-rows)
|
227
|
+
(cons (mapconcat
|
228
|
+
(lambda (tuple)
|
229
|
+
(let ((alignment (car tuple))
|
230
|
+
(width (cadr tuple)))
|
231
|
+
(format "%s%s%s"
|
232
|
+
(if (memq alignment '(left center))
|
233
|
+
":" "-")
|
234
|
+
(make-string (- width 2) ?-)
|
235
|
+
(if (memq alignment '(right center))
|
236
|
+
":" "-"))))
|
237
|
+
(funcall zip alignments widths)
|
238
|
+
"|")
|
239
|
+
(cdr joined-rows)))))
|
240
|
+
(mapconcat (lambda (row) (format "|%s|" row))
|
241
|
+
joined-rows-with-delimiter-row
|
242
|
+
"\n"))))
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
;;; Interactive function
|
247
|
+
|
248
|
+
;;;###autoload
|
249
|
+
(defun org-qmd-export-as-markdown (&optional async subtreep visible-only)
|
250
|
+
"Export current buffer to a Qiita Markdown buffer.
|
251
|
+
|
252
|
+
If narrowing is active in the current buffer, only export
|
253
|
+
its narrowed part.
|
254
|
+
|
255
|
+
If a region is active, export that region.
|
256
|
+
|
257
|
+
A non-nil optional argument ASYNC means the process should
|
258
|
+
happen asynchronously. The resulting buffer should be
|
259
|
+
accessible through the `org-export-stack' interface.
|
260
|
+
|
261
|
+
When optional argument SUBTREEP is non-nil, export the
|
262
|
+
sub-tree at point, extracting information from the headline
|
263
|
+
properties first.
|
264
|
+
|
265
|
+
When optional argument VISIBLE-ONLY is non-nil, don't export
|
266
|
+
contents of hidden elements.
|
267
|
+
|
268
|
+
Export is done in a buffer named \"*Org QMD Export*\", which
|
269
|
+
will be displayed when
|
270
|
+
`org-export-show-temporary-export-buffer' is non-nil."
|
271
|
+
(interactive)
|
272
|
+
(org-export-to-buffer 'qmd "*Org QMD Export*"
|
273
|
+
async subtreep visible-only nil nil (lambda () (text-mode))))
|
274
|
+
|
275
|
+
;;;###autoload
|
276
|
+
(defun org-qmd-convert-region-to-md ()
|
277
|
+
"Convert region into Qiita Markdown format.
|
278
|
+
Assume the current region has org-mode syntax, and convert
|
279
|
+
it to Qiita Markdown. This can be used in any buffer. For
|
280
|
+
example, you can write an itemized list in org-mode syntax
|
281
|
+
in a Markdown buffer and use this command to convert it."
|
282
|
+
(interactive)
|
283
|
+
(org-export-replace-region-by 'qmd))
|
284
|
+
|
285
|
+
|
286
|
+
;;;###autoload
|
287
|
+
(defun org-qmd-export-to-markdown (&optional async subtreep visible-only)
|
288
|
+
"Export current buffer to a Qiita Markdown file.
|
289
|
+
|
290
|
+
If narrowing is active in the current buffer, only export
|
291
|
+
its narrowed part.
|
292
|
+
|
293
|
+
If a region is active, export that region.
|
294
|
+
|
295
|
+
A non-nil optional argument ASYNC means the process should
|
296
|
+
happen asynchronously. The resulting file should be
|
297
|
+
accessible through the `org-export-stack' interface.
|
298
|
+
|
299
|
+
When optional argument SUBTREEP is non-nil, export the
|
300
|
+
sub-tree at point, extracting information from the headline
|
301
|
+
properties first.
|
302
|
+
|
303
|
+
When optional argument VISIBLE-ONLY is non-nil, don't export
|
304
|
+
contents of hidden elements.
|
305
|
+
|
306
|
+
Return output file's name."
|
307
|
+
(interactive)
|
308
|
+
(let ((outfile (org-export-output-file-name ".md" subtreep)))
|
309
|
+
(org-export-to-file 'qmd outfile async subtreep visible-only)))
|
310
|
+
|
311
|
+
(provide 'ox-qmd)
|
312
|
+
|
313
|
+
;;; ox-qmd.el ends here
|
data/lib/qiita_org/post.rb
CHANGED
@@ -7,9 +7,10 @@ require "colorize"
|
|
7
7
|
require "qiita_org/search_conf_path.rb"
|
8
8
|
|
9
9
|
class QiitaPost
|
10
|
-
def initialize(file, option)
|
10
|
+
def initialize(file, option, os)
|
11
11
|
@src = file
|
12
12
|
@option = (option == "qiita" || option == "open")? "public" : option
|
13
|
+
@os = os
|
13
14
|
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
14
15
|
@conf_dir = search.search_conf_path()
|
15
16
|
p @conf_dir
|
@@ -39,7 +40,8 @@ class QiitaPost
|
|
39
40
|
@conf = JSON.load(File.read(conf_path))
|
40
41
|
@access_token = @conf["access_token"]
|
41
42
|
@teams_url = @conf["teams_url"]
|
42
|
-
|
43
|
+
lib = File.expand_path("../../../lib", __FILE__)
|
44
|
+
@ox_qmd_load_path = File.join(lib, "qiita_org", "ox-qmd", "ox-qmd") # @conf["ox_qmd_load_path"]
|
43
45
|
end
|
44
46
|
|
45
47
|
# src.org -> src.md
|
@@ -136,6 +138,17 @@ class QiitaPost
|
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
141
|
+
# open qiita
|
142
|
+
def open_qiita()
|
143
|
+
if @os == "mac"
|
144
|
+
system "open #{@res_body["url"]}"
|
145
|
+
elsif @os == "windows"
|
146
|
+
system "explorer.exe #{@res_body["url"]}"
|
147
|
+
else
|
148
|
+
system "open #{@res_body["url"]}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
139
152
|
def run()
|
140
153
|
get_title_tags()
|
141
154
|
set_config()
|
@@ -146,8 +159,7 @@ class QiitaPost
|
|
146
159
|
qiita_post()
|
147
160
|
get_and_print_qiita_return()
|
148
161
|
|
149
|
-
|
150
|
-
system "open #{@res_body["url"]}"
|
162
|
+
open_qiita()
|
151
163
|
|
152
164
|
add_qiita_id_on_org()
|
153
165
|
end
|
data/lib/qiita_org/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita_org
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Yamamoto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -953,12 +953,14 @@ files:
|
|
953
953
|
- hoge.rb
|
954
954
|
- lib/qiita_org.rb
|
955
955
|
- lib/qiita_org/.qiita.conf
|
956
|
+
- lib/qiita_org/check_pc_os.rb
|
956
957
|
- lib/qiita_org/config.json
|
957
958
|
- lib/qiita_org/config.rb
|
958
959
|
- lib/qiita_org/get.rb
|
959
960
|
- lib/qiita_org/get_template.rb
|
960
961
|
- lib/qiita_org/hoge.txt
|
961
962
|
- lib/qiita_org/list.rb
|
963
|
+
- lib/qiita_org/ox-qmd/ox-qmd.el
|
962
964
|
- lib/qiita_org/post.rb
|
963
965
|
- lib/qiita_org/search_conf_path.rb
|
964
966
|
- lib/qiita_org/template.org
|
@@ -968,7 +970,7 @@ homepage: https://github.com/yamatoken/qiita_org
|
|
968
970
|
licenses:
|
969
971
|
- MIT
|
970
972
|
metadata: {}
|
971
|
-
post_install_message:
|
973
|
+
post_install_message:
|
972
974
|
rdoc_options: []
|
973
975
|
require_paths:
|
974
976
|
- lib
|
@@ -984,7 +986,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
984
986
|
version: '0'
|
985
987
|
requirements: []
|
986
988
|
rubygems_version: 3.1.4
|
987
|
-
signing_key:
|
989
|
+
signing_key:
|
988
990
|
specification_version: 4
|
989
991
|
summary: this is qiita post gem from org.
|
990
992
|
test_files: []
|