asciidoctor-pdf-linewrap-ja 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abd9b1d6da8f68c6e1288ca2cf665f9c61c28cd4
|
4
|
+
data.tar.gz: f8eeedd8f06d68df4454264a9e3f2726056fd1a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ef07aaf492f6ce52e2fee4629d60ac6ef23da2c759c3ba1144a57d606fa7f50435e34b835db99be743cf44cb7830fe6af02f866dfb13112ec34a2a11c2e053
|
7
|
+
data.tar.gz: bf159d331dac2a3ece7d0299d3418b556cc7fd8c5a4117a5eea85260a52cd9ba4afa39c53a89861d57ea68023a2ea8165fd702632d7c34a5d1c04ad548896210
|
@@ -9,6 +9,31 @@ Extensions.register do
|
|
9
9
|
treeprocessor do
|
10
10
|
|
11
11
|
process do |document|
|
12
|
+
|
13
|
+
tables = document.find_by context: :table
|
14
|
+
tables.each do |table|
|
15
|
+
table.rows.head.each do |head|
|
16
|
+
head.each do |cell|
|
17
|
+
raw_text = get_raw_text(cell)
|
18
|
+
cell.text = Asciidoctor::Pdf::Linewrap::Ja::Converter::insert_zero_width_space(raw_text)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
table.rows.body.each do |body|
|
23
|
+
body.each do |cell|
|
24
|
+
raw_text = get_raw_text(cell)
|
25
|
+
cell.text = Asciidoctor::Pdf::Linewrap::Ja::Converter::insert_zero_width_space(raw_text)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
table.rows.foot.each do |foot|
|
30
|
+
foot.each do |cell|
|
31
|
+
raw_text = get_raw_text(cell)
|
32
|
+
cell.text = Asciidoctor::Pdf::Linewrap::Ja::Converter::insert_zero_width_space(raw_text)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
12
37
|
paragraphs = document.find_by context: :paragraph
|
13
38
|
paragraphs.each do |paragraph|
|
14
39
|
paragraph.lines.each_with_index do |line, i|
|
@@ -18,7 +43,16 @@ Extensions.register do
|
|
18
43
|
|
19
44
|
list_items = document.find_by context: :list_item
|
20
45
|
list_items.each do |list_item|
|
21
|
-
|
46
|
+
raw_text = get_raw_text(list_item)
|
47
|
+
list_item.text = Asciidoctor::Pdf::Linewrap::Ja::Converter::insert_zero_width_space(raw_text)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_raw_text(item)
|
52
|
+
if item.instance_variable_defined?('@text')
|
53
|
+
return item.instance_variable_get('@text')
|
54
|
+
else
|
55
|
+
return item.text
|
22
56
|
end
|
23
57
|
end
|
24
58
|
end
|
@@ -44,7 +44,7 @@ module Asciidoctor
|
|
44
44
|
new_line << ZERO_WIDTH_SPACE if insert_zero_width_space?(ch, line[idx + 1])
|
45
45
|
end
|
46
46
|
|
47
|
-
return new_line
|
47
|
+
return remove_zero_width_space(new_line)
|
48
48
|
end
|
49
49
|
|
50
50
|
def self.insert_zero_width_space?(ch, next_ch)
|
@@ -58,6 +58,12 @@ module Asciidoctor
|
|
58
58
|
return false
|
59
59
|
end
|
60
60
|
|
61
|
+
def self.remove_zero_width_space(line)
|
62
|
+
line.gsub(/http.*?[\]\s]/) do |href|
|
63
|
+
href.gsub(/#{ZERO_WIDTH_SPACE}/, "")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
61
67
|
def self.japanese_char?(ch)
|
62
68
|
(/[\p{Han}\p{Hiragana}\p{Katakana}ー]/ === ch) \
|
63
69
|
|| PROHIBIT_LINE_BREAK_BEFORE.include?(ch) \
|
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.4.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-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor-pdf
|