zine_brewer 1.7.0 → 1.11.0

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: ee3ba68f6148bff1354914fd0f2b98c5e60b70341aae73cc113d4aed2b1aa5a4
4
- data.tar.gz: 7d25319819a05e422cdb9504e173bdfa455b938c3015a3ea6c84c58b73bcf6c3
3
+ metadata.gz: d64a3c71ecba43de692fa711576fa4c5a218a7f62850e42cb500d82de3d0c022
4
+ data.tar.gz: cd5305ccb1c290a1235420a449778bd186c51be507107e7fc4ec24403a34cac5
5
5
  SHA512:
6
- metadata.gz: 26a77c54ce06edc09849fbca363d08eff80b428e811d9ec3e95b0866dd192453be50e9aca6a16d7a0a8ca27dcf48b8917482a2d50ad723d71404fab472848b27
7
- data.tar.gz: 2c7f9293f59f9caa63243f042b9803d5518c1886de8ef043cf3f22b427712b812619ce31e44018d179b00441be1b2bf8c910ce83719cb59b761f6a03ea951845
6
+ metadata.gz: 7ac8faad841af5e80530b2e23789987370d47c5417538c10717548c1264873dd31d24c72d703ce34b9a11ed5f90372c540d18feb7fba1de3924c99e4d8e61100
7
+ data.tar.gz: a56c967e8b54bf99df7125dccddd2a77a269f8c3e31757db124431120e92cc5ff18182fbec484f6d328e693f1f2f64805472c0ca723497857c21acbc124c155d
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")
@@ -121,10 +123,6 @@ module Kramdown
121
123
  format_as_span_html(el.type, attr, res)
122
124
  end
123
125
 
124
- def convert_span(el, indent)
125
- format_as_span_html('span', el.attr, inner(el, indent))
126
- end
127
-
128
126
  def convert_em(el, indent)
129
127
  format_as_span_html('strong', el.attr, inner(el, indent))
130
128
  end
@@ -29,7 +29,6 @@ module Kramdown
29
29
  end
30
30
 
31
31
  @block_parsers.insert(5, :column, :definition_table, :wraparound,:div, :page)
32
- @span_parsers.insert(5, :span)
33
32
 
34
33
  @page = 0
35
34
  @fn_counter = 0
@@ -159,7 +158,7 @@ module Kramdown
159
158
  if @fn_number.has_key?(@src[1])
160
159
  warning("Duplicate footnote name '#{@src[1]}' on line #{start_line_number} - overwriting")
161
160
  end
162
- a = %!<a href="#fnref:#{@fn_number[@src[1]]}">[#{@fn_number[@src[1]]}]</a>: #{@src[2].strip}!
161
+ a = %!<a href="#fnref:#{@fn_number[@src[1]]}">\\[#{@fn_number[@src[1]]}\\]</a>: #{@src[2].strip}!
163
162
  p = new_block_el(:p, nil, {'id' => "fn:#{@fn_number[@src[1]]}"})
164
163
  p.children << new_block_el(:raw_text, a, nil)
165
164
  if @tree.children.last.type == :footnote_definition_sekd
@@ -49,6 +49,7 @@ module ZineBrewer
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
 
@@ -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.7.0"
2
+ VERSION = "1.11.0"
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.7.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori Ichigo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-14 00:00:00.000000000 Z
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description:
41
+ description:
42
42
  email:
43
43
  - akinori.ichigo@gmail.com
44
44
  executables:
@@ -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
@@ -77,7 +78,7 @@ metadata:
77
78
  homepage_uri: https://github.com/akinori-ichigo/zine_brewer
78
79
  source_code_uri: https://github.com/akinori-ichigo/zine_brewer
79
80
  changelog_uri: https://github.com/akinori-ichigo/zine_brewer
80
- post_install_message:
81
+ post_install_message:
81
82
  rdoc_options: []
82
83
  require_paths:
83
84
  - lib
@@ -93,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
94
  version: '0'
94
95
  requirements: []
95
96
  rubygems_version: 3.1.6
96
- signing_key:
97
+ signing_key:
97
98
  specification_version: 4
98
99
  summary: Kramdown to HTML converter for Shoeisha Web Media
99
100
  test_files: []