md-reader 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/md-reader +22 -1
- data/lib/md_reader/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f19af5e102c9eea366a9df28b932e1c0bebfdda9313cfb303d3b899590a60121
|
|
4
|
+
data.tar.gz: 22d688f9092748da05a64a201d0a2a130743abf963725ce3aa41bef26ac442b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 287b6f2b39fdf728c36dac8df8fb8d10580df8c8b7216dab5f1380297155216e65ec69fbf603e87937b2fd29286dcd3b5aaf40c9ddbc35034d63c878277e9d4d
|
|
7
|
+
data.tar.gz: 519b7e84b7c1f88e8a897980056c14679aa4fa2ba60905df8d303f4ae3d7169a1318a87cf393df3ae7afc9cec0a13364e2b2912e016664b217a72512f486198d
|
data/bin/md-reader
CHANGED
|
@@ -6,6 +6,27 @@ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
|
|
|
6
6
|
require "md_reader"
|
|
7
7
|
require "launchy"
|
|
8
8
|
require "tmpdir"
|
|
9
|
+
require "shellwords"
|
|
10
|
+
|
|
11
|
+
# Dentro do WSL o launchy não acha browser (procura xdg-open/navegador de
|
|
12
|
+
# desktop Linux). Detectamos o WSL e abrimos no Windows, traduzindo o caminho
|
|
13
|
+
# Linux para o formato UNC (\\wsl.localhost\...) e montando uma URL file://.
|
|
14
|
+
def wsl?
|
|
15
|
+
return ENV.key?("WSL_DISTRO_NAME") if ENV.key?("WSL_DISTRO_NAME")
|
|
16
|
+
|
|
17
|
+
File.exist?("/proc/version") &&
|
|
18
|
+
File.read("/proc/version").downcase.include?("microsoft")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def open_file(path)
|
|
22
|
+
if wsl?
|
|
23
|
+
win_path = `wslpath -w #{Shellwords.escape(path)}`.strip # \\wsl.localhost\...\x.html
|
|
24
|
+
url = "file:#{win_path.tr('\\', '/')}" # file://wsl.localhost/...
|
|
25
|
+
system("explorer.exe", url) # explorer costuma retornar status != 0 mesmo em sucesso
|
|
26
|
+
else
|
|
27
|
+
Launchy.open("file://#{path}")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
9
30
|
|
|
10
31
|
if ARGV.empty?
|
|
11
32
|
warn "Usage: md-reader <arquivo.md>"
|
|
@@ -35,6 +56,6 @@ File.write(tmp_path, html, encoding: "utf-8")
|
|
|
35
56
|
at_exit { File.delete(tmp_path) rescue nil }
|
|
36
57
|
|
|
37
58
|
puts "Abrindo #{title} no browser..."
|
|
38
|
-
|
|
59
|
+
open_file(tmp_path)
|
|
39
60
|
|
|
40
61
|
sleep 3
|
data/lib/md_reader/version.rb
CHANGED