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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1f233a227990e104c69822136bf5ea926a0a7c04eba1d738f98264db47fc904
4
- data.tar.gz: 7c637eee8f81ab8ff23da31e71011ed230c62d6cd9b4a63b82f33c90ce3dbef5
3
+ metadata.gz: 65a8a931951246e4b20734d071ead64884366231e12526d6790b0c78a8dc8940
4
+ data.tar.gz: 4e875d9152a0ed900e96f7feadc1f28ab0eb1be76ad87a86ff34be562d3c2998
5
5
  SHA512:
6
- metadata.gz: ecd7514e9028c93d8ea5abce5a974684d67d7dc262ccdc7f4a8cba57731d80a658548bc34925c2972c3825fdc32d8fae87fcb649bf8e64944dbc6809712e606c
7
- data.tar.gz: a5aca5fa814e6054d1968ea9282a20b5ec0cde7a9a8bac2d01fb54b1efeb3abd531df79f28192612a114638f44eb11ce1c846916e356de31532dedb92f63697e
6
+ metadata.gz: e68034d4bc23511e3f4ea9e24058d4a9f47f28b23a034de570b55bab743114e4617925c99c551340be4ece37c03a24f63fe554eee80ab61a68523115577f576f
7
+ data.tar.gz: 60d444f08878ad2cf6febf4d5e8ec8b8a2d619be7feec6508f0dcca847a0b8c369c81158928bd6c21b86355390b3f5a1f61b1269b6c972a6e244a7d7a2b99aa1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 2.0.41
2
+
3
+ 2026-01-23 11:32
4
+
5
+ #### NEW
6
+
7
+ - Add shiki as a highlighter option
8
+
1
9
  ### 2.0.40
2
10
 
3
11
  2025-01-18 08:05
data/README.md CHANGED
@@ -256,7 +256,7 @@ installed and you don't configure it otherwise.
256
256
  ### Usage
257
257
 
258
258
  ```
259
- Snibbets v2.0.40
259
+ Snibbets v2.0.41
260
260
 
261
261
  Usage: snibbets [options] query
262
262
  -a, --all If a file contains multiple snippets, output all of them (no menu)
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/na/*.rb']
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
@@ -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
@@ -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] =~ /^s/ && !skylight.nil?
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
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # RSpec.describe Snibbets::Todo do
4
+ # subject(:todo) { Snibbets::Todo.new }
5
+
6
+ # describe ".todo" do
7
+ # it "returns todo" do
8
+ # expect(todo.todo).to be "TODO"
9
+ # end
10
+ # end
11
+ # end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snibbets
4
- VERSION = '2.0.40'
4
+ VERSION = '2.0.41'
5
5
  end
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.40
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: 2025-01-18 00:00:00.000000000 Z
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.2
331
+ rubygems_version: 3.6.6
331
332
  specification_version: 4
332
333
  summary: Snibbets
333
334
  test_files: []