wtex 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -240,6 +240,7 @@ _eos
240
240
  body = convert_ruby body
241
241
  body = convert_strong body
242
242
  body = convert_underline body
243
+ body = convert_combined body
243
244
  body = escape_specials body
244
245
  end
245
246
 
@@ -267,6 +268,11 @@ _eos
267
268
  body
268
269
  end
269
270
 
271
+ def convert_combined(body)
272
+ body.gsub!(/[!!\??]{2,}/u) { '\\WTcombined{' + $&.gsub(/!/, '!').gsub(/?/, '?') + '}' }
273
+ body
274
+ end
275
+
270
276
  def escape_specials(body)
271
277
  body.gsub!(/[#{Characters::SPECIAL}]/) { Characters::SPECIAL_MAP[$&] }
272
278
  body
@@ -14,14 +14,13 @@
14
14
  \vfuzz 10pt
15
15
 
16
16
  %%% custom commands
17
- \newcommand{\WTunderline}[1]
18
- {
19
- \underline{#1}
20
- }
17
+ \newcommand{\WTunderline}[1] {\underline{#1}}
18
+
19
+ \newcommand{\WTcombined}[1] {#1}
21
20
 
22
21
  \newcommand{\WTseparator}[0]
23
22
  {
24
- \begin{center}\subsection*{◆◇◆}\end{center}
23
+ \subsection*{\centering{◆◇◆}}
25
24
  }
26
25
 
27
26
  %%% custom environments
@@ -18,14 +18,13 @@
18
18
  \vfuzz 10pt
19
19
 
20
20
  %%% custom commands
21
- \newcommand{\WTunderline}[1]
22
- {
23
- \bou{#1}
24
- }
21
+ \newcommand{\WTunderline}[1] {\bou{#1}}
22
+
23
+ \newcommand{\WTcombined}[1] {\rensuji{#1}}
25
24
 
26
25
  \newcommand{\WTseparator}[0]
27
26
  {
28
- \begin{center}\subsection*{◆◇◆}\end{center}
27
+ \subsection*{\centering{◆◇◆}}
29
28
  }
30
29
 
31
30
  %%% custom environments
@@ -146,4 +146,68 @@ class TC_WTeX_Inline < Test::Unit::TestCase
146
146
  )
147
147
  end
148
148
 
149
+ def test_tex_combined_basic
150
+ assert_equal(
151
+ "foo\\WTcombined{!!}\n",
152
+ @wt.tex('foo!!'),
153
+ "WTeX#tex should combine multiple '!' characters"
154
+ )
155
+ assert_equal(
156
+ "foo\\WTcombined{!!}\n",
157
+ @wt.tex('foo!!'),
158
+ "WTeX#tex should combine multiple '!' characters"
159
+ )
160
+
161
+ assert_equal(
162
+ "foo\\WTcombined{?!}\n",
163
+ @wt.tex('foo?!'),
164
+ "WTeX#tex should combine '?' and '!'"
165
+ )
166
+ assert_equal(
167
+ "foo\\WTcombined{?!}\n",
168
+ @wt.tex('foo?!'),
169
+ "WTeX#tex should combine '?' and '!'"
170
+ )
171
+
172
+ assert_equal(
173
+ "foo\\WTcombined{?!}bar\\WTcombined{!!}\n",
174
+ @wt.tex('foo?!bar!!'),
175
+ "WTeX#tex should combine '?' and '!'"
176
+ )
177
+ end
178
+
179
+ def test_tex_combined_irregular
180
+ assert_equal(
181
+ "foo!\n",
182
+ @wt.tex('foo!'),
183
+ "WTeX#tex should leave single '!' character"
184
+ )
185
+ assert_equal(
186
+ "foo!\n",
187
+ @wt.tex('foo!'),
188
+ "WTeX#tex should leave single '!' character"
189
+ )
190
+ assert_equal(
191
+ "foo?\n",
192
+ @wt.tex('foo?'),
193
+ "WTeX#tex should leave single '?' character"
194
+ )
195
+ assert_equal(
196
+ "foo?\n",
197
+ @wt.tex('foo?'),
198
+ "WTeX#tex should leave single '?' character"
199
+ )
200
+
201
+ assert_equal(
202
+ "foo\\WTcombined{!!!}\n",
203
+ @wt.tex('foo!!!'),
204
+ 'WTeX#tex should deal with more than two characters'
205
+ )
206
+ assert_equal(
207
+ "foo\\WTcombined{?!!}\n",
208
+ @wt.tex('foo?!!'),
209
+ 'WTeX#tex should deal with more than two characters'
210
+ )
211
+ end
212
+
149
213
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Akira FUNAI
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-21 00:00:00 +09:00
17
+ date: 2011-03-26 00:00:00 +09:00
18
18
  default_executable: wikitex
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency