wtex 0.1.0 → 0.1.1
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.
- data/README.ja.pdf +0 -0
- data/README.ja.txt +57 -54
- data/lib/wtex.rb +10 -6
- data/t/test_wtex.rb +180 -0
- metadata +3 -3
data/README.ja.pdf
CHANGED
|
Binary file
|
data/README.ja.txt
CHANGED
|
@@ -119,83 +119,64 @@ body.txtに、Wiki/TeXマークアップでソースを記述します。head.te
|
|
|
119
119
|
行の先頭に「]」記号、または「|」記号を置くと、その行は枠付きボックスとして表示されます。行の直前に「foo.rb:」のようにコロン「:」で終わる行を書くと、ボックスのタイトルとして扱われます。「]」で始まるブロックの内部では、WikiマークアップおよびTeXマークアップが利用可能です。「|」で始まるブロックの内部では、WikiマークアップもTeXマークアップも使用できず、ソースの文字がすべてそのまま表示されます。
|
|
120
120
|
|
|
121
121
|
ソース:
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
122
|
+
|foo_bar.tex:
|
|
123
|
+
|] foo,bar,
|
|
124
|
+
|] {\large\bf bar},**baz**
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
foo,bar
|
|
129
|
-
{\large\bf bar}
|
|
130
|
-
\end{WTbox}
|
|
131
|
-
\end{WTbox}
|
|
126
|
+
出力(マークアップが評価される):
|
|
127
|
+
]foo_bar.tex:
|
|
128
|
+
]] foo,bar,
|
|
129
|
+
]] {\large\bf bar},**baz**
|
|
132
130
|
|
|
133
131
|
ソース:
|
|
134
132
|
| foo_bar.tex:
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
|| foo,bar,
|
|
134
|
+
|| {\large\bf bar},**baz**
|
|
137
135
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
foo,bar,
|
|
141
|
-
{\large\bf bar},**baz**
|
|
142
|
-
\end{WTcode}
|
|
143
|
-
\end{WTbox}
|
|
136
|
+
出力(マークアップは評価されない):
|
|
137
|
+
]foo_bar.tex:
|
|
138
|
+
]| foo,bar,
|
|
139
|
+
]| {\large\bf bar},**baz**
|
|
144
140
|
|
|
145
141
|
! 引用
|
|
146
142
|
|
|
147
143
|
行の先頭に「>」記号を置くと、その行は引用として扱われます。引用の内部では、WikiマークアップおよびTeXマークアップが利用可能です。
|
|
148
144
|
|
|
149
145
|
ソース:
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
|> 吾輩は猫である。
|
|
147
|
+
|> 名前は__まだ無い__。
|
|
152
148
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
名前は\WTunderline{まだ無い}。
|
|
157
|
-
\end{quote}
|
|
158
|
-
\end{WTbox}
|
|
149
|
+
出力:
|
|
150
|
+
]> 吾輩は猫である。
|
|
151
|
+
]> 名前は__まだ無い__。
|
|
159
152
|
|
|
160
153
|
! リスト
|
|
161
154
|
|
|
162
155
|
行の先頭に「*」または「+」記号を置くと、その行はリストアイテムとして扱われます。「*」は序数なし、「+」だと序数ありです。強調の「\verb|**foo**|」と区別するため、記号とアイテムの間には、必ず空白を入れてください。
|
|
163
156
|
|
|
164
157
|
ソース:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
\end{itemize}
|
|
174
|
-
*baz←くっつけて書くとリストにならない
|
|
175
|
-
\end{WTbox}
|
|
158
|
+
|* foo
|
|
159
|
+
|* bar
|
|
160
|
+
|*baz←くっつけて書くとリストにならない
|
|
161
|
+
|
|
162
|
+
出力:
|
|
163
|
+
]* foo
|
|
164
|
+
]* bar
|
|
165
|
+
]*baz←くっつけて書くとリストにならない
|
|
176
166
|
|
|
177
167
|
リストを入れ子にすることもできます。
|
|
178
168
|
|
|
179
169
|
ソース:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
\begin{WTbox}{出力}
|
|
186
|
-
\begin{enumerate}
|
|
187
|
-
\item foo\begin{itemize}
|
|
188
|
-
\item bar
|
|
189
|
-
\item baz
|
|
190
|
-
\end{itemize}
|
|
191
|
-
|
|
192
|
-
\item qux
|
|
193
|
-
\end{enumerate}
|
|
194
|
-
\end{WTbox}
|
|
195
|
-
|
|
196
|
-
! テーブル・表
|
|
170
|
+
|+ foo
|
|
171
|
+
|+* bar
|
|
172
|
+
|+* baz
|
|
173
|
+
|+ qux
|
|
197
174
|
|
|
198
|
-
|
|
175
|
+
出力:
|
|
176
|
+
]+ foo
|
|
177
|
+
]+* bar
|
|
178
|
+
]+* baz
|
|
179
|
+
]+ qux
|
|
199
180
|
|
|
200
181
|
!! TeXとの混在
|
|
201
182
|
|
|
@@ -241,6 +222,28 @@ TeXの特殊記号は、自動的にエスケープされます。「#」「%」
|
|
|
241
222
|
出力(ディスプレイ数式モード):
|
|
242
223
|
] これはひどい $$x^2 + \sqrt{y}$$ です。
|
|
243
224
|
|
|
225
|
+
! ボックス、引用、リスト、TeX環境のネスティング
|
|
226
|
+
|
|
227
|
+
Wikiマークアップのうち、ボックス「]」引用「>」リスト「*」「+」は、TeX環境やボックス・引用同士でネスティングすることができます。ネスティングする場合、Wiki要素の行頭マークは空白を開けずに連続して書いてください。また、TeX環境の内部にWikiマークアップを書いても評価されません。
|
|
228
|
+
|
|
229
|
+
ソース:
|
|
230
|
+
|]foo:
|
|
231
|
+
|]] $$x^2 + 2y + z$$
|
|
232
|
+
|]> **boo**
|
|
233
|
+
|]>+ A
|
|
234
|
+
|]>++ B
|
|
235
|
+
|] \begin{huge}
|
|
236
|
+
|] FOO\end{huge}
|
|
237
|
+
|
|
238
|
+
出力:
|
|
239
|
+
]]foo:
|
|
240
|
+
]]] $$x^2 + 2y + z$$
|
|
241
|
+
]]> **boo**
|
|
242
|
+
]]>+ A
|
|
243
|
+
]]>++ B
|
|
244
|
+
]] \begin{huge}
|
|
245
|
+
]] FOO\end{huge}
|
|
246
|
+
|
|
244
247
|
|
|
245
248
|
|
|
246
249
|
!!! ライセンス
|
data/lib/wtex.rb
CHANGED
|
@@ -40,16 +40,20 @@ class WTeX
|
|
|
40
40
|
line = ''
|
|
41
41
|
type = :blank
|
|
42
42
|
|
|
43
|
-
markups
|
|
43
|
+
markups = []
|
|
44
44
|
rex_line = /(.*?)(\\|\$\$?|\{|\n|\z)/
|
|
45
45
|
s = StringScanner.new str
|
|
46
46
|
|
|
47
47
|
while !s.eos? && s.scan(rex_line)
|
|
48
48
|
line += s[1]
|
|
49
49
|
|
|
50
|
-
if s[2] =~
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
if s[2] =~ /\\|\$\$?|\{/
|
|
51
|
+
if [:box, :code, :quote].include? wiki_type(line, s)
|
|
52
|
+
line << s[2] << (s.scan(/(.*?)(\n|\z)/) ? s[1] : '') # do not skip
|
|
53
|
+
else
|
|
54
|
+
line += skip_tex_markup(s, s[2], markups)
|
|
55
|
+
next unless s.match? /\z/
|
|
56
|
+
end
|
|
53
57
|
end
|
|
54
58
|
|
|
55
59
|
new_type = wiki_type(line, s)
|
|
@@ -162,7 +166,7 @@ class WTeX
|
|
|
162
166
|
title = escape_specials $1
|
|
163
167
|
end
|
|
164
168
|
body.gsub!(/^(\]|\|)/m, '')
|
|
165
|
-
body =
|
|
169
|
+
body = _tex(body) if type == :box
|
|
166
170
|
if title
|
|
167
171
|
<<_eos
|
|
168
172
|
\\begin{WT#{type}}{#{title}}
|
|
@@ -180,7 +184,7 @@ _eos
|
|
|
180
184
|
body.gsub!(/^>/m, '')
|
|
181
185
|
<<_eos
|
|
182
186
|
\\begin{quote}
|
|
183
|
-
#{
|
|
187
|
+
#{_tex body}\\end{quote}
|
|
184
188
|
_eos
|
|
185
189
|
end
|
|
186
190
|
|
data/t/test_wtex.rb
CHANGED
|
@@ -250,6 +250,115 @@ _eos
|
|
|
250
250
|
)
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
+
def test_tex_nested_wiki_in_box
|
|
254
|
+
w = <<'_eos'
|
|
255
|
+
]foo
|
|
256
|
+
]+ bar
|
|
257
|
+
]+ baz
|
|
258
|
+
_eos
|
|
259
|
+
assert_equal(
|
|
260
|
+
<<'_eos',
|
|
261
|
+
\begin{WTbox-without-title}
|
|
262
|
+
foo
|
|
263
|
+
\begin{enumerate}
|
|
264
|
+
\item bar
|
|
265
|
+
\item baz
|
|
266
|
+
\end{enumerate}
|
|
267
|
+
\end{WTbox-without-title}
|
|
268
|
+
_eos
|
|
269
|
+
@wt.tex(w),
|
|
270
|
+
'WTeX#tex should convert blocks inside a boxed block'
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
w = <<'_eos'
|
|
274
|
+
qux:
|
|
275
|
+
]foo
|
|
276
|
+
]bar:
|
|
277
|
+
]| baz
|
|
278
|
+
_eos
|
|
279
|
+
assert_equal(
|
|
280
|
+
<<'_eos',
|
|
281
|
+
\begin{WTbox}{qux}
|
|
282
|
+
foo
|
|
283
|
+
\begin{WTcode}{bar}
|
|
284
|
+
baz
|
|
285
|
+
\end{WTcode}
|
|
286
|
+
\end{WTbox}
|
|
287
|
+
_eos
|
|
288
|
+
@wt.tex(w),
|
|
289
|
+
'WTeX#tex should convert blocks inside a boxed block'
|
|
290
|
+
)
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def test_tex_nested_tex_in_box
|
|
294
|
+
w = <<'_eos'
|
|
295
|
+
]foo
|
|
296
|
+
]$$
|
|
297
|
+
]x^2 + 2y + z
|
|
298
|
+
]$$
|
|
299
|
+
_eos
|
|
300
|
+
assert_equal(
|
|
301
|
+
<<'_eos',
|
|
302
|
+
\begin{WTbox-without-title}
|
|
303
|
+
foo\\
|
|
304
|
+
$$
|
|
305
|
+
x^2 + 2y + z
|
|
306
|
+
$$
|
|
307
|
+
\end{WTbox-without-title}
|
|
308
|
+
_eos
|
|
309
|
+
@wt.tex(w),
|
|
310
|
+
'WTeX#tex should convert multi-line TeX inside a boxed block'
|
|
311
|
+
)
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def test_tex_complex_nesting_in_box
|
|
315
|
+
w = <<'_eos'
|
|
316
|
+
]foo
|
|
317
|
+
]]$$
|
|
318
|
+
]]x^2 + 2y + z
|
|
319
|
+
]]$$
|
|
320
|
+
]]**boo**
|
|
321
|
+
]\begin{huge}
|
|
322
|
+
]FOO\end{huge}
|
|
323
|
+
_eos
|
|
324
|
+
assert_equal(
|
|
325
|
+
<<'_eos',
|
|
326
|
+
\begin{WTbox-without-title}
|
|
327
|
+
foo
|
|
328
|
+
\begin{WTbox-without-title}
|
|
329
|
+
$$
|
|
330
|
+
x^2 + 2y + z
|
|
331
|
+
$$\\
|
|
332
|
+
{\large\bf boo}
|
|
333
|
+
\end{WTbox-without-title}
|
|
334
|
+
\begin{huge}
|
|
335
|
+
FOO\end{huge}
|
|
336
|
+
\end{WTbox-without-title}
|
|
337
|
+
_eos
|
|
338
|
+
@wt.tex(w),
|
|
339
|
+
'WTeX#tex should not skip complex Wiki/TeX nesting inside a boxed block'
|
|
340
|
+
)
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def test_tex_broken_tex_inside_box
|
|
344
|
+
w = <<'_eos'
|
|
345
|
+
]foo
|
|
346
|
+
]$$
|
|
347
|
+
a$c
|
|
348
|
+
_eos
|
|
349
|
+
assert_equal(
|
|
350
|
+
<<'_eos',
|
|
351
|
+
\begin{WTbox-without-title}
|
|
352
|
+
foo\\
|
|
353
|
+
\${}\${}
|
|
354
|
+
\end{WTbox-without-title}
|
|
355
|
+
a\${}c
|
|
356
|
+
_eos
|
|
357
|
+
@wt.tex(w),
|
|
358
|
+
'WTeX#tex should escape broken TeX inside a box'
|
|
359
|
+
)
|
|
360
|
+
end
|
|
361
|
+
|
|
253
362
|
def test_tex_code
|
|
254
363
|
w = <<'_eos'
|
|
255
364
|
foo.rb:
|
|
@@ -329,6 +438,25 @@ _eos
|
|
|
329
438
|
)
|
|
330
439
|
end
|
|
331
440
|
|
|
441
|
+
def test_tex_complex_nesting_in_code
|
|
442
|
+
w = <<'_eos'
|
|
443
|
+
|]**boo**
|
|
444
|
+
|\begin{huge}
|
|
445
|
+
|FOO\end{huge}
|
|
446
|
+
_eos
|
|
447
|
+
assert_equal(
|
|
448
|
+
<<'_eos',
|
|
449
|
+
\begin{WTcode-without-title}
|
|
450
|
+
]**boo**
|
|
451
|
+
\begin{huge}
|
|
452
|
+
FOO\end{huge}
|
|
453
|
+
\end{WTcode-without-title}
|
|
454
|
+
_eos
|
|
455
|
+
@wt.tex(w),
|
|
456
|
+
'WTeX#tex should treat complex Wiki/TeX nesting inside a code block'
|
|
457
|
+
)
|
|
458
|
+
end
|
|
459
|
+
|
|
332
460
|
def test_tex_quote
|
|
333
461
|
w = <<'_eos'
|
|
334
462
|
>a = 123
|
|
@@ -346,6 +474,58 @@ _eos
|
|
|
346
474
|
)
|
|
347
475
|
end
|
|
348
476
|
|
|
477
|
+
def test_tex_nested_wiki_in_quote
|
|
478
|
+
w = <<'_eos'
|
|
479
|
+
>foo
|
|
480
|
+
>+ bar
|
|
481
|
+
>+ baz
|
|
482
|
+
_eos
|
|
483
|
+
assert_equal(
|
|
484
|
+
<<'_eos',
|
|
485
|
+
\begin{quote}
|
|
486
|
+
foo
|
|
487
|
+
\begin{enumerate}
|
|
488
|
+
\item bar
|
|
489
|
+
\item baz
|
|
490
|
+
\end{enumerate}
|
|
491
|
+
\end{quote}
|
|
492
|
+
_eos
|
|
493
|
+
@wt.tex(w),
|
|
494
|
+
'WTeX#tex should convert nested blocks inside a quote'
|
|
495
|
+
)
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
def test_tex_complex_nesting_in_quote
|
|
499
|
+
w = <<'_eos'
|
|
500
|
+
>foo
|
|
501
|
+
>]$$
|
|
502
|
+
>]x^2 + 2y + z
|
|
503
|
+
>]$$
|
|
504
|
+
>>**boo**
|
|
505
|
+
>\begin{huge}
|
|
506
|
+
>FOO\end{huge}
|
|
507
|
+
_eos
|
|
508
|
+
assert_equal(
|
|
509
|
+
<<'_eos',
|
|
510
|
+
\begin{quote}
|
|
511
|
+
foo
|
|
512
|
+
\begin{WTbox-without-title}
|
|
513
|
+
$$
|
|
514
|
+
x^2 + 2y + z
|
|
515
|
+
$$
|
|
516
|
+
\end{WTbox-without-title}
|
|
517
|
+
\begin{quote}
|
|
518
|
+
{\large\bf boo}
|
|
519
|
+
\end{quote}
|
|
520
|
+
\begin{huge}
|
|
521
|
+
FOO\end{huge}
|
|
522
|
+
\end{quote}
|
|
523
|
+
_eos
|
|
524
|
+
@wt.tex(w),
|
|
525
|
+
'WTeX#tex should not skip complex Wiki/TeX nesting inside a quote'
|
|
526
|
+
)
|
|
527
|
+
end
|
|
528
|
+
|
|
349
529
|
def test_tex_itemize
|
|
350
530
|
w = <<'_eos'
|
|
351
531
|
* foo
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 1
|
|
8
|
-
-
|
|
9
|
-
version: 0.1.
|
|
8
|
+
- 1
|
|
9
|
+
version: 0.1.1
|
|
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-
|
|
17
|
+
date: 2011-02-21 00:00:00 +09:00
|
|
18
18
|
default_executable: wikitex
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|