asciidoctor-pdf-linewrap-ja 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: eff9aad0fb004903c2916a361ef78281e39523e5
4
- data.tar.gz: f276dc36475b598b5676fc6ca825a134416ec59d
3
+ metadata.gz: 5a7dfa5b6776ad065bbafbd6d8fee5646a6d3253
4
+ data.tar.gz: e41ffa2997d3a2b28e2822e14f9d699c2981bce0
5
5
  SHA512:
6
- metadata.gz: e2a450f97d4281a2cb7b53bc509cd29885f963fa282122815af75af9ac7d09ee3b5d4b6d8731d70c4a5c3d998bf56d8f790a8b79619457d584f7422ce74e5f35
7
- data.tar.gz: '0393658a00ef8eb98e3473427e426c6b93c7b62354806021ece9251e0ee8d485a0fc8e05650214f9c5fd2b8d2d6605907338369259a2e56c0e5e427d3d58a0a6'
6
+ metadata.gz: 5454dd3f9000df206d2514860db3bb5008c12ea60281a140d1ad9bf5514dc4b1739de4c0428ad4760b4e646f92ebdc2d5470cb76205668b840207bb797eb725f
7
+ data.tar.gz: 80c7fc637804599b7555e9b4af486488994b9364faa7e74837d6d8600e377f0bc4e5fe4227ea59d34c912e30a511c7c35f22a22eac98ab582e8410216bf8fc21
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
@@ -15,6 +15,11 @@ Extensions.register do
15
15
  paragraph.lines[i] = Asciidoctor::Pdf::Linewrap::Ja::Converter::insert_zero_width_space(line)
16
16
  end
17
17
  end
18
+
19
+ list_items = document.find_by context: :list_item
20
+ list_items.each do |list_item|
21
+ list_item.text = Asciidoctor::Pdf::Linewrap::Ja::Converter::insert_zero_width_space(list_item.text)
22
+ end
18
23
  end
19
24
  end
20
25
  end
@@ -38,17 +38,37 @@ module Asciidoctor
38
38
  end
39
39
 
40
40
  def self.insert_zero_width_space?(ch, next_ch)
41
- japanese_char?(ch) \
42
- && !PROHIBIT_LINE_BREAK_AFTER.include?(ch) \
43
- && next_ch != nil && !PROHIBIT_LINE_BREAK_BEFORE.include?(next_ch) \
44
- && !(PROHIBIT_DIVIDE.include?(ch) && PROHIBIT_DIVIDE.include?(next_ch))
41
+
42
+ if japanese_char?(ch)
43
+ return !prohibit_line_break?(ch, next_ch)
44
+ elsif next_ch != nil && japanese_char?(next_ch)
45
+ return !prohibit_line_break_before?(next_ch)
46
+ end
47
+
48
+ return false
45
49
  end
46
50
 
47
51
  def self.japanese_char?(ch)
48
52
  (/[\p{Han}\p{Hiragana}\p{Katakana}ー]/ === ch) \
49
- || PROHIBIT_LINE_BREAK_BEFORE.include?(ch) \
50
- || PROHIBIT_LINE_BREAK_AFTER.include?(ch) \
51
- || PROHIBIT_DIVIDE.include?(ch)
53
+ || PROHIBIT_LINE_BREAK_BEFORE.include?(ch) \
54
+ || PROHIBIT_LINE_BREAK_AFTER.include?(ch) \
55
+ || PROHIBIT_DIVIDE.include?(ch)
56
+ end
57
+
58
+ def self.prohibit_line_break?(ch, next_ch)
59
+ prohibit_line_break_after?(ch) || prohibit_line_break_before?(next_ch) || prohibit_divide?(ch, next_ch)
60
+ end
61
+
62
+ def self.prohibit_line_break_after?(ch)
63
+ PROHIBIT_LINE_BREAK_AFTER.include?(ch)
64
+ end
65
+
66
+ def self.prohibit_line_break_before?(ch)
67
+ ch == nil || PROHIBIT_LINE_BREAK_BEFORE.include?(ch)
68
+ end
69
+
70
+ def self.prohibit_divide?(ch, next_ch)
71
+ next_ch == nil || (PROHIBIT_DIVIDE.include?(ch) && PROHIBIT_DIVIDE.include?(next_ch))
52
72
  end
53
73
  end
54
74
  end
@@ -2,7 +2,7 @@ module Asciidoctor
2
2
  module Pdf
3
3
  module Linewrap
4
4
  module Ja
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-pdf-linewrap-ja
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - y.fukazawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-21 00:00:00.000000000 Z
11
+ date: 2018-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor-pdf
@@ -76,7 +76,6 @@ files:
76
76
  - ".gitignore"
77
77
  - ".travis.yml"
78
78
  - Gemfile
79
- - Gemfile.lock
80
79
  - LICENSE.txt
81
80
  - README.md
82
81
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,22 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- asciidoctor-pdf-linewrap-ja (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- minitest (5.11.3)
10
- rake (10.4.2)
11
-
12
- PLATFORMS
13
- ruby
14
-
15
- DEPENDENCIES
16
- asciidoctor-pdf-linewrap-ja!
17
- bundler (~> 1.16)
18
- minitest (~> 5.0)
19
- rake (~> 10.0)
20
-
21
- BUNDLED WITH
22
- 1.16.1