zine_brewer 1.6.0 → 1.9.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: 9f47a38372b16bb0fdf904883a92e1b1e6c312b535e7efeba1c5ea5f34143d89
4
- data.tar.gz: 057c4e1ed3e0408135326a69db755a4d50b4a4cef5e10ab3969030f6e78fe289
3
+ metadata.gz: 9377b1600b8679c919199df61d3c142c7f8a0c9c1972d891a31cd6429b406a49
4
+ data.tar.gz: b100b1ad9d96943035a8acd2dd043aa27499c348d8e9a9b9c4bbef47b9d2d0b2
5
5
  SHA512:
6
- metadata.gz: c9a74e98d128f27bb27f859e80a45eb2bf242c5eeb523be44795a6d06cae851ad66b004a74338e6893312ceff02d31efa8f3864147c3ece6eb4cb1688b47c605
7
- data.tar.gz: 41ad0cf51d8e2d6c2aa466bb9bf752c4c3158f2ee2d33365f60fa06a1bd77b11ba0d32c2e74f3931f41f29b874eab4eccf94e520d8e39f66347ad2b3f6839cb8
6
+ metadata.gz: ba17f9a2b9d9288b7e54e97f3fa9ccacfa9bebfad069810bd8fb20526e012d32a944f3c1bb44851b5d899d4c94b532c958bb8a2c8dbe2d36abd381f258b2bd99
7
+ data.tar.gz: b5e927c93f297b95758ad684cb54e770a981372fc2815e1f50f7d2de0d4347edf504b5f269ba0b50518fadbd09ed3550d0adc51a022c1e5504cd8ad105bd1ddc
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"
@@ -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}}" src="{{cover}}" style="border:1px solid #808080; width:100px;" title="{{title}}" /></a></figure>
16
+ <a href="{{url}}" target="_blank"><img alt="{{title}}" loading="lazy" src="{{cover}}" style="border:1px solid #808080;" width="100" title="{{title}}" /></a></figure>
17
17
  <p markdown="1"> {{& description}}</p>
18
18
  </div>
19
19
  EOT
@@ -25,7 +25,7 @@ EOT
25
25
  def cover
26
26
  case File.dirname(src)
27
27
  when ".", "images"
28
- f = File.basename(l_src)
28
+ f = File.basename(src)
29
29
  "/static/images/article/■記事ID■/#{/^\d+_/ =~ f ? f : '■記事ID■_' + f}"
30
30
  when "common"
31
31
  "/static/images/article/common/#{File.basename(src)}"
@@ -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}}" alt="{{name}}" style="height:135px;" />
24
+ <img src="{{fig_src}}" loading="lazy" alt="{{name}}" height="135" width="110" />
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>
@@ -10,8 +10,7 @@ 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_style] = make_img_style(h["width"], h["height"]) \
14
- unless h["width"].nil? && h["height"].nil?
13
+ a_img[:img_size] = make_img_size(h["width"], h["height"])
15
14
  result << a_img
16
15
  end
17
16
  result
@@ -54,13 +53,11 @@ module Fig_00
54
53
  end
55
54
  end
56
55
 
57
- def make_img_style(l_width, l_height)
56
+ def make_img_size(l_width, l_height)
58
57
  s = []
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
58
+ s << %Q{width="#{l_width}"} unless l_width.nil?
59
+ s << %Q{height="#{l_height}"} unless l_height.nil?
60
+ s.join(' ').strip
64
61
  end
65
62
 
66
63
  end
@@ -3,11 +3,10 @@
3
3
  require 'mustache'
4
4
 
5
5
  require_relative 'fig/module_fig_base'
6
- require_relative 'fig/module_fig_plus'
7
6
 
8
7
  class Fig_A < Mustache
9
8
 
10
- include Fig_00, Fig_01
9
+ include Fig_00
11
10
 
12
11
  # <<Fig_A>>
13
12
  # src: 画像ファイル名
@@ -18,9 +17,9 @@ class Fig_A < Mustache
18
17
  @template = <<EOT
19
18
  <figure>
