isodoc 2.5.6 → 2.5.7

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: 7c7354811120c945f0a478b34503c89e841a49a8cffc6655e0be43f5b565ad35
4
- data.tar.gz: 0f9dae634d16cbf5521eb048cbf4ff6de3d2e9d48d2284322183f598df7fc19b
3
+ metadata.gz: 89b2a927f8f452dd13667b90a02e9871472784e620c85978a83d6fd52015902b
4
+ data.tar.gz: f76d973900f03358f4411a8b479db06544e3d7ecc52971cd0c5afe60334046bd
5
5
  SHA512:
6
- metadata.gz: 98e9b5625dfe9ab222ba00b03b02216e9f3ee00affa6e655c58be6acbeedb8bb05663b7d6832fbc94a76a8da02bc732a9f1b2c309532e968089990b1f50fe6ba
7
- data.tar.gz: 756d64e9edbf24c6ba0ae909421e0a7c0a7f916fff8b5f6622d5792c9952728f05c8d2854888a559d3c6b36aa4a54d394ce7cfeded705fc168c0293240ea04b9
6
+ metadata.gz: aecc80230f4d1cde0232702931d07290c340f98c3a5e93a81603fed8c7775a1fca6dbf29cf09aa8141aece7fa3befb6d583c70690cf2cda02fcf50ce5bf75848
7
+ data.tar.gz: fc2d6d6fa85a1dc0edf1735068b940084b21fe20442158bc18307e9ae77581875dbf2b66be5cc4847bd2eb1096063b959c9df9695d356963e879c9c83e6a9e3b
@@ -30,33 +30,38 @@ module IsoDoc
30
30
 
31
31
  docxml.xpath("//td | //th").each do |d|
32
32
  d.traverse do |n|
33
- next unless n.text?
34
-
35
- n.replace(HTMLEntities.new.encode(
36
- break_up_long_strings(n.text),
37
- ))
33
+ n.text? or next
34
+ ret = break_up_long_str(n.text)
35
+ n.content = ret
38
36
  end
39
37
  end
40
38
  end
41
39
 
42
- def break_up_long_strings(text)
43
- return text if /^\s*$/.match?(text)
40
+ LONGSTR_THRESHOLD = 10
41
+ LONGSTR_NOPUNCT = 2
44
42
 
43
+ def break_up_long_str(text)
44
+ /^\s*$/.match?(text) and return text
45
45
  text.split(/(?=\s)/).map do |w|
46
- if /^\s*$/.match(text) || (w.size < 30) then w
46
+ if /^\s*$/.match(text) || (w.size < LONGSTR_THRESHOLD) then w
47
47
  else
48
- w.scan(/.{,30}/).map do |w1|
49
- w1.size < 30 ? w1 : break_up_long_strings1(w1)
48
+ w.scan(/.{,#{LONGSTR_THRESHOLD}}/o).map.with_index do |w1, i|
49
+ w1.size < LONGSTR_THRESHOLD ? w1 : break_up_long_str1(w1, i + 1)
50
50
  end.join
51
51
  end
52
52
  end.join
53
53
  end
54
54
 
55
- def break_up_long_strings1(text)
56
- s = text.split(%r{(?<=[,.?+;/=])})
57
- if s.size == 1 then "#{text} "
55
+ # break on punct every LONGSTRING_THRESHOLD chars
56
+ # break regardless every LONGSTRING_THRESHOLD * LONGSTR_NOPUNCT
57
+ def break_up_long_str1(text, iteration)
58
+ s = text.split(%r{(?<=[,.?+;/=(\[])})
59
+ if s.size == 1
60
+ (iteration % LONGSTR_NOPUNCT).zero? and
61
+ text += "\u200b"
62
+ text
58
63
  else
59
- s[-1] = " #{s[-1]}"
64
+ s[-1] = "\u200b#{s[-1]}"
60
65
  s.join
61
66
  end
62
67
  end
@@ -102,8 +102,6 @@ module IsoDoc
102
102
  end
103
103
  end
104
104
 
105
- def table_long_strings_cleanup(docxml); end
106
-
107
105
  def table_attrs(node)
108
106
  ret = super
109
107
  node.at(ns("./colgroup")) and ret[:style] += "table-layout:fixed;"
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.5.6".freeze
2
+ VERSION = "2.5.7".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.6
4
+ version: 2.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-05 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html2doc