przn 0.1.5

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.
data/lib/przn/theme.rb ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module Przn
6
+ class Theme
7
+ DEFAULT_PATH = File.expand_path('../../../default_theme.yml', __FILE__)
8
+
9
+ attr_reader :colors, :font
10
+
11
+ def self.load(path)
12
+ raise ArgumentError, "Theme file not found: #{path}" unless File.exist?(path)
13
+
14
+ defaults = load_yaml(DEFAULT_PATH)
15
+ overrides = load_yaml(path)
16
+ merged = {
17
+ colors: defaults[:colors].merge(overrides[:colors] || {}),
18
+ font: defaults[:font].merge(overrides[:font] || {}),
19
+ }
20
+ new(merged)
21
+ end
22
+
23
+ def self.default
24
+ new(load_yaml(DEFAULT_PATH))
25
+ end
26
+
27
+ def self.load_yaml(path)
28
+ data = YAML.safe_load_file(path, symbolize_names: true) || {}
29
+ {
30
+ colors: data[:colors] || {},
31
+ font: data[:font] || {},
32
+ }
33
+ end
34
+ private_class_method :load_yaml
35
+
36
+ def initialize(config)
37
+ @colors = config[:colors]
38
+ @font = config[:font]
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Przn
4
+ VERSION = "0.1.5"
5
+ end
data/lib/przn.rb ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "przn/version"
4
+ require_relative "przn/kitty_text"
5
+ require_relative "przn/image_util"
6
+ require_relative "przn/slide"
7
+ require_relative "przn/parser"
8
+ require_relative "przn/presentation"
9
+ require_relative "przn/terminal"
10
+ require_relative "przn/renderer"
11
+ require_relative "przn/controller"
12
+ require_relative "przn/pdf_exporter"
13
+ require_relative "przn/theme"
14
+
15
+ module Przn
16
+ class Error < StandardError; end
17
+
18
+ def self.start(file, theme: nil)
19
+ markdown = File.read(file)
20
+ presentation = Parser.parse(markdown)
21
+ terminal = Terminal.new
22
+ base_dir = File.dirname(File.expand_path(file))
23
+ renderer = Renderer.new(terminal, base_dir: base_dir, theme: theme)
24
+ Controller.new(presentation, terminal, renderer)
25
+ end
26
+
27
+ def self.export_pdf(file, output, theme: nil)
28
+ markdown = File.read(file)
29
+ presentation = Parser.parse(markdown)
30
+ base_dir = File.dirname(File.expand_path(file))
31
+ PdfExporter.new(presentation, base_dir: base_dir, theme: theme).export(output)
32
+ puts "Generated: #{output}"
33
+ end
34
+ end
data/sample/sample.md ADDED
@@ -0,0 +1,45 @@
1
+ # przn
2
+
3
+ A terminal presentation tool written in Ruby
4
+
5
+ # Features
6
+
7
+ - **Markdown** based slides
8
+ - *Kitty text sizing* protocol support
9
+ - Simple keyboard navigation
10
+
11
+ # Code Blocks
12
+
13
+ ```ruby
14
+ puts "Hello from przn!"
15
+ ```
16
+
17
+ # Inline Formatting
18
+
19
+ This is **bold**, this is *italic*, and this is `inline code`.
20
+
21
+ > This is a blockquote
22
+
23
+ # Lists
24
+
25
+ - First item
26
+ - Second item
27
+ - Third item
28
+
29
+ 1. Ordered one
30
+ 2. Ordered two
31
+ 3. Ordered three
32
+
33
+ # Custom Styling
34
+
35
+ {::tag name="xx-large"}BIG text{:/tag}
36
+
37
+ {::tag name="x-large"}large text{:/tag}
38
+
39
+ {::tag name="large"}large text{:/tag}
40
+
41
+ normal and {::tag name="red"}red text{:/tag} mixed
42
+
43
+ # Thank You!
44
+
45
+ That's all! Enjoy!
data/sig/przn.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Przn
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: przn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Akira Matsuda
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: prawn
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ description: A terminal-based presentation tool that renders Markdown slides with
27
+ Kitty text sizing protocol support for beautifully scaled headers
28
+ email:
29
+ - ronnie@dio.jp
30
+ executables:
31
+ - przn
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE.txt
36
+ - README.md
37
+ - Rakefile
38
+ - default_theme.yml
39
+ - exe/przn
40
+ - lib/przn.rb
41
+ - lib/przn/controller.rb
42
+ - lib/przn/image_util.rb
43
+ - lib/przn/kitty_text.rb
44
+ - lib/przn/parser.rb
45
+ - lib/przn/pdf_exporter.rb
46
+ - lib/przn/presentation.rb
47
+ - lib/przn/renderer.rb
48
+ - lib/przn/slide.rb
49
+ - lib/przn/terminal.rb
50
+ - lib/przn/theme.rb
51
+ - lib/przn/version.rb
52
+ - sample/sample.md
53
+ - sig/przn.rbs
54
+ homepage: https://github.com/amatsuda/przn
55
+ licenses:
56
+ - MIT
57
+ metadata:
58
+ allowed_push_host: https://rubygems.org
59
+ source_code_uri: https://github.com/amatsuda/przn
60
+ homepage_uri: https://github.com/amatsuda/przn
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubygems_version: 4.1.0.dev
76
+ specification_version: 4
77
+ summary: Terminal presentation tool
78
+ test_files: []