Module: Sakusei
- Defined in:
- lib/sakusei.rb,
lib/sakusei/cli.rb,
lib/sakusei/builder.rb,
lib/sakusei/version.rb,
lib/sakusei/pdf_concat.rb,
lib/sakusei/style_pack.rb,
lib/sakusei/erb_processor.rb,
lib/sakusei/file_resolver.rb,
lib/sakusei/style_preview.rb,
lib/sakusei/vue_processor.rb,
lib/sakusei/converter_base.rb,
lib/sakusei/html_converter.rb,
lib/sakusei/preview_server.rb,
lib/sakusei/heading_wrapper.rb,
lib/sakusei/multi_file_builder.rb,
lib/sakusei/image_path_resolver.rb,
lib/sakusei/md_to_pdf_converter.rb,
lib/sakusei/page_chrome_translator.rb
Defined Under Namespace
Classes: Builder, CLI, ConverterBase, ErbProcessor, Error, FileResolver, HeadingWrapper, HtmlConverter, ImagePathResolver, MdToPdfConverter, MultiFileBuilder, PageChromeTranslator, PdfConcatenator, PreviewServer, StylePack, StylePackInitializer, StylePreview, VueProcessor
Constant Summary collapse
- MARKDOWN_EXTENSIONS =
Markdown extensions to auto-discover when a CLI is given a file argument without an extension (e.g. ‘sakusei-preview ai_workflow_assessment`).
%w[.md .text .markdown].freeze
- VERSION =
'0.5.9'
Class Method Summary collapse
-
.build(source_file, options = {}) ⇒ Object
Main entry point for building PDFs.
-
.resolve_file_extension(file) ⇒ Object
Resolve a file argument by trying known markdown extensions if no extension was given.
Class Method Details
.build(source_file, options = {}) ⇒ Object
Main entry point for building PDFs
47 48 49 |
# File 'lib/sakusei.rb', line 47 def self.build(source_file, = {}) Builder.new(source_file, ).build end |
.resolve_file_extension(file) ⇒ Object
Resolve a file argument by trying known markdown extensions if no extension was given. Returns the input unchanged if the file already exists, is a directory, looks like a glob, or already has an extension.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sakusei.rb', line 31 def self.resolve_file_extension(file) return file if file.nil? || file.empty? return file if File.exist?(file) return file if File.directory?(file) return file if file.include?('*') return file if File.extname(file).length.positive? MARKDOWN_EXTENSIONS.each do |ext| candidate = file + ext return candidate if File.exist?(candidate) end file end |