-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMDViewer.ahk
57 lines (50 loc) · 1.75 KB
/
MDViewer.ahk
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
; Copyright (c) Luis Sanchez (luissanchezdev, LuisSanchez-Dev)
; MDViewer - A fast and lightweight markdown viewer for Windows written in Autohotkey
#Include Neutron.ahk
file = %1%
file_content = # No file specified\nMake sure to open a file with this app.
if (file) {
FileRead, file_content, %file%
file_content := StrReplace(file_content, "\", "\\")
file_content := StrReplace(file_content, "`r`n", "\n")
file_content := StrReplace(file_content, "`n", "\n")
file_content := StrReplace(file_content, "`n", "\n")
file_content := StrReplace(file_content, "'", "\'")
file_content := file_content "</br></br></br></br></br></br></br></br></br></br>"
}
css := "res://" A_ScriptFullPath "/10/github-markdown.css"
md_parser := "res://" A_ScriptFullPath "/10/remarkable.min.js"
if (!A_IsCompiled) {
css = %A_ScriptDir%\github-markdown.css
md_parser = %A_ScriptDir%\remarkable.min.js
}
if (FileExist(A_ScriptDir "\style.css") <> "") {
css = %A_ScriptDir%\style.css
}
html =
(
<link rel="stylesheet" href="%css%">
<script src="%md_parser%"></script>
<div id="markdown-body" class="markdown-body"></div>
<script>
var md = new Remarkable({
html: true,
linkify: true
});
var html = md.render('%file_content%');
document.getElementById("markdown-body").innerHTML = html;
</script>
)
Clipboard := html
MDViewer := new NeutronWindow(html,,, title:="MDViewer - " file)
MDViewer.Gui("+LabelMDViewerGui")
MDViewer.Show("w" A_ScreenWidth " h" A_ScreenHeight)
MDViewer.Maximize()
return
MDViewerGuiClose:
MDViewerGuiEscape:
MDViewer.Destroy()
ExitApp
return
FileInstall, remarkable.min.js, remarkable.min.js
FileInstall, github-markdown.css, github-markdown.css#Include Neutron.ahk