orthotypo 0.6.0 → 1.0.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
  SHA256:
3
- metadata.gz: b41b05766be4f11e6494a7e89823a6ab730910aec4a679d22b764ae96fb05f10
4
- data.tar.gz: 0c2a072f5c3ebd8583b70c7ee4bf0eafe064c827d4e0af250728bcf5762dc5ae
3
+ metadata.gz: fd24cbdb2c5adaa4f6ecf91acf144025549b7599aeb0f944e3f1987331448450
4
+ data.tar.gz: 6d9a7bb478c4cc0b76722128a1065fc99666f7d1f284cc82cb6f26acfe89bf70
5
5
  SHA512:
6
- metadata.gz: 20ff73ede6bf05d4b2b8842604b09267f36cf2d44fc17c6e4a467e9e703934a20f18616368cc5af88529122166130c8b868612af6caab95ff6f685236b862443
7
- data.tar.gz: 55f9a2023f185176d52de197847f92ee61ea0e8ba20d70c920fec7e31b4d86dbae0ab87594adcd7c406fcdbbc2ef189fa8a113bcfeab9f60786c31dd77771f1e
6
+ metadata.gz: e51b243378c8d97df6fd3bfa7f59a7aeb7f516d3f54d82cce4eb0ae8d3c7b6a5893211c857c72f8c249a73e0333f3d187ddf4d6145a45ab6de5039633aeaf457
7
+ data.tar.gz: dc77c1043a6210122c48a8d5849d63df04247d3d957707469d9e3029ed0cf1a9bec745cd12115bb4563254abc6e227c74e13f02285fc0cada9a0d75ab0be2ad6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orthotypo (0.6.0)
4
+ orthotypo (1.0.0)
5
5
  htmlentities
6
6
  nokogiri
7
7
 
data/README.md CHANGED
@@ -28,10 +28,10 @@ Ajout d'espace fine insécable avant les signes doubles en français.
28
28
  ## Roadmap
29
29
 
30
30
  ### v1
31
- 1. S'adapter aux locales (détecter I18n)
32
- 2. Ne pas endommager l'HTML et les HTML entities ( )
31
+ Ne pas endommager l'HTML et les HTML entities ( )
33
32
 
34
33
  ### v2
34
+ S'adapter aux locales (détecter I18n)
35
35
  Permettre les configs
36
36
 
37
37
  ## Sources
@@ -19,6 +19,12 @@ module Orthotypo
19
19
  []
20
20
  end
21
21
 
22
+ def chars_with_space_before_after_digit
23
+ [
24
+ '%'
25
+ ]
26
+ end
27
+
22
28
  def chars_with_space_after
23
29
  [
24
30
  ',',
@@ -42,6 +48,22 @@ module Orthotypo
42
48
  []
43
49
  end
44
50
 
51
+ def chars_with_no_space_around_between_digits
52
+ [
53
+ '/',
54
+ ':'
55
+ ]
56
+ end
57
+
58
+ def chars_in_numbers
59
+ [
60
+ '.',
61
+ ',',
62
+ '/',
63
+ ':'
64
+ ]
65
+ end
66
+
45
67
  def is_html?
46
68
  # TODO contains tags?
47
69
  @html || contains_html_entities?
@@ -67,6 +89,7 @@ module Orthotypo
67
89
  preserve_precious_things
68
90
  # Chars
69
91
  parse_chars_with_space_before
92
+ parse_chars_with_space_before_after_digit
70
93
  parse_chars_with_space_after
71
94
  parse_chars_with_space_around
72
95
  parse_chars_with_no_space_around
@@ -74,7 +97,7 @@ module Orthotypo
74
97
  parse_pairs_with_space_around
75
98
  parse_pairs_with_no_space_around
76
99
  # Numbers
77
- parse_numbers
100
+ parse_chars_in_numbers
78
101
  #
79
102
  clean_ortho
80
103
  restore_precious_things
@@ -106,9 +129,15 @@ module Orthotypo
106
129
  def parse_chars_with_space_before
107
130
  chars_with_space_before.each do |char|
108
131
  # Espace normal avant -> espace fine insécable avant
109
- fix(SPACE + '%', NNBSP + '%')
132
+ fix(SPACE + char, NNBSP + char)
110
133
  # Pas d'espace avant -> espace fine insécable avant
111
- fix(/([[:alnum:]])%/, "\\1" + NNBSP + '%')
134
+ fix(/([[:alpha:]])[#{char}]/, "\\1" + NNBSP + char)
135
+ end
136
+ end
137
+
138
+ def parse_chars_with_space_before_after_digit
139
+ chars_with_space_before_after_digit.each do |char|
140
+ fix(/([[:digit:]])[#{char}]/, "\\1" + NNBSP + char)
112
141
  end
113
142
  end
114
143
 
@@ -117,7 +146,7 @@ module Orthotypo
117
146
  # Espace avant -> pas d'espace avant
118
147
  fix(SPACE + char, char)
119
148
  # Pas d'espace après -> espace après
120
- fix(/[#{char}]([[:alnum:]])/, char + SPACE + "\\1")
149
+ fix(/[#{char}]([[:alpha:]])/, char + SPACE + "\\1")
121
150
  end
122
151
  end
123
152
 
@@ -126,7 +155,7 @@ module Orthotypo
126
155
  # Espace normal avant -> espace fine insécable avant
127
156
  fix(SPACE + char, NNBSP + char)
128
157
  # Pas d'espace avant -> espace fine insécable avant
129
- fix(/([[:alnum:]])[#{char}]/, "\\1" + NNBSP + char)
158
+ fix(/([[:alpha:]])[#{char}]/, "\\1" + NNBSP + char)
130
159
  end
131
160
  end
132
161
 
@@ -162,8 +191,10 @@ module Orthotypo
162
191
  end
163
192
  end
164
193
 
165
- def parse_numbers
166
- ['.', ','].each do |char|
194
+ def parse_chars_in_numbers
195
+ chars_in_numbers.each do |char|
196
+ fix(/([[:digit:]])[[:space:]][#{char}]([[:digit:]])/, "\\1" + char + "\\2")
197
+ fix(/([[:digit:]])[[:space:]][#{char}][[:space:]]([[:digit:]])/, "\\1" + char + "\\2")
167
198
  fix(/([[:digit:]])[#{char}][[:space:]]([[:digit:]])/, "\\1" + char + "\\2")
168
199
  end
169
200
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orthotypo
4
- VERSION = "0.6.0"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -5,7 +5,8 @@ describe Orthotypo::Composer::Fr do
5
5
  it 'adds spaces before double punctuation marks' do
6
6
  expect("mot: suite".ortho).to(eq("mot : suite"))
7
7
  expect("é: suite".ortho).to(eq("é : suite"))
8
- expect("1: suite".ortho).to(eq("1 : suite"))
8
+ # Pas automatisable, parce que 11:20
9
+ # expect("1: suite".ortho).to(eq("1 : suite"))
9
10
  expect("mot; suite".ortho).to(eq("mot ; suite"))
10
11
  expect("mot!".ortho).to(eq("mot !"))
11
12
  expect("mot !".ortho).to(eq("mot !"))
@@ -44,6 +45,14 @@ describe Orthotypo::Composer::Fr do
44
45
  expect("10 %".ortho).to(eq("10 %"))
45
46
  end
46
47
 
48
+ it 'fixes dates/time' do
49
+ expect("10/01/2023 16:00".ortho).to(eq("10/01/2023 16:00"))
50
+ expect("10/01/2023 16:00:00".ortho).to(eq("10/01/2023 16:00:00"))
51
+ expect("10 / 01 / 2023 16:00".ortho).to(eq("10/01/2023 16:00"))
52
+ expect("10 / 01 / 2023 16 : 00".ortho).to(eq("10/01/2023 16:00"))
53
+ expect("10 octobre 2023 16:00".ortho).to(eq("10 octobre 2023 16:00"))
54
+ end
55
+
47
56
  # https://www.scribbr.fr/elements-linguistiques/les-espaces/
48
57
  it 'tests de Justine Debret' do
49
58
  expect("Elle a vu son cousin,sa tante et son oncle.Ils allaient tous très bien.".ortho).to(eq("Elle a vu son cousin, sa tante et son oncle. Ils allaient tous très bien."))
@@ -53,6 +62,7 @@ describe Orthotypo::Composer::Fr do
53
62
  expect("Il a dit : «J’arrive ce matin ( ou plus tard ) à Paris [ rue de la République ] pour son anniversaire.»".ortho).to(eq("Il a dit : « J’arrive ce matin (ou plus tard) à Paris [rue de la République] pour son anniversaire. »"))
54
63
  # Le test suivant n'est pas automatisable, parce qu'on ne peut distinguer un Paris-Brest (le gâteau) d'un Paris - Brest (le trajet)
55
64
  # expect("Nous l’avons rencontré à Saint - Martin.".ortho).to(eq("Nous l’avons rencontré à Saint-Martin."))
65
+ expect("Il roule pendant 31, 5 km.".ortho).to(eq("Il roule pendant 31,5 km."))
56
66
  # Le test suivant est-il automatisable ?
57
67
  # expect("Il roule pendant 31, 5km.".ortho).to(eq("Il roule pendant 31,5 km."))
58
68
  # Pas automatisable, rien ne permet de distinguer s'il s'agit d'un rang ou d'un nombre
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orthotypo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2023-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities