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 +4 -4
- data/.gitignore +1 -0
- data/lib/asciidoctor/pdf/linewrap/ja.rb +5 -0
- data/lib/asciidoctor/pdf/linewrap/ja/converter.rb +27 -7
- data/lib/asciidoctor/pdf/linewrap/ja/version.rb +1 -1
- metadata +2 -3
- data/Gemfile.lock +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a7dfa5b6776ad065bbafbd6d8fee5646a6d3253
|
4
|
+
data.tar.gz: e41ffa2997d3a2b28e2822e14f9d699c2981bce0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5454dd3f9000df206d2514860db3bb5008c12ea60281a140d1ad9bf5514dc4b1739de4c0428ad4760b4e646f92ebdc2d5470cb76205668b840207bb797eb725f
|
7
|
+
data.tar.gz: 80c7fc637804599b7555e9b4af486488994b9364faa7e74837d6d8600e377f0bc4e5fe4227ea59d34c912e30a511c7c35f22a22eac98ab582e8410216bf8fc21
|
data/.gitignore
CHANGED
@@ -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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
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
|
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.
|
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-
|
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
|