wtex 0.1.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.
@@ -0,0 +1,16 @@
1
+ all : pdf
2
+
3
+ pdf : book.pdf
4
+
5
+ book.pdf : out/tmpl.dvi
6
+ dvipdfmx -o book.pdf out/tmpl.dvi
7
+
8
+ out/tmpl.dvi : tmpl.tex head.tex body.tex
9
+ platex -output-directory=out tmpl.tex
10
+ platex -output-directory=out tmpl.tex
11
+
12
+ tmpl.tex:
13
+ cp -p tmpl.tex.report tmpl.tex
14
+
15
+ body.tex : body.txt
16
+ wikitex convert
@@ -0,0 +1,2 @@
1
+ ここに本文を書いてください。
2
+ make結果は、book.pdfに出力されます。
@@ -0,0 +1,3 @@
1
+ \title{文書タイトル}
2
+ \author{著者名}
3
+ \date{日付} % delete this line to display the current date
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,81 @@
1
+ \documentclass[oneside,11pt,a4paper]{report}
2
+ \usepackage{okumacro}
3
+ \usepackage{ascmac}
4
+ \usepackage{fancybox}
5
+
6
+ \textheight 25cm
7
+ \textwidth 17cm
8
+ \topmargin -1cm
9
+ \oddsidemargin -.5cm
10
+ \evensidemargin -.5cm
11
+
12
+ \parindent 0zw
13
+ \parskip 1zw plus .5zw minus .2zw
14
+ \vfuzz 10pt
15
+
16
+ %%% custom commands
17
+ \newcommand{\WTunderline}[1]
18
+ {
19
+ \underline{#1}
20
+ }
21
+
22
+ \newcommand{\WTseparator}[0]
23
+ {
24
+ \begin{center}\subsection*{◆◇◆}\end{center}
25
+ }
26
+
27
+ %%% custom environments
28
+ \newenvironment{WTbox}[1]
29
+ {
30
+ \begin{itembox}[l]{#1}
31
+ }
32
+ {
33
+ \end{itembox}
34
+ }
35
+
36
+ \newenvironment{WTbox-without-title}[0]
37
+ {
38
+ \begin{screen}
39
+ }
40
+ {
41
+ \end{screen}
42
+ }
43
+
44
+ \newenvironment{WTcode}[1]
45
+ {
46
+ \VerbatimEnvironment
47
+ \begin{itembox}[l]{#1}
48
+ \baselineskip=.8\normalbaselineskip
49
+ \begin{Verbatim}
50
+ }
51
+ {
52
+ \end{Verbatim}
53
+ \baselineskip=\normalbaselineskip
54
+ \end{itembox}
55
+ }
56
+
57
+ \newenvironment{WTcode-without-title}[0]
58
+ {
59
+ \VerbatimEnvironment
60
+ \begin{screen}
61
+ \baselineskip=.8\normalbaselineskip
62
+ \begin{Verbatim}
63
+ }
64
+ {
65
+ \end{Verbatim}
66
+ \baselineskip=\normalbaselineskip
67
+ \end{screen}
68
+ }
69
+
70
+ %%% title, author, etc.
71
+ \include{head}
72
+
73
+ %%% body
74
+ \begin{document}
75
+
76
+ \maketitle
77
+ \tableofcontents
78
+
79
+ \include{body}
80
+
81
+ \end{document}
@@ -0,0 +1,85 @@
1
+ \documentclass[oneside,12pt,landscape]{tbook}
2
+ \usepackage{okumacro}
3
+ \usepackage{ascmac}
4
+ \usepackage{fancybox}
5
+
6
+ \AtBeginDvi{\special{papersize=297mm,210mm}}
7
+
8
+ \textheight 34\baselineskip
9
+ \textwidth 39zw
10
+ \oddsidemargin 4zw
11
+
12
+ %\textwidth 41zw
13
+ %\kanjiskip=.1zw plus 3pt minus 3pt
14
+ %\xkanjiskip=.2zw plus 3pt minus 3pt
15
+
16
+ \parindent 0zw
17
+ \parskip 1zw plus .5zw minus .2zw
18
+ \vfuzz 10pt
19
+
20
+ %%% custom commands
21
+ \newcommand{\WTunderline}[1]
22
+ {
23
+ \bou{#1}
24
+ }
25
+
26
+ \newcommand{\WTseparator}[0]
27
+ {
28
+ \begin{center}\subsection*{◆◇◆}\end{center}
29
+ }
30
+
31
+ %%% custom environments
32
+ \newenvironment{WTbox}[1]
33
+ {
34
+ \begin{itembox}[l]{#1}
35
+ }
36
+ {
37
+ \end{itembox}
38
+ }
39
+
40
+ \newenvironment{WTbox-without-title}[0]
41
+ {
42
+ \begin{screen}
43
+ }
44
+ {
45
+ \end{screen}
46
+ }
47
+
48
+ \newenvironment{WTcode}[1]
49
+ {
50
+ \VerbatimEnvironment
51
+ \begin{itembox}[l]{#1}
52
+ \baselineskip=.6\normalbaselineskip
53
+ \begin{Verbatim}
54
+ }
55
+ {
56
+ \end{Verbatim}
57
+ \baselineskip=\normalbaselineskip
58
+ \end{itembox}
59
+ }
60
+
61
+ \newenvironment{WTcode-without-title}[0]
62
+ {
63
+ \VerbatimEnvironment
64
+ \begin{screen}
65
+ \baselineskip=.6\normalbaselineskip
66
+ \begin{Verbatim}
67
+ }
68
+ {
69
+ \end{Verbatim}
70
+ \baselineskip=\normalbaselineskip
71
+ \end{screen}
72
+ }
73
+
74
+ %%% title, author, etc.
75
+ \include{head}
76
+
77
+ %%% body
78
+ \begin{document}
79
+
80
+ \maketitle
81
+ \tableofcontents
82
+
83
+ \include{body}
84
+
85
+ \end{document}
data/t/t.rb ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # Author:: Akira FUNAI
5
+ # Copyright:: Copyright (c) 2011 Akira FUNAI
6
+
7
+ require 'test/unit'
8
+
9
+ t_dir = ::File.dirname __FILE__
10
+
11
+ $LOAD_PATH.unshift t_dir
12
+ $LOAD_PATH.unshift(::File.expand_path('../lib', t_dir))
13
+ require 'wtex'
@@ -0,0 +1,455 @@
1
+ # encoding: UTF-8
2
+
3
+ # Author:: Akira FUNAI
4
+ # Copyright:: Copyright (c) 2011 Akira FUNAI
5
+
6
+ require "#{::File.dirname __FILE__}/t"
7
+
8
+ class TC_WTeX < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @wt = WTeX.new
12
+ end
13
+
14
+ def teardown
15
+ end
16
+
17
+ def test_instance
18
+ wt = nil
19
+ assert_nothing_raised(
20
+ 'WikiTex.new should return a proper instance'
21
+ ) {
22
+ wt = WTeX.new
23
+ }
24
+ assert_instance_of(
25
+ WTeX,
26
+ wt,
27
+ 'WikiTex.new should return a proper instance'
28
+ )
29
+ end
30
+
31
+ def test_tex_heading
32
+ [
33
+ '!foo',
34
+ '! foo',
35
+ "! foo\n",
36
+ ].each {|w|
37
+ assert_equal(
38
+ "\\subsection{foo}\n",
39
+ @wt.tex(w.dup),
40
+ "WTeX#tex should convert #{w.inspect} into \\subsection{foo}"
41
+ )
42
+ }
43
+
44
+ assert_equal(
45
+ "\\section{bar}\n",
46
+ @wt.tex('!! bar'),
47
+ 'WTeX#tex should convert "!! bar" into \\section{bar}'
48
+ )
49
+ assert_equal(
50
+ "\\chapter{baz}\n",
51
+ @wt.tex('!!! baz'),
52
+ 'WTeX#tex should convert "!!! baz" into \\chapter{baz}'
53
+ )
54
+
55
+ assert_equal(
56
+ "\\chapter{baz}\n",
57
+ @wt.tex('!!!!! baz'),
58
+ 'WTeX#tex should convert more than 4 "!"s into \\chapter{}'
59
+ )
60
+ end
61
+
62
+ def test_tex_separator
63
+ assert_equal(
64
+ "\\WTseparator{}\n",
65
+ @wt.tex('---'),
66
+ 'WTeX#tex should convert "---" into \\WTseparator{}'
67
+ )
68
+ end
69
+
70
+ def test_tex_heading_without_number
71
+ assert_equal(
72
+ "\\subsection*{foo}\n",
73
+ @wt.tex('!* foo'),
74
+ 'WTeX#tex should convert "!!!" with "*" into \\chapter*{}'
75
+ )
76
+ assert_equal(
77
+ "\\chapter*{baz}\n",
78
+ @wt.tex('!!!* baz'),
79
+ 'WTeX#tex should convert "!!!" with "*" into \\chapter*{}'
80
+ )
81
+ end
82
+
83
+ def test_tex_heading_combination
84
+ w = <<'_eos'
85
+ !!! foo
86
+
87
+ !! bar
88
+
89
+ _eos
90
+ assert_equal(
91
+ <<'_eos',
92
+ \chapter{foo}
93
+
94
+ \section{bar}
95
+
96
+ _eos
97
+ @wt.tex(w),
98
+ 'WTeX#tex should deal with multiple headings'
99
+ )
100
+
101
+ w = <<'_eos'
102
+ !!! foo
103
+ !! bar
104
+
105
+ _eos
106
+ assert_equal(
107
+ <<'_eos',
108
+ \chapter{foo}
109
+ \section{bar}
110
+
111
+ _eos
112
+ @wt.tex(w),
113
+ 'WTeX#tex should deal with sequence of headings'
114
+ )
115
+ end
116
+
117
+ def test_tex_p
118
+ w = <<'_eos'
119
+ foo
120
+ bar
121
+ _eos
122
+ assert_equal(
123
+ <<'_eos',
124
+ foo\\
125
+ bar
126
+ _eos
127
+ @wt.tex(w),
128
+ 'WTeX#tex should append new line commands explicitly'
129
+ )
130
+ end
131
+
132
+ def test_tex_p_multiple
133
+ w = <<'_eos'
134
+ foo
135
+ bar
136
+
137
+ baz
138
+ qux
139
+
140
+ boo
141
+ _eos
142
+ assert_equal(
143
+ <<'_eos',
144
+ foo\\
145
+ bar
146
+
147
+ baz\\
148
+ qux
149
+
150
+ boo
151
+ _eos
152
+ @wt.tex(w),
153
+ 'WTeX#tex should deal with multiple paragraphs'
154
+ )
155
+
156
+ w = <<'_eos'
157
+ foo
158
+ bar
159
+ baz
160
+
161
+ qux
162
+
163
+ boo
164
+ _eos
165
+ assert_equal(
166
+ <<'_eos',
167
+ foo\\
168
+ bar\\
169
+ baz
170
+
171
+ qux
172
+
173
+ boo
174
+ _eos
175
+ @wt.tex(w),
176
+ 'WTeX#tex should deal with multiple paragraphs'
177
+ )
178
+ end
179
+
180
+ def test_tex_p_combination
181
+ w = <<'_eos'
182
+ !!! foo
183
+
184
+ baz
185
+ qux
186
+
187
+ boo
188
+ _eos
189
+ assert_equal(
190
+ <<'_eos',
191
+ \chapter{foo}
192
+
193
+ baz\\
194
+ qux
195
+
196
+ boo
197
+ _eos
198
+ @wt.tex(w),
199
+ 'WTeX#tex should deal with combination of commands and paragraphs'
200
+ )
201
+
202
+ w = <<'_eos'
203
+ foo
204
+ bar
205
+
206
+ !! qux
207
+
208
+ boo
209
+ _eos
210
+ assert_equal(
211
+ <<'_eos',
212
+ foo\\
213
+ bar
214
+
215
+ \section{qux}
216
+
217
+ boo
218
+ _eos
219
+ @wt.tex(w),
220
+ 'WTeX#tex should deal with combination of commands and paragraphs'
221
+ )
222
+ end
223
+
224
+ def test_tex_box
225
+ w = <<'_eos'
226
+ foo:
227
+ ] ***big***
228
+ _eos
229
+ assert_equal(
230
+ <<'_eos',
231
+ \begin{WTbox}{foo}
232
+ {\LARGE\bf big}
233
+ \end{WTbox}
234
+ _eos
235
+ @wt.tex(w),
236
+ "WTeX#tex should convert lines which begin with ']' into boxed block"
237
+ )
238
+
239
+ w = <<'_eos'
240
+ ] ***big***
241
+ _eos
242
+ assert_equal(
243
+ <<'_eos',
244
+ \begin{WTbox-without-title}
245
+ {\LARGE\bf big}
246
+ \end{WTbox-without-title}
247
+ _eos
248
+ @wt.tex(w),
249
+ "WTeX#tex should convert lines which begin with ']' into boxed block"
250
+ )
251
+ end
252
+
253
+ def test_tex_code
254
+ w = <<'_eos'
255
+ foo.rb:
256
+ |a = 123
257
+ | b = 456 * 789
258
+ _eos
259
+ assert_equal(
260
+ <<'_eos',
261
+ \begin{WTcode}{foo.rb}
262
+ a = 123
263
+ b = 456 * 789
264
+ \end{WTcode}
265
+ _eos
266
+ @wt.tex(w),
267
+ "WTeX#tex should convert lines which begin with '|' into code block"
268
+ )
269
+
270
+ w = <<'_eos'
271
+ foo.rb:
272
+ bbb|a = 123
273
+ _eos
274
+ assert_equal(
275
+ <<'_eos',
276
+ foo.rb:\\
277
+ bbb\textbar{}a = 123
278
+ _eos
279
+ @wt.tex(w),
280
+ "WTeX#tex should convert lines which begin with '|' into code block"
281
+ )
282
+
283
+ w = <<'_eos'
284
+ foo_bar.rb:
285
+ |a = 123
286
+ _eos
287
+ assert_equal(
288
+ <<'_eos',
289
+ \begin{WTcode}{foo\_{}bar.rb}
290
+ a = 123
291
+ \end{WTcode}
292
+ _eos
293
+ @wt.tex(w),
294
+ 'WTeX#tex should escape title of code blocks'
295
+ )
296
+ end
297
+
298
+ def test_tex_code_without_title
299
+ w = <<'_eos'
300
+ |a = 123
301
+ | b = 456 * 789
302
+ _eos
303
+ assert_equal(
304
+ <<'_eos',
305
+ \begin{WTcode-without-title}
306
+ a = 123
307
+ b = 456 * 789
308
+ \end{WTcode-without-title}
309
+ _eos
310
+ @wt.tex(w),
311
+ "WTeX#tex should convert lines which begin with '|' into code block"
312
+ )
313
+
314
+ w = <<'_eos'
315
+ |foo.rb:
316
+ |a = 123
317
+ | b = 456 * 789
318
+ _eos
319
+ assert_equal(
320
+ <<'_eos',
321
+ \begin{WTcode-without-title}
322
+ foo.rb:
323
+ a = 123
324
+ b = 456 * 789
325
+ \end{WTcode-without-title}
326
+ _eos
327
+ @wt.tex(w),
328
+ "WTeX#tex should not treat lines which begin with '|' as a title"
329
+ )
330
+ end
331
+
332
+ def test_tex_quote
333
+ w = <<'_eos'
334
+ >a = 123
335
+ > b = 456 & 789
336
+ _eos
337
+ assert_equal(
338
+ <<'_eos',
339
+ \begin{quote}
340
+ a = 123\\
341
+ b = 456 \&{} 789
342
+ \end{quote}
343
+ _eos
344
+ @wt.tex(w),
345
+ "WTeX#tex should convert lines which begin with '>' into quote"
346
+ )
347
+ end
348
+
349
+ def test_tex_itemize
350
+ w = <<'_eos'
351
+ * foo
352
+ * bar
353
+ _eos
354
+ assert_equal(
355
+ <<'_eos',
356
+ \begin{itemize}
357
+ \item foo
358
+ \item bar
359
+ \end{itemize}
360
+ _eos
361
+ @wt.tex(w),
362
+ "WTeX#tex should convert lines which begin with '*' into list"
363
+ )
364
+
365
+ w = <<'_eos'
366
+ * **baz**
367
+ _eos
368
+ assert_equal(
369
+ <<'_eos',
370
+ \begin{itemize}
371
+ \item {\large\bf baz}
372
+ \end{itemize}
373
+ _eos
374
+ @wt.tex(w),
375
+ "WTeX#tex should convert lines which begin with '*' into list"
376
+ )
377
+ end
378
+
379
+ def test_tex_itemize_ambiguous
380
+ w = <<'_eos'
381
+ *foo
382
+ _eos
383
+ assert_equal(
384
+ <<'_eos',
385
+ *foo
386
+ _eos
387
+ @wt.tex(w),
388
+ "WTeX#tex should not convert lines with '*' and immidiate strings without spaces"
389
+ )
390
+ end
391
+
392
+ def test_tex_enumerate
393
+ w = <<'_eos'
394
+ + foo
395
+ + bar
396
+ _eos
397
+ assert_equal(
398
+ <<'_eos',
399
+ \begin{enumerate}
400
+ \item foo
401
+ \item bar
402
+ \end{enumerate}
403
+ _eos
404
+ @wt.tex(w),
405
+ "WTeX#tex should convert lines which begin with '+' into list"
406
+ )
407
+ end
408
+
409
+ def test_tex_nested_list
410
+ w = <<'_eos'
411
+ * foo
412
+ ** bar
413
+ ** baz
414
+ * qux
415
+ _eos
416
+ assert_equal(
417
+ <<'_eos',
418
+ \begin{itemize}
419
+ \item foo\begin{itemize}
420
+ \item bar
421
+ \item baz
422
+ \end{itemize}
423
+
424
+ \item qux
425
+ \end{itemize}
426
+ _eos
427
+ @wt.tex(w),
428
+ 'WTeX#tex should handle nested lists'
429
+ )
430
+ end
431
+
432
+ def test_tex_mixed_list
433
+ w = <<'_eos'
434
+ * foo
435
+ *+ bar
436
+ *+ baz
437
+ * qux
438
+ _eos
439
+ assert_equal(
440
+ <<'_eos',
441
+ \begin{itemize}
442
+ \item foo\begin{enumerate}
443
+ \item bar
444
+ \item baz
445
+ \end{enumerate}
446
+
447
+ \item qux
448
+ \end{itemize}
449
+ _eos
450
+ @wt.tex(w),
451
+ 'WTeX#tex should handle mixed lists'
452
+ )
453
+ end
454
+
455
+ end