zine_brewer 1.8.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ec1e562956e0815a826a59cef79390646e78600d8a63e00d77561813596a20d
4
- data.tar.gz: f3f4a11911c859b2d86b8f69f53167a922355b213500ace38fffb0c672d309df
3
+ metadata.gz: acc53bca60e0672756e165ad78c244050d3fcbf9aac968ea3cb842b9e3352ee9
4
+ data.tar.gz: dcd432bec401c8064f31b1350e5d24dfd2a3046cfe23e69b2fa083466ba544ad
5
5
  SHA512:
6
- metadata.gz: 973130be4a6996dcde4d97683711aee2c6827c1910b3414a21389c8493a920a31fdf2289c5171a00a5587307f9a0bf14a7df32f449ff68681f2280902069c020
7
- data.tar.gz: 2ebbd32bf872e1c4cfb570b7b0f26c6a1c759e2fe97d1b5adfde6136c2f95f342495753df3d22cba0a297ff79c0af78b0f07e402926ffa5d45eff4087a90e3d5
6
+ metadata.gz: 55d5263353cbab4604547eb9a0497381933f2d1303d909eb667fc9b5c74e09f00f1c2477c92d3a401f4f9b50708d42166bd1e90960e21d9f399e288291feef87
7
+ data.tar.gz: ac5871e89764f0888dd5642a1fb8a1d49e98c60007c0eac914739b5ed6e8049df7a0e0eb33ab6c4f8fb99187768f364fa90f3617ae1ba751de16099d4f70170b
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile CHANGED
@@ -4,3 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
+
8
+ gem "rspec", "~> 3.0"
9
+
10
+ gem "pry"
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ZineBrewer
2
2
 
3
- ZineBrewer converts Kramdown (=exhanced Markdown) document to HTML for Shoeisha Web Media.
3
+ ZineBrewer converts Kramdown (=exhanced Markdown) document to HTML for a web media.
4
4
 
5
5
  ## Installation
6
6
 
@@ -353,12 +353,12 @@ width: 200px
353
353
 
354
354
  #### ■定義表の書き方
355
355
 
356
- 定義リストの記述を`===dtable`〜`==/dtable`で挟むと、左に項目、右に内容のテーブル(表)ができます。
356
+ 定義リストの記述を`===dtable`〜`==/dtable`で挟むと、左に項目、右に内容のテーブル(表)ができます。キャプション(caption)を定義できるほか、1列目の幅を`th-width`属性で指定できます。
357
357
 
358
358
  例えば、次のように記述すると、
359
359
 
360
360
  ```
361
- {:caption="イベント概要"}
361
+ {:caption="イベント概要" th-width="20%"}
362
362
  ===dtable
363
363
  イベント名
364
364
  : HRzine Day 2020 Autumn
@@ -376,7 +376,7 @@ width: 200px
376
376
 
377
377
  次のように表示されます。
378
378
 
379
- ![dtable](https://user-images.githubusercontent.com/24837059/94995269-32e6e680-05d8-11eb-86ed-074e650ff2eb.png)
379
+ ![dtable](https://user-images.githubusercontent.com/24837059/133894991-59887c24-3c2f-402d-a854-b56c55d7da8c.png)
380
380
 
381
381
  #### ■スタイルの書き方
382
382
 
@@ -75,10 +75,12 @@ module Kramdown
75
75
  end
76
76
 
77
77
  def convert_definition_table(el, indent)
78
+ th_width = el.attr.delete('th-width')
79
+ th = th_width.nil? ? "<th>" : "<th width=\"#{th_width}\">"
78
80
  raw_caption = el.attr.delete('caption')
79
81
  rows = raw_caption.nil? ? '' : table_caption(raw_caption)
80
82
  inner(el.children.first, indent).scan(/(<dt>.+?<\/dt>|<dd>.+?<\/dd>)/m).
81
- map{|x| x.first.sub(/\A<dt>(.+)<\/dt>\z/m, "<th>\\1</th>")}.
83
+ map{|x| x.first.sub(/\A<dt>(.+)<\/dt>\z/m, "#{th}\\1</th>")}.
82
84
  map{|x| x.sub(/\A<dd>(.+)<\/dd>\z/m, "<td>\\1</td>")}.
83
85
  each_slice(2) do |x|
84
86
  row = x.map{|c| (' '*(indent + 2)) + c}.join("\n")
@@ -42,18 +42,19 @@ module ZineBrewer
42
42
 
43
43
  @article_id = $+ if header.sub!(/^■記事ID■[^0-9]+(\d+)$/, '')
44
44
  h = header.strip.split(/\n\n+/)
45
- @corner = set_header_item(h[0], 'IT人材ラボの記事・ニュース')
45
+ @corner = set_header_item(h[0], '記事・ニュースのコーナー')
46
46
  @title = set_header_item(h[1], 'タイトル' )
47
47
  @lead = set_header_item(h[2], 'リード')
48
48
  @pic = set_header_item(h[3], 'dummy.png')
49
49
  @author = set_header_item(h[4], '著者 クレジット')
50
50
  @css = set_header_item(h[5], '')
51
51
 
52
+ @pp_header = make_pp_header
52
53
  @converted = convert(body)
53
54
  end
54
55
 
55
56
  def set_header_item(target, default)
56
- if /\A[\-%]+\Z/ =~ target || target.nil?
57
+ if /\A\ufeff?[\-%]+\Z/ =~ target || target.nil?
57
58
  default.define_singleton_method(:is_complete?){ false }
58
59
  default
59
60
  else
@@ -62,6 +63,17 @@ module ZineBrewer
62
63
  end
63
64
  end
64
65
 
66
+ def make_pp_header
67
+ header_output = []
68
+ header_output << "[コーナー]\n#{@corner}" if @corner.is_complete?
69
+ header_output << "[タイトル]\n#{@title}" if @title.is_complete?
70
+ header_output << "[リード]\n<p>#{@lead}</p>" if @lead.is_complete?
71
+ header_output << "[タイトル画像]\n#{@pic}" if @pic.is_complete?
72
+ header_output << "[著者クレジット]\n#{@author}" if @author.is_complete?
73
+ header_output << "[追加CSS]\n#{@css}" if @css.is_complete?
74
+ header_output.join("\n\n")
75
+ end
76
+
65
77
  ## Writing out header and body to each file
66
78
  def write_out
67
79
  make_proof_directory
@@ -78,15 +90,8 @@ module ZineBrewer
78
90
  end
79
91
 
80
92
  def write_proof_header
81
- header_output = ""
82
- header_output << "[コーナー]\n#{@corner}\n\n" if @corner.is_complete?
83
- header_output << "[タイトル]\n#{@title}\n\n" if @title.is_complete?
84
- header_output << "[リード]\n<p>#{@lead}</p>\n\n" if @lead.is_complete?
85
- header_output << "[タイトル画像]\n#{@pic}\n\n" if @pic.is_complete?
86
- header_output << "[著者クレジット]\n#{@author}\n\n" if @author.is_complete?
87
- header_output << "[追加CSS]\n#{@css}\n\n" if @css.is_complete?
88
93
  File.open("#{@proof_dir}/header.txt", 'wb') do |f|
89
- f.write(header_output)
94
+ f.write(@pp_header)
90
95
  end
91
96
  end
92
97
 
@@ -120,6 +125,11 @@ module ZineBrewer
120
125
  ### Converts a markdown document and returns that converted body
121
126
  dkmn.convert
122
127
  end
128
+
129
+ ### pretty print of the converted document
130
+ def pretty_print
131
+ @pp_header + "\n\n" + @converted
132
+ end
123
133
  end
124
134
  end
125
135
 
@@ -13,7 +13,7 @@ class BookRanking < Mustache
13
13
  @template = <<EOT
14
14
  <div class="imgLRBlock cf">
15
15
  <figure class="imgR">
16
- <a href="{{url}}" target="_blank"><img alt="{{title}}" loading="lazy" src="{{cover}}" style="border:1px solid #808080;" width="100" title="{{title}}" /></a></figure>
16
+ <a href="{{url}}" target="_blank"><img alt="{{title}}" loading="lazy" src="{{cover}}" style="border:1px solid #808080; width:100px;" title="{{title}}" /></a></figure>
17
17
  <p markdown="1"> {{& description}}</p>
18
18
  </div>
19
19
  EOT
@@ -13,7 +13,7 @@ class Casts < Mustache
13
13
  # cap: プロフィール
14
14
 
15
15
  # CSSに下記の登録が必要
16
- # article#contents div.article div.casts>div ~ div { margin-top:8px; }
16
+ # .c-article_content div.casts>div ~ div { margin-top:8px; }
17
17
 
18
18
  @template = <<EOT
19
19
  <div class="casts" style="margin-bottom:30px; padding:13px 13px 3px; border:solid 2px #eee;">
@@ -21,7 +21,7 @@ class Casts < Mustache
21
21
  {{#title_sw}}<h4>{{title}}</h4>{{/title_sw}}
22
22
  <div class="imgLRBlock cf">
23
23
  <figure class="imgL">
24
- <img src="{{fig_src}}" loading="lazy" alt="{{name}}" height="135" width="110" />
24
+ <img src="{{fig_src}}" loading="lazy" alt="{{name}}" style="height:135px;" />
25
25
  </figure>
26
26
  <p class="ovh" markdown="span" style="font-size:14px; line-height:1.7; margin-bottom:10px;"><strong style="font-size:15px;">{{name}}({{huri}})氏</strong><br />{{& caption}}</p>
27
27
  </div>
@@ -68,7 +68,7 @@ EOT
68
68
 
69
69
  def make_caption(l_cap)
70
70
  begin
71
- l_cap.chomp.sub(/^\\/, '').gsub(/\n/, '(((BR)))')
71
+ l_cap.chomp.sub(/^\\/, '').gsub(/\n/, '<br/>')
72
72
  rescue
73
73
  nil
74
74
  end
@@ -10,7 +10,8 @@ module Fig_00
10
10
  a_img[:fig_src] = make_src(h["src"])
11
11
  a_img[:href] = h["href"]
12
12
  a_img[:alt] = make_alt(h["alt"])
13
- a_img[:img_size] = make_img_size(h["width"], h["height"])
13
+ a_img[:img_style] = make_img_style(h["width"], h["height"]) \
14
+ unless h["width"].nil? && h["height"].nil?
14
15
  result << a_img
15
16
  end
16
17
  result
@@ -18,7 +19,7 @@ module Fig_00
18
19
 
19
20
  def caption
20
21
  begin
21
- cap.chomp.sub(/^\\/, '').gsub(/\n/,'(((BR)))')
22
+ cap.chomp.sub(/^\\/, '').gsub(/\n/,'<br/>')
22
23
  rescue
23
24
  nil
24
25
  end
@@ -53,11 +54,13 @@ module Fig_00
53
54
  end
54
55
  end
55
56
 
56
- def make_img_size(l_width, l_height)
57
+ def make_img_style(l_width, l_height)
57
58
  s = []
58
- s << %Q{width="#{l_width}"} unless l_width.nil?
59
- s << %Q{height="#{l_height}"} unless l_height.nil?
60
- s.join(' ').strip
59
+ s << "width:#{l_width};" unless l_width.nil?
60
+ s << "height:#{l_height};" unless l_height.nil?
61
+ unless s.all?{|v| v.nil? }
62
+ %Q{style="#{s.join(' ').strip}" }
63
+ end
61
64
  end
62
65
 
63
66
  end
@@ -17,7 +17,7 @@ class Fig_A < Mustache
17
17
  @template = <<EOT
18
18
  <figure>
19
19
  {{#imgs_list}}
20
- <a href="{{fig_src}}" target="_blank"><img src="{{fig_src}}" loading="lazy" alt="{{alt}}"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} /></a>
20
+ <a href="{{fig_src}}" target="_blank"><img src="{{fig_src}}" loading="lazy" alt="{{alt}}" {{& img_style}} /></a>
21
21
  {{/imgs_list}}
22
22
  <figcaption markdown="span">{{#caption}}{{& caption}}<br/>{{/caption}}[画像クリックで拡大表示]</figcaption>
23
23
  </figure>
@@ -18,7 +18,7 @@ class Fig_H < Mustache
18
18
  @template = <<EOT
19
19
  <figure>
20
20
  {{#imgs_list}}
21
- <a href="{{href}}" target="_blank"><img src="{{fig_src}}" loading="lazy" alt="{{alt}}"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} /></a>
21
+ <a href="{{href}}" target="_blank"><img src="{{fig_src}}" loading="lazy" alt="{{alt}}" {{& img_style}} /></a>
22
22
  {{/imgs_list}}
23
23
  {{#caption}}<figcaption markdown="span">{{& caption}}</figcaption>{{/caption}}
24
24
  </figure>
@@ -13,12 +13,11 @@ class Fig_N < Mustache
13
13
  # width: 画像幅
14
14
  # height: 画像高さ
15
15
  # cap: キャプション
16
- # from: 出典 << 出典URL
17
16
 
18
17
  @template = <<EOT
19
18
  <figure>
20
19
  {{#imgs_list}}
21
- <img src="{{fig_src}}" loading="lazy" alt="{{alt}}"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} />
20
+ <img src="{{fig_src}}" loading="lazy" alt="{{alt}}" {{& img_style}} />
22
21
  {{/imgs_list}}
23
22
  {{#caption}}<figcaption markdown="span">{{caption}}</figcaption>{{/caption}}
24
23
  </figure>
@@ -10,22 +10,26 @@ class Fig_P < Mustache
10
10
 
11
11
  # <<Fig_P>>
12
12
  # src: 画像ファイル名
13
- # name: 姓 名
14
- # huri: ふり・がな
15
13
  # width: 画像幅
16
14
  # height: 画像高さ
15
+ # name: 姓 名
16
+ # huri: ふり・がな
17
+ # title: 肩書き
17
18
  # cap: |
18
- # キャプション
19
+ # プロフィール
19
20
 
20
21
  @template = <<EOT
21
22
  <figure>
22
23
  {{#imgs_list}}
23
- <img src="{{fig_src}}" loading="lazy" alt="{{name}}氏"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} />
24
+ <img src="{{fig_src}}" loading="lazy" alt="{{name}}氏" {{& img_style}} />
24
25
  {{/imgs_list}}
25
- <div style="text-align:left; padding:0px 35px;">
26
- <figcaption><strong>{{name}}({{huri}})氏</strong></figcaption>
27
- <figcaption markdown="span">{{caption}}</figcaption>
28
- </div>
26
+ <figcaption style="text-align:left;">
27
+ <strong>{{name}}({{huri}})氏</strong><br/>
28
+ <span markdown="span">{{title}}</span>
29
+ <div markdown="span" style="margin-top:6px;">
30
+ {{{caption}}}
31
+ </div>
32
+ </figcaption>
29
33
  </figure>
30
34
  EOT
31
35
 
@@ -17,7 +17,7 @@ class Fig_Z < Mustache
17
17
  @template = <<EOT
18
18
  <figure>
19
19
  {{#imgs_list}}
20
- <a href="{{fig_src}}" rel="lightbox" target="_blank"><img src="{{fig_src}}" loading="lazy" alt="{{alt}}"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} /></a>
20
+ <a href="{{fig_src}}" rel="lightbox" target="_blank"><img src="{{fig_src}}" alt="{{alt}}" {{& img_style}}/></a>
21
21
  {{/imgs_list}}
22
22
  <figcaption markdown="span">{{#caption}}{{& caption}}<br/>{{/caption}}[画像クリックで拡大表示]</figcaption>
23
23
  </figure>
@@ -1,3 +1,3 @@
1
1
  module ZineBrewer
2
- VERSION = "1.8.0"
2
+ VERSION = "1.11.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zine_brewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori Ichigo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-12 00:00:00.000000000 Z
11
+ date: 2022-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache
@@ -47,6 +47,7 @@ executables:
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
+ - ".rspec"
50
51
  - CODE_OF_CONDUCT.md
51
52
  - Gemfile
52
53
  - LICENSE.txt