sakusei 0.5.8 → 0.5.9
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/Gemfile.lock +1 -1
- data/bin/sakusei-preview +2 -2
- data/lib/sakusei/cli.rb +2 -14
- data/lib/sakusei/version.rb +1 -1
- data/lib/sakusei.rb +22 -0
- 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: f8f86cb0ba1fda1a5536579ffc06db171359b7d839537bef66a7622dabed68be
|
|
4
|
+
data.tar.gz: 1eeb757166832e05c87fa8ae7d8a654a4cf2c5abab097b82e4466245d99830d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e6d8145acd491414bdaea711ba249557aa887a049b0d7c59788825d1b8946cb93f33a4f5e87be5b3843f2ef8703577fe34dd7c0ec7681f9b55216c897e3aad17
|
|
7
|
+
data.tar.gz: 07ead103bda8c9d269501f6384f2d42d37efaf718f66237b006a0dc2430974535696d3eb1e1fb1b46b82683afa0eed437dd6a0a590692c01b6fd53f42f0daafa
|
data/Gemfile.lock
CHANGED
data/bin/sakusei-preview
CHANGED
|
@@ -24,9 +24,9 @@ if args.empty?
|
|
|
24
24
|
exit 1
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
source_file = args.first
|
|
27
|
+
source_file = Sakusei.resolve_file_extension(args.first)
|
|
28
28
|
unless File.exist?(source_file)
|
|
29
|
-
warn "File not found: #{
|
|
29
|
+
warn "File not found: #{args.first}"
|
|
30
30
|
exit 1
|
|
31
31
|
end
|
|
32
32
|
|
data/lib/sakusei/cli.rb
CHANGED
|
@@ -242,26 +242,14 @@ module Sakusei
|
|
|
242
242
|
return false if arg.nil? || arg.empty?
|
|
243
243
|
return false if File.extname(arg).length > 0 # Already has an extension
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
Sakusei::MARKDOWN_EXTENSIONS.any? { |ext| File.exist?(arg + ext) }
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
private
|
|
249
249
|
|
|
250
250
|
# Resolve file by trying markdown extensions if no extension provided
|
|
251
251
|
def resolve_file_extension(file)
|
|
252
|
-
|
|
253
|
-
return file if File.directory?(file)
|
|
254
|
-
return file if file.include?('*') # Glob pattern
|
|
255
|
-
return file if File.extname(file).length > 0 # Already has extension
|
|
256
|
-
|
|
257
|
-
# Try markdown extensions
|
|
258
|
-
%w[.md .text .markdown].each do |ext|
|
|
259
|
-
path_with_ext = file + ext
|
|
260
|
-
return path_with_ext if File.exist?(path_with_ext)
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
# Return original if no extension found
|
|
264
|
-
file
|
|
252
|
+
Sakusei.resolve_file_extension(file)
|
|
265
253
|
end
|
|
266
254
|
|
|
267
255
|
def open_pdf(path)
|
data/lib/sakusei/version.rb
CHANGED
data/lib/sakusei.rb
CHANGED
|
@@ -21,6 +21,28 @@ require_relative 'sakusei/page_chrome_translator'
|
|
|
21
21
|
module Sakusei
|
|
22
22
|
class Error < StandardError; end
|
|
23
23
|
|
|
24
|
+
# Markdown extensions to auto-discover when a CLI is given a file argument
|
|
25
|
+
# without an extension (e.g. `sakusei-preview ai_workflow_assessment`).
|
|
26
|
+
MARKDOWN_EXTENSIONS = %w[.md .text .markdown].freeze
|
|
27
|
+
|
|
28
|
+
# Resolve a file argument by trying known markdown extensions if no extension
|
|
29
|
+
# was given. Returns the input unchanged if the file already exists, is a
|
|
30
|
+
# directory, looks like a glob, or already has an extension.
|
|
31
|
+
def self.resolve_file_extension(file)
|
|
32
|
+
return file if file.nil? || file.empty?
|
|
33
|
+
return file if File.exist?(file)
|
|
34
|
+
return file if File.directory?(file)
|
|
35
|
+
return file if file.include?('*')
|
|
36
|
+
return file if File.extname(file).length.positive?
|
|
37
|
+
|
|
38
|
+
MARKDOWN_EXTENSIONS.each do |ext|
|
|
39
|
+
candidate = file + ext
|
|
40
|
+
return candidate if File.exist?(candidate)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
file
|
|
44
|
+
end
|
|
45
|
+
|
|
24
46
|
# Main entry point for building PDFs
|
|
25
47
|
def self.build(source_file, options = {})
|
|
26
48
|
Builder.new(source_file, options).build
|