mp 0.1.0 → 0.1.1

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: ff079cf7563dddd6684f0a4b88d59adba0e0a7290c505f45687566c5bc13af9a
4
- data.tar.gz: 8178770f3b19a573736ffc24e20534221170dfe7d7429c65edd5bc619bac3b1d
3
+ metadata.gz: 34fc0a2942d59611b53629311f2696063e7c780f5d5a23f295961806f13898da
4
+ data.tar.gz: bbf907d4146120f4438f9e260a402dc7fca7fd7a8e3e366ef987cd6655fea2d0
5
5
  SHA512:
6
- metadata.gz: 50c91001bcbd108799a7e752910e5b7bab6badcd530a8357b07860bf22f5484a190c509cafc05ebc2b243a0755a9a329e8bf9f1d7d4986902cbfe8269d59448c
7
- data.tar.gz: e252cc2177716ade059b52fd4846228c41c1f3b1598db1683005a6d3f580946012514deac78d3dbdfd3bbcc2890d14638949475b1a95f881bdcae59ce5f705e9
6
+ metadata.gz: 999b1907304af0e73c5520565a1e4cc20d68beb94f54ca4509589b9978c1e6ad75839ed5b21100bbee4ffbb8504fdd7137550bfce94ba3779472518004bae851
7
+ data.tar.gz: 9b86c3d9a52300db5b225fde23b43e94e4d5e108b02c07c6ca3ecf3bc0e83fc885e1527331fb936fb135a2425b0511e68ef9c0667429cbe9355a8a215fe408f3
data/README.md CHANGED
@@ -32,6 +32,8 @@ Markdown や CSS を保存すると自動で再読み込みします。このと
32
32
  | `## 見出し` | 通常のスライド 1 枚。見出しがページタイトルになる |
33
33
  | `---` | タイトルなしの続きスライド |
34
34
 
35
+ 見出しだけで本文がないスライドは、タイトルを画面の中央に置きます。左に寄せるには `<!-- _class: left -->` を書きます。
36
+
35
37
  ## ターミナルの埋め込み
36
38
 
37
39
  ````markdown
@@ -88,7 +90,7 @@ style: |
88
90
  <!-- _backgroundColor: black --> このスライドだけに適用(先頭に _)
89
91
  ```
90
92
 
91
- 使えるディレクティブは `paginate` `header` `footer` `class` `color` `backgroundColor` `backgroundImage` `backgroundPosition` `backgroundRepeat` `backgroundSize` です。クラスには `lead`(中央寄せ)、`invert`(配色反転)、`columns`(2 列)があります。
93
+ 使えるディレクティブは `paginate` `header` `footer` `class` `color` `backgroundColor` `backgroundImage` `backgroundPosition` `backgroundRepeat` `backgroundSize` です。クラスには `lead`(中央寄せ)、`left`(左寄せ)、`invert`(配色反転)、`columns`(2 列)があります。
92
94
 
93
95
  **画像**
94
96
 
data/lib/mp/deck.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "cgi"
3
+ require "cgi/escape"
4
4
  require "shellwords"
5
5
  require "yaml"
6
6
  require_relative "slide_renderer"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "cgi"
3
+ require "cgi/escape"
4
4
  require "kramdown"
5
5
  require "kramdown-parser-gfm"
6
6
  require "rouge"
@@ -43,6 +43,7 @@ module Mp
43
43
  document = Kramdown::Document.new(source, KRAMDOWN)
44
44
  @source_lines = source.split("\n", -1)
45
45
  transform(document.root)
46
+ @title_only = title_only?(document.root)
46
47
  html = scope_styles(restore_tokens(document.to_html))
47
48
  html = html.sub(/<h([12])>/, '<h\1 class="fit">') if @chunk.fit
48
49
 
@@ -59,6 +60,14 @@ module Mp
59
60
  element.children.each { convert_image(_1) if _1.type == :img }
60
61
  end
61
62
 
63
+ # 背景画像はここまでに取り除かれ、ノートは kramdown に渡していない
64
+ def title_only?(root)
65
+ return false if @chunk.kind == :continuation
66
+
67
+ content = root.children.reject { _1.type == :blank || (_1.type == :html_element && _1.value == "style") }
68
+ content.length == 1 && content.first.type == :header
69
+ end
70
+
62
71
  def background_only?(element)
63
72
  return false unless element.type == :p
64
73
 
@@ -135,7 +144,8 @@ module Mp
135
144
 
136
145
  def classes
137
146
  kind = { cover: "cover", continuation: "continuation" }[@chunk.kind]
138
- ["slide", kind, *Array(@directives["class"]).flat_map { _1.to_s.split }].compact.join(" ")
147
+ title_only = "title-only" if @title_only
148
+ ["slide", kind, *Array(@directives["class"]).flat_map { _1.to_s.split }, title_only].compact.join(" ")
139
149
  end
140
150
 
141
151
  def style
data/lib/mp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mp
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/public/style.css CHANGED
@@ -20,6 +20,16 @@ section.slide.active { visibility: visible; }
20
20
  section.slide.cover, section.slide.lead { justify-content: center; }
21
21
  section.slide.lead { text-align: center; align-items: center; }
22
22
 
23
+ /* 見出しだけのスライドは自動で中央に置く */
24
+ section.slide.title-only { justify-content: center; align-items: center; text-align: center; }
25
+ section.slide.title-only > :is(h1, h2) { margin: 0; padding: 0; border: 0; }
26
+
27
+ /* 左寄せ: <!-- _class: left --> */
28
+ section.slide.left { align-items: stretch; text-align: left; }
29
+
30
+ /* 中央寄せでも横幅いっぱいを基準に拡大する */
31
+ section.slide > .fit { align-self: stretch; }
32
+
23
33
  /* 見出しの下を 2 列にする: <!-- _class: columns --> */
24
34
  section.slide.columns {
25
35
  display: grid;
@@ -41,6 +51,7 @@ section.slide > header, section.slide > footer, section.slide > .page-number {
41
51
  left: var(--pad);
42
52
  right: var(--pad);
43
53
  z-index: 2;
54
+ text-align: left; /* 中央寄せのスライドでも位置を変えない */
44
55
  font-size: 18px;
45
56
  opacity: .65;
46
57
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - takkanm
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  - !ruby/object:Gem::Version
225
225
  version: '0'
226
226
  requirements: []
227
- rubygems_version: 4.0.3
227
+ rubygems_version: 4.0.24
228
228
  specification_version: 4
229
229
  summary: Markdown を全画面プレゼンテーションにするツール(ターミナル / Web 埋め込み対応)
230
230
  test_files: []