FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sscript/subdone/subdone.py at master · alpha1e0/sscript · GitHub
alpha1e0
sscript
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sscript
/
subdone
/
subdone.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (41 loc) · 1.98 KB
Breadcrumbs
sscript
/
subdone
/
subdone.py
Copy path
File metadata and controls
56 lines (41 loc) · 1.98 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
sublime
,
sublime_plugin
import
os
import
subprocess
class
MdToHtmlCommand
(
sublime_plugin
.
TextCommand
):
def
run
(
self
,
edit
):
settings
=
sublime
.
load_settings
(
"subdone.sublime-settings"
)
cmdFile
=
settings
.
get
(
"pandoc_cmd_file"
)
cmdFile
=
cmdFile
if
cmdFile
else
"pandoc"
#pluginPath = sublime.packages_path()
pluginPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
templateFile
=
settings
.
get
(
"pandoc_template_file"
)
if
not
templateFile
:
templateFile
=
os
.
path
.
join
(
pluginPath
,
"data"
, \
"pandoc-template"
,
"template.html"
)
templateFileArg
=
"
\"
"
+
templateFile
+
"
\"
"
cssFile
=
settings
.
get
(
"pandoc_css_file"
)
if
not
cssFile
:
self
.
_cssFile
=
os
.
path
.
join
(
pluginPath
,
"data"
, \
"pandoc-template"
,
"template.css"
)
cssFileArg
=
"
\"
"
+
self
.
_cssFile
+
"
\"
"
toc
=
settings
.
get
(
"pandoc_toc"
)
if
toc
:
tocDepth
=
settings
.
get
(
"pandoc_toc_depth"
)
tocDepth
=
tocDepth
if
tocDepth
else
3
self
.
_tocArg
=
"--toc --toc-depth={0}"
.
format
(
tocDepth
)
else
:
self
.
_tocArg
=
""
sourceFileName
=
self
.
view
.
file_name
()
sourceFileNameArg
=
"
\"
"
+
sourceFileName
+
"
\"
"
outputFileName
=
os
.
path
.
basename
(
sourceFileName
)
+
".html"
outputPath
=
settings
.
get
(
"pandoc_output_path"
)
outputPath
=
outputPath
if
outputPath
else
os
.
path
.
dirname
(
sourceFileName
)
outputFileArg
=
"
\"
"
+
os
.
path
.
join
(
outputPath
,
outputFileName
)
+
"
\"
"
cmd
=
" "
.
join
([
cmdFile
,
"--from markdown"
,
"--to html"
, \
"--template"
,
templateFileArg
,
"--css"
,
cssFileArg
, \
"-s --self-contained"
,
self
.
_tocArg
,
sourceFileNameArg
, \
"--output"
,
outputFileArg
])
try
:
subprocess
.
check_output
(
cmd
,
shell
=
True
,
stderr
=
subprocess
.
STDOUT
)
except
subprocess
.
CalledProcessError
as
err
:
sublime
.
error_message
(
str
(
err
.
output
))
Back
|
FazBrowse Home
|
New Git URL