snibbets 2.0.40 → 2.0.41
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/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/snibbets/config.rb +2 -2
- data/lib/snibbets/highlight.rb +31 -1
- data/lib/snibbets/todo_spec.rb +11 -0
- data/lib/snibbets/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 65a8a931951246e4b20734d071ead64884366231e12526d6790b0c78a8dc8940
|
|
4
|
+
data.tar.gz: 4e875d9152a0ed900e96f7feadc1f28ab0eb1be76ad87a86ff34be562d3c2998
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e68034d4bc23511e3f4ea9e24058d4a9f47f28b23a034de570b55bab743114e4617925c99c551340be4ece37c03a24f63fe554eee80ab61a68523115577f576f
|
|
7
|
+
data.tar.gz: 60d444f08878ad2cf6febf4d5e8ec8b8a2d619be7feec6508f0dcca847a0b8c369c81158928bd6c21b86355390b3f5a1f61b1269b6c972a6e244a7d7a2b99aa1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
|
@@ -11,7 +11,7 @@ Rake::RDocTask.new do |rd|
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
YARD::Rake::YardocTask.new do |t|
|
|
14
|
-
t.files = ['lib/
|
|
14
|
+
t.files = ['lib/snibbets/**/*.rb']
|
|
15
15
|
t.options = ['--markup-provider=redcarpet', '--markup=markdown', '--no-private', '-p', 'yard_templates']
|
|
16
16
|
# t.stats_options = ['--list-undoc']
|
|
17
17
|
end
|
data/lib/snibbets/config.rb
CHANGED
|
@@ -61,10 +61,10 @@ module Snibbets
|
|
|
61
61
|
|
|
62
62
|
return TTY::Which.which('subl') if TTY::Which.exist?('subl') && @test_editor == 'subl'
|
|
63
63
|
|
|
64
|
-
return TTY::Which.which('nano') if TTY::Which.exist?('nano') && @test_editor == 'nano'
|
|
65
|
-
|
|
66
64
|
return TTY::Which.which('vim') if TTY::Which.exist?('vim') && @test_editor == 'vim'
|
|
67
65
|
|
|
66
|
+
return TTY::Which.which('nano') if TTY::Which.exist?('nano') && @test_editor == 'nano'
|
|
67
|
+
|
|
68
68
|
'TextEdit'
|
|
69
69
|
end
|
|
70
70
|
end
|
data/lib/snibbets/highlight.rb
CHANGED
|
@@ -40,6 +40,29 @@ module Snibbets
|
|
|
40
40
|
run_command_with_input("#{executable} #{theme}--syntax #{syntax}", input: code)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
def highlight_shiki(executable, code, syntax, theme)
|
|
44
|
+
theme ||= 'vitesse-dark'
|
|
45
|
+
tempfile = Tempfile.new(['snibbets', '.tmp'])
|
|
46
|
+
begin
|
|
47
|
+
tempfile.write(code)
|
|
48
|
+
tempfile.close
|
|
49
|
+
|
|
50
|
+
command_parts = [executable, '--format', 'ansi']
|
|
51
|
+
command_parts << '--theme' << theme unless theme.nil? || theme.empty?
|
|
52
|
+
command_parts << '--lang' << syntax unless syntax.nil? || syntax.empty?
|
|
53
|
+
command_parts << tempfile.path
|
|
54
|
+
|
|
55
|
+
stdout, _stderr, status = Open3.capture3(*command_parts)
|
|
56
|
+
if status.success?
|
|
57
|
+
stdout
|
|
58
|
+
else
|
|
59
|
+
code
|
|
60
|
+
end
|
|
61
|
+
ensure
|
|
62
|
+
tempfile&.unlink
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
43
66
|
def highlight_fences(code, filename, syntax)
|
|
44
67
|
content = code.dup
|
|
45
68
|
|
|
@@ -68,8 +91,12 @@ module Snibbets
|
|
|
68
91
|
|
|
69
92
|
skylight = TTY::Which.which('skylighting')
|
|
70
93
|
pygments = TTY::Which.which('pygmentize')
|
|
94
|
+
shiki = TTY::Which.which('shiki')
|
|
71
95
|
|
|
72
|
-
if Snibbets.options[:highlighter] =~ /^
|
|
96
|
+
if Snibbets.options[:highlighter] =~ /^shiki/ && !shiki.nil?
|
|
97
|
+
shiki_theme = Snibbets.options[:highlight_theme] || 'vitesse-dark'
|
|
98
|
+
return highlight_shiki(shiki, code, syntax, shiki_theme)
|
|
99
|
+
elsif Snibbets.options[:highlighter] =~ /^s/ && !skylight.nil?
|
|
73
100
|
if !Lexers.skylight_lexer?(syntax) && !pygments.nil?
|
|
74
101
|
return highlight_pygments(pygments, code, syntax, 'monokai')
|
|
75
102
|
else
|
|
@@ -81,6 +108,9 @@ module Snibbets
|
|
|
81
108
|
return highlight_skylight(skylight, code, syntax, theme)
|
|
82
109
|
elsif !pygments.nil?
|
|
83
110
|
return highlight_pygments(pygments, code, syntax, theme)
|
|
111
|
+
elsif !shiki.nil?
|
|
112
|
+
shiki_theme = Snibbets.options[:highlight_theme] || 'vitesse-dark'
|
|
113
|
+
return highlight_shiki(shiki, code, syntax, shiki_theme)
|
|
84
114
|
end
|
|
85
115
|
|
|
86
116
|
code
|
data/lib/snibbets/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: snibbets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.41
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brett Terpstra
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-01-23 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: bundler
|
|
@@ -264,6 +264,7 @@ files:
|
|
|
264
264
|
- lib/snibbets/menu.rb
|
|
265
265
|
- lib/snibbets/os.rb
|
|
266
266
|
- lib/snibbets/string.rb
|
|
267
|
+
- lib/snibbets/todo_spec.rb
|
|
267
268
|
- lib/snibbets/version.rb
|
|
268
269
|
- lib/snibbets/which.rb
|
|
269
270
|
- lib/themes/atom-one-dark.theme
|
|
@@ -327,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
327
328
|
- !ruby/object:Gem::Version
|
|
328
329
|
version: '0'
|
|
329
330
|
requirements: []
|
|
330
|
-
rubygems_version: 3.6.
|
|
331
|
+
rubygems_version: 3.6.6
|
|
331
332
|
specification_version: 4
|
|
332
333
|
summary: Snibbets
|
|
333
334
|
test_files: []
|