metanorma-utils 1.8.2 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utils/hash_transform_keys.rb +1 -2
- data/lib/utils/main.rb +17 -10
- data/lib/utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acea881df59c64c2137792a3fc9bbb5a36d09dd43fc5fa6d0e3b066b3bbb60da
|
4
|
+
data.tar.gz: 00fc04e75a5eec309ed1a1d62633e7c9358e93adbf0558f12bad11fa069d4441
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ba485eb93b52444caa930e05dc185f8506fc1d68c70483f43593e560e63ab418aeea60375e579363b120a7864046daefe4cd6ded9769491990748a88570cf83
|
7
|
+
data.tar.gz: c16aecbe71a3acdede53591130d310f9745fc3b8d59a7624250d36ab93468a0f16ecc05b6251c10d6dac34bab792fd15fb0344a2cd30e606f4166b4d5ed045af
|
data/lib/utils/main.rb
CHANGED
@@ -4,6 +4,7 @@ require "sterile"
|
|
4
4
|
require "htmlentities"
|
5
5
|
require "nokogiri"
|
6
6
|
require "csv"
|
7
|
+
require_relative "../sterile/sterile"
|
7
8
|
|
8
9
|
module Metanorma
|
9
10
|
module Utils
|
@@ -34,21 +35,26 @@ module Metanorma
|
|
34
35
|
docfile.nil? ? "./" : "#{Pathname.new(docfile).parent}/"
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
+
CJK = "\\p{Han}|\\p{Bopomofo}|\\p{Hangul}|\\p{Hiragana}|\\p{Katakana}"
|
39
|
+
.freeze
|
40
|
+
|
41
|
+
# TODO needs internationalisation of quote
|
38
42
|
def smartformat(text)
|
39
|
-
HTMLEntities.new.
|
40
|
-
|
41
|
-
|
42
|
-
.gsub("--", "—"),
|
43
|
-
)
|
44
|
-
.smart_format, :basic
|
43
|
+
ret = HTMLEntities.new.decode(
|
44
|
+
text.gsub(/ --? /, " — ")
|
45
|
+
.gsub("--", "—"),
|
45
46
|
)
|
47
|
+
ret = ret.gsub(%r{(#{CJK})(["'])}o, "\\1\u200a\\2")
|
48
|
+
.gsub(%r{(["'])(#{CJK})}o, "\\1\u200a\\2")
|
49
|
+
ret = ret.smart_format
|
50
|
+
ret = ret.gsub(%r{(#{CJK})\u200a}o, "\\1")
|
51
|
+
.gsub(%r{\u200a(#{CJK})}o, "\\1")
|
52
|
+
HTMLEntities.new.encode(ret, :basic)
|
46
53
|
end
|
47
54
|
|
48
55
|
def endash_date(elem)
|
49
56
|
elem.traverse do |n|
|
50
|
-
|
51
|
-
|
57
|
+
n.text? or next
|
52
58
|
n.replace(n.text.gsub(/\s+--?\s+/, "–").gsub("--", "–"))
|
53
59
|
end
|
54
60
|
end
|
@@ -133,7 +139,8 @@ module Metanorma
|
|
133
139
|
# if punct fails, try break on camel case, with soft hyphen
|
134
140
|
# break regardless every LONGSTRING_THRESHOLD * LONGSTR_NOPUNCT,
|
135
141
|
# with soft hyphen
|
136
|
-
def break_up_long_str(text, threshold = LONGSTR_THRESHOLD,
|
142
|
+
def break_up_long_str(text, threshold = LONGSTR_THRESHOLD,
|
143
|
+
nopunct = LONGSTR_NOPUNCT)
|
137
144
|
/^\s*$/.match?(text) and return text
|
138
145
|
text.split(/(?=(?:\s|-))/).map do |w|
|
139
146
|
if /^\s*$/.match(text) || (w.size < threshold) then w
|
data/lib/utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|