langhelp 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
data/test/ruby.e ADDED
@@ -0,0 +1,3 @@
1
+ ruby.e for test
2
+ # (lh-ri "Array#transpose")
3
+ # (lh-ri "Array#uniq")
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <head><link rel="next" href="tagify02.html"><title>Test &amp; HTML</title><meta http-equiv="Content-Type" content="text/html; charset=Shift-JIS"></head>
3
+ <body>
4
+ blah blah blah
5
+ <h1>HeadLine1</h1>
6
+ <h2>HeadLine2</h2>
7
+ <dl>
8
+ <dt>DescListItem</dt>
9
+ <dd>DescListDesc</dd>
10
+ </dl>
11
+ </body></html>
@@ -0,0 +1,11 @@
1
+ <html><body>
2
+ blah blah blah
3
+ <h1>HeadLine1
4
+ (with new line)
5
+ </h1>
6
+ <h2>HeadLine2</h2>
7
+ <dl>
8
+ <dt><img src="DescListItem.jpg" alt="DescListItem"></dt>
9
+ <dd>DescListDesc</dd>
10
+ </dl>
11
+ </body></html>
data/test/test-base.rb ADDED
@@ -0,0 +1,538 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require 'langhelp/langhelp-base'
4
+ require 'stringio'
5
+ require 'fileutils'
6
+ require 'tmpdir'
7
+ require 'test/common'
8
+ require 'langhelp/langhelp-sub'
9
+
10
+ class TestGrepIndex < Test::Unit::TestCase
11
+ include CheckLink
12
+ def setup
13
+ @path = "/tmp/test0.rd"
14
+ open(@path, "w") {|f| f.write(<<EOT) }
15
+ --- index1
16
+ body1
17
+ --- index2
18
+ body2
19
+ EOT
20
+ end
21
+
22
+ def teardown
23
+ File.unlink @path
24
+ end
25
+
26
+ def test_grep_old
27
+ @x = Grep.new(:Grep=> /^\s*---/, :src=>@path)
28
+ check_link <<EOT
29
+ # (lh-view " --- index1"\t"/tmp/test0.rd")
30
+ # (lh-view "--- index2"\t"/tmp/test0.rd")
31
+ EOT
32
+ end
33
+
34
+ def test_grep_new
35
+ @x = Grep.new(:Grep=> @path, :regexp=>/^\s*---/)
36
+ check_link <<EOT
37
+ # (lh-view " --- index1"\t"/tmp/test0.rd")
38
+ # (lh-view "--- index2"\t"/tmp/test0.rd")
39
+ EOT
40
+ end
41
+
42
+ def test_grep__exclude
43
+ @x = Grep.new(:Grep=> /^\s*---/, :src=>@path, :exclude=>[" --- index1"])
44
+ check_link <<EOT
45
+ # (lh-view "--- index2"\t"/tmp/test0.rd")
46
+ EOT
47
+ end
48
+
49
+ def test_grep__exclude
50
+ @x = Grep.new(:Grep=> /^\s*---/, :src=>@path, :exclude=> /index1/)
51
+ check_link <<EOT
52
+ # (lh-view "--- index2"\t"/tmp/test0.rd")
53
+ EOT
54
+ end
55
+
56
+ end
57
+
58
+ class TestGrepEncoding < Test::Unit::TestCase
59
+ include CheckLink
60
+
61
+ def path
62
+ scriptdir = Dir.scriptdir
63
+ "#{scriptdir}/tagify-japanese-before.html"
64
+ end
65
+
66
+ def result
67
+ <<EOT
68
+ # (lh-view "<h1>�縫�Ф�</h1>"\t"#{path}")
69
+ # (lh-view "<h2>�渫�Ф�</h2>"\t"#{path}")
70
+ EOT
71
+ end
72
+
73
+
74
+
75
+ def test_grep__encoding
76
+ @x = Grep.new(:Grep=> /^<h[12]>/, :src=>path, :conf=>{:ENCODING=>:utf8})
77
+ check_link(result.toutf8)
78
+
79
+ @x = Grep.new(:Grep=> /^<h[12]>/, :src=>path, :conf=>{:ENCODING=>:euc_jp})
80
+ check_link(result.toeuc)
81
+
82
+ @x = Grep.new(:Grep=> /^<h[12]>/, :src=>path, :conf=>{:ENCODING=>:sjis})
83
+ check_link(result.tosjis)
84
+ end
85
+ end
86
+
87
+
88
+
89
+ class TestLink < Test::Unit::TestCase
90
+ include CheckLink
91
+
92
+ def test_w3mlink_with_label
93
+ @x = W3MLink.new :W3MLink=>"/usr/bin/ruby", :label=>"ruby executable"
94
+ check_link %Q!# ruby executable\t(lh-w3m nil "/usr/bin/ruby")\n!
95
+ end
96
+
97
+ def test_viewlink_with_label
98
+ @x = ViewLink.new :ViewLink=>"/usr/bin/ruby", :label=>"ruby executable"
99
+ check_link %Q!# ruby executable\t(lh-view nil "/usr/bin/ruby")\n!
100
+ end
101
+
102
+ def test_w3mlink_without_label
103
+ @x = W3MLink.new :W3MLink=>"/usr/bin/ruby"
104
+ check_link %Q!# (lh-w3m nil "/usr/bin/ruby")\n!
105
+ end
106
+
107
+ end
108
+
109
+ class TestManpage < Test::Unit::TestCase
110
+ include CheckLink
111
+
112
+ def test_manpages
113
+ @x = Manpage.new :Manpage=>[1], :manpath=>["/usr/share/man"], :glob=>"ls.1.gz"
114
+ check_link %Q!# (lh-man "1 ls")\n!
115
+ end
116
+
117
+ def test_a_manpage
118
+ ENV['LC_ALL']='C'
119
+ ENV['LANG']='C'
120
+ @x = Manpage.new :Manpage=>"ls", :section=>1
121
+ check_link_include? %Q!# (lh-man* "NAME"\t"1 ls")!
122
+ check_link_include? %Q!# (lh-man* "SYNOPSIS"\t"1 ls")!
123
+ check_link_include? %Q!# (lh-man* " -l use a long listing format"\t"1 ls")!
124
+ end
125
+
126
+
127
+ end
128
+
129
+ class TestW3MExtractLinks < Test::Unit::TestCase
130
+ include CheckLink
131
+ def setup
132
+ @tmpdir=Dir.tmpdir
133
+ @html=File.join @tmpdir, "index.html"
134
+ @src = <<XXX
135
+ <html><body>
136
+ <a href="foo.html">Foo</a><br>
137
+ <a href='bar.html'>Bar<img src="a.jpg"></a><br>
138
+ <a href=baz.html><em>Baz</em></a><br>
139
+ <A href=0.html onclick="">0</a><br>
140
+ <a name="x" href=1.html>1</a><br>
141
+ <a href=/usr/doc/foo/README>&lt;a document&gt;</a><br>
142
+ <a href="img.html">[<img SRC="dot.jpg"><IMG src="img.jpg" alt="img"><img src="dot.jpg">]</a><br>
143
+ </body></html>
144
+ XXX
145
+ open(@html,"w"){|f| f.write @src}
146
+ end
147
+
148
+ def teardown
149
+ $langhelp_home = nil
150
+ FileUtils.rm_f @html
151
+ end
152
+
153
+ def test_w3mextractlinks
154
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html
155
+
156
+ check_link <<XXX
157
+ # Foo\t(lh-w3m nil "#{@tmpdir}/foo.html")
158
+ # Bar\t(lh-w3m nil "#{@tmpdir}/bar.html")
159
+ # Baz\t(lh-w3m nil "#{@tmpdir}/baz.html")
160
+ # 0\t(lh-w3m nil "#{@tmpdir}/0.html")
161
+ # 1\t(lh-w3m nil "#{@tmpdir}/1.html")
162
+ # <a document>\t(lh-w3m nil "/usr/doc/foo/README")
163
+ # [img]\t(lh-w3m nil "#{@tmpdir}/img.html")
164
+ XXX
165
+ end
166
+
167
+ def test_w3mextractlinks__langhelp_home
168
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html
169
+ $langhelp_home = @tmpdir # GLOBAL
170
+
171
+ check_link <<XXX
172
+ # Foo\t(lh-w3m nil "foo.html")
173
+ # Bar\t(lh-w3m nil "bar.html")
174
+ # Baz\t(lh-w3m nil "baz.html")
175
+ # 0\t(lh-w3m nil "0.html")
176
+ # 1\t(lh-w3m nil "1.html")
177
+ # <a document>\t(lh-w3m nil "/usr/doc/foo/README")
178
+ # [img]\t(lh-w3m nil "img.html")
179
+ XXX
180
+ end
181
+
182
+
183
+ def test_w3mextractlinks_exclude_label__regexp
184
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :exclude_label => /Foo/
185
+
186
+ check_link <<XXX
187
+ # Bar\t(lh-w3m nil "#{@tmpdir}/bar.html")
188
+ # Baz\t(lh-w3m nil "#{@tmpdir}/baz.html")
189
+ # 0\t(lh-w3m nil "#{@tmpdir}/0.html")
190
+ # 1\t(lh-w3m nil "#{@tmpdir}/1.html")
191
+ # <a document>\t(lh-w3m nil "/usr/doc/foo/README")
192
+ # [img]\t(lh-w3m nil "#{@tmpdir}/img.html")
193
+ XXX
194
+ end
195
+
196
+ def test_w3mextractlinks_exclude_label__regexps
197
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :exclude_label => [/Foo/, /Bar/]
198
+
199
+ check_link <<XXX
200
+ # Baz\t(lh-w3m nil "#{@tmpdir}/baz.html")
201
+ # 0\t(lh-w3m nil "#{@tmpdir}/0.html")
202
+ # 1\t(lh-w3m nil "#{@tmpdir}/1.html")
203
+ # <a document>\t(lh-w3m nil "/usr/doc/foo/README")
204
+ # [img]\t(lh-w3m nil "#{@tmpdir}/img.html")
205
+ XXX
206
+ end
207
+
208
+ def test_w3mextractlinks_exclude_label__string
209
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :exclude_label => ["Foo", "Bar"]
210
+
211
+ check_link <<XXX
212
+ # Baz\t(lh-w3m nil "#{@tmpdir}/baz.html")
213
+ # 0\t(lh-w3m nil "#{@tmpdir}/0.html")
214
+ # 1\t(lh-w3m nil "#{@tmpdir}/1.html")
215
+ # <a document>\t(lh-w3m nil "/usr/doc/foo/README")
216
+ # [img]\t(lh-w3m nil "#{@tmpdir}/img.html")
217
+ XXX
218
+ end
219
+
220
+ def test_w3mextractlinks_exclude_url__regexp
221
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :exclude_url => /\d.html/
222
+
223
+ check_link <<XXX
224
+ # Foo\t(lh-w3m nil "#{@tmpdir}/foo.html")
225
+ # Bar\t(lh-w3m nil "#{@tmpdir}/bar.html")
226
+ # Baz\t(lh-w3m nil "#{@tmpdir}/baz.html")
227
+ # <a document>\t(lh-w3m nil "/usr/doc/foo/README")
228
+ # [img]\t(lh-w3m nil "#{@tmpdir}/img.html")
229
+ XXX
230
+ end
231
+
232
+ def test_w3mextractlinks_exclude_both
233
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :exclude_url => /\d.html/, :exclude_label => ["Foo", "Bar"]
234
+
235
+ check_link <<XXX
236
+ # Baz\t(lh-w3m nil "#{@tmpdir}/baz.html")
237
+ # <a document>\t(lh-w3m nil "/usr/doc/foo/README")
238
+ # [img]\t(lh-w3m nil "#{@tmpdir}/img.html")
239
+ XXX
240
+ end
241
+
242
+
243
+ end
244
+
245
+ class TestW3MExtractLinksMultipleLines < Test::Unit::TestCase
246
+ include CheckLink
247
+ def setup
248
+ @tmpdir=Dir.tmpdir
249
+ @html=File.join @tmpdir, "index.html"
250
+ @base = "/usr/share/doc/stl-manual/html/index.html"
251
+ @src = <<XXX
252
+ <html><body>
253
+ <A href="http://www.sgi.com/"><IMG SRC="surf.gif" HEIGHT="54" WIDTH="54"
254
+ ALT="[Silicon Surf]"></A>
255
+ <A HREF="index.html"><IMG SRC="stl_home.gif"
256
+ HEIGHT="54" WIDTH="54" ALT="[STL Home]"></A>
257
+ <BR>
258
+ <FONT SIZE="-2">
259
+ <A href="http://www.sgi.com/Misc/sgi_info.html" TARGET="_top">Copyright &copy;
260
+ 1999 Silicon Graphics, Inc.</A> All Rights Reserved.</FONT>
261
+ <FONT SIZE="-3"><a href="http://www.sgi.com/Misc/external.list.html" TARGET="_top">TrademarkInformation</A>
262
+ </FONT>
263
+ </body></html>
264
+ XXX
265
+ open(@html,"w"){|f| f.write @src}
266
+ end
267
+
268
+ def teardown
269
+ FileUtils.rm_f @html
270
+ end
271
+
272
+ def test_w3mextractlinks
273
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :base=>@base
274
+
275
+ check_link <<XXX
276
+ # [Silicon Surf]\t(lh-w3m nil "http://www.sgi.com/")
277
+ # [STL Home]\t(lh-w3m nil "/usr/share/doc/stl-manual/html/index.html")
278
+ # Copyright &copy; 1999 Silicon Graphics, Inc.\t(lh-w3m nil "http://www.sgi.com/Misc/sgi_info.html")
279
+ # TrademarkInformation\t(lh-w3m nil "http://www.sgi.com/Misc/external.list.html")
280
+ XXX
281
+ end
282
+
283
+ def test_w3mextractlinks__exclude
284
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :base=>@base, :exclude_url => /sgi.com/
285
+
286
+ check_link <<XXX
287
+ # [STL Home]\t(lh-w3m nil "/usr/share/doc/stl-manual/html/index.html")
288
+ XXX
289
+ end
290
+
291
+ def test_w3mextractlinks__exclude_url
292
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :base=>@base, :exclude_url=>[ "http://www.sgi.com/", "http://www.sgi.com/Misc/sgi_info.html", /external.list/]
293
+
294
+ check_link <<XXX
295
+ # [STL Home]\t(lh-w3m nil "/usr/share/doc/stl-manual/html/index.html")
296
+ XXX
297
+ end
298
+
299
+ def test_w3mextractlinks__exclude_file
300
+ @x = W3MExtractLinks.new :W3MExtractLinks=>@html, :base=>@base, :exclude_url=>[ "index.html" ]
301
+
302
+ check_link <<XXX
303
+ # [Silicon Surf]\t(lh-w3m nil "http://www.sgi.com/")
304
+ # Copyright &copy; 1999 Silicon Graphics, Inc.\t(lh-w3m nil "http://www.sgi.com/Misc/sgi_info.html")
305
+ # TrademarkInformation\t(lh-w3m nil "http://www.sgi.com/Misc/external.list.html")
306
+ XXX
307
+
308
+ end
309
+
310
+
311
+ end
312
+
313
+ class TestHTML < Test::Unit::TestCase
314
+ include CheckLink
315
+
316
+ def teardown
317
+ $langhelp_home = nil
318
+ end
319
+
320
+ def test_html__writable_01
321
+ # (find-filez "tagify01-before.html tagify01.html")
322
+ scriptdir = Dir.scriptdir
323
+ @before_html = "#{scriptdir}/tagify01-before.html"
324
+ @tagify_html = "#{scriptdir}/tagify01.html"
325
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
326
+ @x = HTML.new(:HTML=>@tagify_html, :title=>"HTML document")
327
+
328
+ # implies `@x.tagify'
329
+ check_link <<XXX
330
+ # Title: Test & HTML\t(lh-w3m nil "file://#{@tagify_html}")
331
+ # = HeadLine1\t(lh-w3m nil "file://#{@tagify_html}#0001")
332
+ # == HeadLine2\t(lh-w3m nil "file://#{@tagify_html}#0002")
333
+ # : DescListItem\t(lh-w3m nil "file://#{@tagify_html}#0003")
334
+ XXX
335
+
336
+ htmlsrc = File.read @tagify_html
337
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
338
+ assert htmlsrc !~ /meta.+charset/i
339
+ assert htmlsrc =~ %r!<h1><a name="0001"></a>HeadLine1</h1>!
340
+ assert htmlsrc =~ %r!<h2><a name="0002"></a>HeadLine2</h2>!
341
+ assert htmlsrc =~ %r!<dt><a name="0003"></a>DescListItem</dt>!
342
+ end
343
+
344
+ def test_html__writable_01__basedir
345
+ # (find-filez "tagify01-before.html tagify01.html")
346
+ scriptdir = Dir.scriptdir
347
+ @before_html = "#{scriptdir}/tagify01-before.html"
348
+ @tagify_html = "#{scriptdir}/tagify01.html"
349
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
350
+ @x = HTML.new(:HTML=>File.basename(@tagify_html), :title=>"HTML document", :basedir=>scriptdir)
351
+
352
+ # implies `@x.tagify'
353
+ check_link <<XXX
354
+ # Title: Test & HTML\t(lh-w3m nil "file://#{@tagify_html}")
355
+ # = HeadLine1\t(lh-w3m nil "file://#{@tagify_html}#0001")
356
+ # == HeadLine2\t(lh-w3m nil "file://#{@tagify_html}#0002")
357
+ # : DescListItem\t(lh-w3m nil "file://#{@tagify_html}#0003")
358
+ XXX
359
+
360
+ htmlsrc = File.read @tagify_html
361
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
362
+ assert htmlsrc !~ /meta.+charset/i
363
+ assert htmlsrc =~ %r!<h1><a name="0001"></a>HeadLine1</h1>!
364
+ assert htmlsrc =~ %r!<h2><a name="0002"></a>HeadLine2</h2>!
365
+ assert htmlsrc =~ %r!<dt><a name="0003"></a>DescListItem</dt>!
366
+ end
367
+
368
+ def test_html__writable_01__noconv
369
+ # (find-filez "tagify01-before.html tagify01-noconv.html")
370
+ scriptdir = Dir.scriptdir
371
+ @before_html = "#{scriptdir}/tagify01-before.html"
372
+ @tagify_html = "#{scriptdir}/tagify01-noconv.html"
373
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
374
+ @x = HTML.new(:HTML=>@tagify_html, :title=>"HTML document", :noconv=>true)
375
+
376
+ # implies `@x.tagify'
377
+ check_link <<XXX
378
+ # Title: Test & HTML\t(lh-w3m nil "file://#{@tagify_html}")
379
+ # = HeadLine1\t(lh-w3m nil "file://#{@tagify_html}#0001")
380
+ # == HeadLine2\t(lh-w3m nil "file://#{@tagify_html}#0002")
381
+ # : DescListItem\t(lh-w3m nil "file://#{@tagify_html}#0003")
382
+ XXX
383
+
384
+ htmlsrc = File.read @tagify_html
385
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
386
+ assert htmlsrc =~ /meta.+charset/i
387
+ assert htmlsrc =~ %r!<h1><a name="0001"></a>HeadLine1</h1>!
388
+ assert htmlsrc =~ %r!<h2><a name="0002"></a>HeadLine2</h2>!
389
+ assert htmlsrc =~ %r!<dt><a name="0003"></a>DescListItem</dt>!
390
+ end
391
+
392
+
393
+ def test_html__writable_01_already_tagified
394
+ # (find-filez "tagify01-before.html tagify01.html")
395
+ scriptdir = Dir.scriptdir
396
+ @before_html = "#{scriptdir}/tagify01-before.html"
397
+ @tagify_html = "#{scriptdir}/tagify01.html"
398
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
399
+ @x = HTML.new(:HTML=>@tagify_html, :title=>"HTML document")
400
+ @x.tagify
401
+ # re-tagify
402
+ @x = HTML.new(:HTML=>@tagify_html, :title=>"HTML document")
403
+ @x.tagify
404
+
405
+ htmlsrc = File.read @tagify_html
406
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
407
+ assert htmlsrc =~ %r!<h1><a name="0001"></a>HeadLine1</h1>!
408
+ assert htmlsrc =~ %r!<h2><a name="0002"></a>HeadLine2</h2>!
409
+ assert htmlsrc =~ %r!<dt><a name="0003"></a>DescListItem</dt>!
410
+ end
411
+
412
+
413
+ def test_html__writable_02
414
+ # (find-filez "tagify02-before.html tagify02.html")
415
+ scriptdir = Dir.scriptdir
416
+ @before_html = "#{scriptdir}/tagify02-before.html"
417
+ @tagify_html = "#{scriptdir}/tagify02.html"
418
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
419
+ @x = HTML.new(:HTML=>@tagify_html, :title=>"HTML document")
420
+
421
+ # implies `@x.tagify'
422
+ check_link <<XXX
423
+ # = HeadLine1 (with new line) \t(lh-w3m nil "file://#{@tagify_html}#0001")
424
+ # == HeadLine2\t(lh-w3m nil "file://#{@tagify_html}#0002")
425
+ # : DescListItem\t(lh-w3m nil "file://#{@tagify_html}#0003")
426
+ XXX
427
+ end
428
+
429
+
430
+
431
+ def test_html__not_writable
432
+ # (find-filez "tagify01-before.html")
433
+ $langhelp_home = Dir.tmpdir # GLOBAL
434
+ scriptdir = Dir.scriptdir
435
+ @before_html = "#{scriptdir}/tagify01-before.html"
436
+ @tagify_html = "#{scriptdir}/tagify01-not-writable.html"
437
+ @output_html = "#{$langhelp_home}#{scriptdir}/tagify01-not-writable.html"
438
+ FileUtils.rm_f @tagify_html
439
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
440
+ FileUtils.chmod 0400, @tagify_html # not writable
441
+ @x = HTML.new(:HTML=>@tagify_html, :title=>"HTML document")
442
+
443
+ # implies `@x.tagify'
444
+ check_link <<XXX
445
+ # Title: Test & HTML\t(lh-w3m nil "file://#{@output_html}")
446
+ # = HeadLine1\t(lh-w3m nil "file://#{@output_html}#0001")
447
+ # == HeadLine2\t(lh-w3m nil "file://#{@output_html}#0002")
448
+ # : DescListItem\t(lh-w3m nil "file://#{@output_html}#0003")
449
+ XXX
450
+
451
+ htmlsrc = File.read @output_html
452
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
453
+ assert htmlsrc !~ /meta.+charset/i
454
+ assert htmlsrc =~ %r!<h1><a name="0001"></a>HeadLine1</h1>!
455
+ assert htmlsrc =~ %r!<h2><a name="0002"></a>HeadLine2</h2>!
456
+ assert htmlsrc =~ %r!<dt><a name="0003"></a>DescListItem</dt>!
457
+ end
458
+
459
+ def test_html__writable_multiple
460
+ # (find-filez "tagify01-before.html tagify01.html")
461
+ scriptdir = Dir.scriptdir
462
+ @before_html = "#{scriptdir}/tagify01-before.html"
463
+ @tagify_html = "#{scriptdir}/tagify01.html"
464
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
465
+ @before_html = "#{scriptdir}/tagify02-before.html"
466
+ @tagify_html = "#{scriptdir}/tagify02.html"
467
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
468
+
469
+ @x = HTML.new(:HTML=>[["#{scriptdir}/tagify01.ht*"],"#{scriptdir}/tagify02.html"], :title=>"HTML document")
470
+ @x.tagify
471
+
472
+ htmlsrc = File.read "#{scriptdir}/tagify01.html"
473
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
474
+
475
+ htmlsrc = File.read "#{scriptdir}/tagify02.html"
476
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
477
+
478
+ end
479
+
480
+
481
+ def test_html__writable_next
482
+ # (find-filez "tagify01-before.html tagify01.html")
483
+ # (find-filez "tagify02-before.html tagify02.html")
484
+ scriptdir = Dir.scriptdir
485
+ @before_html = "#{scriptdir}/tagify01-before.html"
486
+ @tagify_html = html01 = "#{scriptdir}/tagify01.html"
487
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
488
+ @before_html = "#{scriptdir}/tagify02-before.html"
489
+ @tagify_html = html02 = "#{scriptdir}/tagify02.html"
490
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
491
+
492
+ @x = HTML.new(:HTML=>"#{scriptdir}/tagify01.html", :title=>"HTML document", :recursive=>:next)
493
+ check_link <<XXX
494
+ # Title: Test & HTML\t(lh-w3m nil "file://#{html01}")
495
+ # = HeadLine1\t(lh-w3m nil "file://#{html01}#0001")
496
+ # == HeadLine2\t(lh-w3m nil "file://#{html01}#0002")
497
+ # : DescListItem\t(lh-w3m nil "file://#{html01}#0003")
498
+ # = HeadLine1 (with new line) \t(lh-w3m nil "file://#{html02}#0001")
499
+ # == HeadLine2\t(lh-w3m nil "file://#{html02}#0002")
500
+ # : DescListItem\t(lh-w3m nil "file://#{html02}#0003")
501
+ XXX
502
+
503
+ htmlsrc = File.read "#{scriptdir}/tagify01.html"
504
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
505
+
506
+ htmlsrc = File.read "#{scriptdir}/tagify02.html"
507
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
508
+
509
+ end
510
+
511
+ def test_html__japanese
512
+ # (find-filez "tagify-japanese-before.html tagify-japanese.html")
513
+ scriptdir = Dir.scriptdir
514
+ @before_html = "#{scriptdir}/tagify-japanese-before.html"
515
+ @tagify_html = "#{scriptdir}/tagify-japanese.html"
516
+
517
+ FileUtils.cp @before_html, @tagify_html # because @x overwrites HTML file
518
+ @x = HTML.new(:HTML=>@tagify_html, :title=>"HTML document", :conf=>{:ENCODING=>:euc_jp})
519
+
520
+ # implies `@x.tagify'
521
+ check_link <<XXX
522
+ # Title: Test & HTML\t(lh-w3m nil "file://#{@tagify_html}")
523
+ # = �縫�Ф�\t(lh-w3m nil "file://#{@tagify_html}#0001")
524
+ # == �渫�Ф�\t(lh-w3m nil "file://#{@tagify_html}#0002")
525
+ # : �Ѹ�\t(lh-w3m nil "file://#{@tagify_html}#0003")
526
+ XXX
527
+
528
+ htmlsrc = File.read @tagify_html
529
+ assert htmlsrc =~ /<!-- Tagified by langhelp -->/
530
+ assert htmlsrc !~ /meta.+charset/i
531
+ assert htmlsrc =~ %r!<h1><a name="0001"></a>�縫�Ф�</h1>!
532
+ assert htmlsrc =~ %r!<h2><a name="0002"></a>�渫�Ф�</h2>!
533
+ assert htmlsrc =~ %r!<dt><a name="0003"></a>�Ѹ�</dt>!
534
+ end
535
+
536
+
537
+
538
+ end