20
19
  {{#imgs_list}}
21
- <a href="{{fig_src}}" target="_blank"><img src="{{fig_src}}" alt="{{alt}}" {{& img_style}}/></a>
20
+ <a href="{{fig_src}}" target="_blank"><img src="{{fig_src}}" loading="lazy" alt="{{alt}}"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} /></a>
22
21
  {{/imgs_list}}
23
- <figcaption markdown="span">{{#figcaption_sw}}{{& caption}}<br/>{{/figcaption_sw}}[画像クリックで拡大表示]</figcaption>
22
+ <figcaption markdown="span">{{#caption}}{{& caption}}<br/>{{/caption}}[画像クリックで拡大表示]</figcaption>
24
23
  </figure>
25
24
  EOT
26
25
 
@@ -3,11 +3,10 @@
3
3
  require 'mustache'
4
4
 
5
5
  require_relative 'fig/module_fig_base'
6
- require_relative 'fig/module_fig_plus'
7
6
 
8
7
  class Fig_H < Mustache
9
8
 
10
- include Fig_00, Fig_01
9
+ include Fig_00
11
10
 
12
11
  # <<Fig_H>>
13
12
  # src: 画像ファイル名
@@ -19,9 +18,9 @@ class Fig_H < Mustache
19
18
  @template = <<EOT
20
19
  <figure>
21
20
  {{#imgs_list}}
22
- {{#href}}<a href="{{href}}" target="_blank">{{/href}}<img src="{{fig_src}}" alt="{{alt}}" {{& img_style}}/>{{#href}}</a>{{/href}}
21
+ <a href="{{href}}" target="_blank"><img src="{{fig_src}}" loading="lazy" alt="{{alt}}"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} /></a>
23
22
  {{/imgs_list}}
24
- {{#figcaption_sw}}<figcaption markdown="span">{{& caption}}</figcaption>{{/figcaption_sw}}
23
+ {{#caption}}<figcaption markdown="span">{{& caption}}</figcaption>{{/caption}}
25
24
  </figure>
26
25
  EOT
27
26
 
@@ -3,11 +3,10 @@
3
3
  require 'mustache'
4
4
 
5
5
  require_relative 'fig/module_fig_base'
6
- require_relative 'fig/module_fig_plus'
7
6
 
8
7
  class Fig_N < Mustache
9
8
 
10
- include Fig_00, Fig_01
9
+ include Fig_00
11
10
 
12
11
  # <<Fig_N>>
13
12
  # src: 画像ファイル名
@@ -19,9 +18,9 @@ class Fig_N < Mustache
19
18
  @template = <<EOT
20
19
  <figure>
21
20
  {{#imgs_list}}
22
- <img src="{{fig_src}}" alt="{{alt}}" {{& img_style}}/>
21
+ <img src="{{fig_src}}" loading="lazy" alt="{{alt}}"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} />
23
22
  {{/imgs_list}}
24
- {{#figcaption_sw}}<figcaption markdown="span">{{caption}}{{& cited_from}}</figcaption>{{/figcaption_sw}}
23
+ {{#caption}}<figcaption markdown="span">{{caption}}</figcaption>{{/caption}}
25
24
  </figure>
26
25
  EOT
27
26
 
@@ -20,7 +20,7 @@ class Fig_P < Mustache
20
20
  @template = <<EOT
21
21
  <figure>
22
22
  {{#imgs_list}}
23
- <img src="{{fig_src}}" alt="{{name}}氏" {{& img_style}} />
23
+ <img src="{{fig_src}}" loading="lazy" alt="{{name}}氏"{{#width}} width="{{width}}"{{/width}}{{#height}} height="{{height}}"{{/height}} />
24
24
  {{/imgs_list}}
25
25
  <div style="text-align:left; padding:0px 35px;">
26
26
  <figcaption><strong>{{name}}({{huri}})氏</strong></figcaption>
@@ -3,11 +3,10 @@
3
3
  require 'mustache'
4
4
 
5
5
  require_relative 'fig/module_fig_base'
6
- require_relative 'fig/module_fig_plus'
7
6
 
8
7
  class Fig_Z < Mustache
9
8
 
10
- include Fig_00, Fig_01
9
+ include Fig_00
11
10
 
12
11
  # <<Fig_Z>>
13
12
  # src: 画像ファイル名
@@ -18,9 +17,9 @@ class Fig_Z < Mustache
18
17
  @template = <<EOT
19
18
  <figure>
20
19
  {{#imgs_list}}
21
- <a href="{{fig_src}}" rel="lightbox" target="_blank"><img src="{{fig_src}}" alt="{{alt}}" {{& img_style}}/></a>
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>
22
21
  {{/imgs_list}}
23
- <figcaption markdown="span">{{#figcaption_sw}}{{& caption}}<br/>{{/figcaption_sw}}[画像クリックで拡大表示]</figcaption>
22
+ <figcaption markdown="span">{{#caption}}{{& caption}}<br/>{{/caption}}[画像クリックで拡大表示]</figcaption>
24
23
  </figure>
25
24
  EOT
26
25
 
@@ -1,3 +1,3 @@
1
1
  module ZineBrewer
2
- VERSION = "1.6.0"
2
+ VERSION = "1.9.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.6.0
4
+ version: 1.9.0
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-03-14 00:00:00.000000000 Z
11
+ date: 2021-09-18 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
@@ -63,7 +64,6 @@ files:
63
64
  - lib/zine_brewer/templates/bookranking.rb
64
65
  - lib/zine_brewer/templates/casts.rb
65
66
  - lib/zine_brewer/templates/fig/module_fig_base.rb
66
- - lib/zine_brewer/templates/fig/module_fig_plus.rb
67
67
  - lib/zine_brewer/templates/fig_a.rb
68
68
  - lib/zine_brewer/templates/fig_h.rb
69
69
  - lib/zine_brewer/templates/fig_n.rb
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
- rubygems_version: 3.2.14
96
+ rubygems_version: 3.1.6
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Kramdown to HTML converter for Shoeisha Web Media
@@ -1,15 +0,0 @@
1
- # coding: utf-8
2
-
3
- module Fig_01
4
-
5
- def open_which
6
- defined?(href)
7
- end
8
-
9
- def figcaption_sw
10
- defined?(cap)
11
- end
12
-
13
- end
14
-
15
-