hikidoc 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 27cec17d6692baec7703efada8f3797f70bcbf17
4
+ data.tar.gz: 032cab997e685c3330942506f263bc2e0616d49a
5
+ SHA512:
6
+ metadata.gz: 824abf9b36727cefb838c1b29b5548b0c2d1f21d5e1823f6e9fa17e1bcc4c37489e6e72d5b91b32ff4d25c3dc1f3f32632374641f98adeade01d550b2cf5add1
7
+ data.tar.gz: 57aad57567d009f90f3dcc5e109a00436b608ddba285f9f63bb22f22ee4793081c6b8173d06dd74b9a0fd73dd10a06905af6183cb020e8c28f19a30bb594cf5f
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hikidoc.gemspec
4
+ gemspec
data/NEWS ADDED
@@ -0,0 +1,30 @@
1
+ ! NEWS
2
+
3
+ !! Changes 0.0.6 from 0.0.5: 2010-08-28
4
+
5
+ * fix missing NEWS.ja for packaging
6
+
7
+ !! Changes 0.0.5 from 0.0.4: 2010-08-26
8
+
9
+ * fix a bug: strings after non-WikiName expression are ignored
10
+ * new text decoration ``monospaced text``
11
+ * fix rake failure with Hoe 1.9.0 or later
12
+ * add syntax highlighting with google-code-prettify
13
+
14
+ !! Changes 0.0.4 from 0.0.3: 2009-08-17
15
+
16
+ * escape collectly in inline_plugin same as block_plugin does.
17
+ * fix a DoS vulnerability processing a plugin expression.
18
+
19
+ !! Changes 0.0.3 from 0.0.2: 2008-08-25
20
+
21
+ * fix warning message "Could not find main page README.txt" at installation via gem
22
+
23
+ !! Changes 0.0.2 from 0.0.1: 2008-08-11
24
+
25
+ * fix a bug: an inline that is inside of a modifier inline do not works
26
+ * add a option "--no-wikiname" to `hikidoc' command
27
+ * correct URI scheme behavior of InterWikiName
28
+ * add some tests
29
+ * add a Rake task "coverage" (requires rcov)
30
+
data/NEWS.ja ADDED
@@ -0,0 +1,30 @@
1
+ ! NEWS.ja
2
+
3
+ !! 0.0.5����0.0.6���ѹ���: 2010-08-28
4
+
5
+ * �ѥå���������NEWS.ja��ϳ��Ƥ��ޤ��Τ���
6
+
7
+ !! 0.0.4����0.0.5���ѹ���: 2010-08-26
8
+
9
+ * Ʊ��Ԥ˴ޤޤ����WikiNameɽ���ʹߤ�ʸ�������Ϥ���ʤ��Х�����
10
+ * ������ʸ���ν���``����ɽ��``���ɲ�
11
+ * Hoe 1.9.0 �ޤ��Ϥ���ʹߤ�rake�����Ԥ����������
12
+ * google-code-prettify�ǤΥ��󥿥å����ϥ��饤�Ȥ��ɲ�
13
+
14
+ !! 0.0.3����0.0.4���ѹ���: 2009-08-17
15
+
16
+ * inline_plugin��block_pluginƱ�ͤ˥��������פ���褦�˽���
17
+ * �ץ饰����ɽ���β��ˤ�����DoS�ȼ������Ф��뽤��
18
+
19
+ !! 0.0.2����0.0.3���ѹ���: 2008-08-25
20
+
21
+ * gem����Υ��󥹥ȡ������"Could not find main page README.txt"�Ȥ����ٹ��å����������Ϥ����������
22
+
23
+ !! 0.0.1����0.0.2���ѹ���: 2008-08-11
24
+
25
+ * �����ϥ���饤����Υ���饤��ˡ��Ÿ������ʤ��Х�����
26
+ * hikidoc���ޥ�ɤ�--no-wikiname���ץ������ɲ�
27
+ * InterWikiName��URI scheme�Ȥ��ư�����Τ�http(s),file,ftp�˸��ꤹ��褦����
28
+ * �ƥ��Ȥ򶯲�
29
+ * Rake������coverage���ɲá���rcov��
30
+
data/README CHANGED
@@ -51,6 +51,7 @@ The following softwares use the HikiDoc library or the HikiDoc format.
51
51
  :[[lily|http://lily.sourceforge.jp/]]:a simple CMS
52
52
  :[[Text::HikiDoc|http://search.cpan.org/perldoc?Text::HikiDoc]]:HikiDoc by Perl
53
53
  :[[PikiDoc|http://github.com/moro/piki_doc/]]:a library that you can add plugin functions on HikiDoc
54
+ :[[mail2weblog|http://sourceforge.jp/projects/mail2weblog/wiki/FrontPage]]:a blog system via mobile phone email
54
55
 
55
56
  !! License
56
57
 
data/README.ja CHANGED
@@ -48,6 +48,7 @@ Subversion
48
48
  :[[lily|http://lily.sourceforge.jp/]]:����ץ�� CMS (Web �����ȹ��ۥ����ƥ�)
49
49
  :[[Text::HikiDoc|http://search.cpan.org/perldoc?Text::HikiDoc]]:Perl �ˤ�� HikiDoc �μ���
50
50
  :[[PikiDoc|http://github.com/moro/piki_doc/]]:HikiDoc�Ρ֥ץ饰����׵�ǽ���ɲäǤ���饤�֥��Ǥ�
51
+ :[[mail2weblog|http://sourceforge.jp/projects/mail2weblog/wiki/FrontPage]]:�ⵡǽ�᡼����Ʒ���֥���
51
52
 
52
53
  !! �饤����
53
54
 
data/Rakefile CHANGED
@@ -1,84 +1,8 @@
1
- # -*- ruby -*-
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
2
3
 
3
- require 'rubygems'
4
- require 'hoe'
5
-
6
- require 'find'
7
-
8
- base_dir = File.expand_path(File.dirname(__FILE__))
9
- $LOAD_PATH.unshift(File.join(base_dir, 'lib'))
10
- require 'hikidoc'
11
-
12
- truncate_base_dir = Proc.new do |x|
13
- x.gsub(/\A#{Regexp.escape(base_dir + File::SEPARATOR)}/, '')
14
- end
15
-
16
- manifest = File.join(base_dir, "Manifest.txt")
17
- manifest_contents = []
18
- base_dir_included_components = %w(COPYING README README.ja Rakefile
19
- TextFormattingRules TextFormattingRules.ja
20
- setup.rb)
21
- excluded_components = %w(.svn doc log pkg)
22
- Find.find(base_dir) do |target|
23
- target = truncate_base_dir[target]
24
- components = target.split(File::SEPARATOR)
25
- if components.size == 1 and !File.directory?(target)
26
- next unless base_dir_included_components.include?(components[0])
27
- end
28
- Find.prune if (excluded_components - components) != excluded_components
29
- manifest_contents << target if File.file?(target)
30
- end
31
-
32
- File.open(manifest, "w") do |f|
33
- f.puts manifest_contents.sort.join("\n")
34
- end
35
- at_exit do
36
- FileUtils.rm_f(manifest)
37
- end
38
-
39
- ENV["VERSION"] ||= HikiDoc::VERSION
40
- project = Hoe.new('hikidoc', HikiDoc::VERSION) do |project|
41
- project.author = ['Kazuhiko']
42
- project.email = ['kazuhiko@fdiary.net']
43
- project.description = project.paragraphs_of('README', 2).join
44
- project.summary = project.description.split(/(\.)/, 3)[0, 2].join
45
- project.url = 'http://rubyforge.org/projects/hikidoc/'
46
- project.test_globs = ['test/test_*.rb']
47
- project.rdoc_pattern = /(?:^(?:lib|bin)|\AREADME\z)/
48
- project.changes = File.read("NEWS").split(/^!! .*$/)[1].strip
49
- end
50
-
51
- desc 'Tag the repository for release.'
52
- task :tag do
53
- version = HikiDoc::VERSION
54
- message = "Released HikiDoc #{version}!"
55
- base = "svn+ssh://rubyforge.org/var/svn/hikidoc/"
56
- sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
57
- end
58
-
59
- begin
60
- require 'rcov/rcovtask'
61
-
62
- desc "Analyze code coverage of the unit tests."
63
- Rcov::RcovTask.new(:coverage) do |t|
64
- t.test_files = FileList[project.test_globs]
65
- t.verbose = true
66
- t.rcov_opts << "--text-report"
67
- begin
68
- require "rubygems"
69
- t.rcov_opts << "--exclude=^#{Regexp.escape(Gem.dir)}"
70
- rescue LoadError
71
- end
72
- end
73
- rescue LoadError
74
- end
75
-
76
-
77
- # Fix Hoe's uncustomizable options
78
- rdoc_main = "lib/hikidoc.rb"
79
- project.spec.rdoc_options.each do |option|
80
- option.replace(rdoc_main) if option == "README.txt"
81
- end
82
- ObjectSpace.each_object(Rake::RDocTask) do |task|
83
- task.main = rdoc_main if task.main == "README.txt"
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ t.verbose = true
84
8
  end
@@ -126,17 +126,21 @@ Text surrounded by sets of three single quotes (''') is strongly emphasised.
126
126
 
127
127
  Text surrounded by sets of double equal signs (===) is struck out.
128
128
 
129
+ Text surrounded by sets of double backquotes (``) is inline literal.
130
+
129
131
  *Example statement
130
132
 
131
133
  If you write like this, it becomes ''emphasised''.
132
134
  And if you write like this, it becomes '''strongly emphasised'''.
133
135
  ==This is dull, but== And struck-out text is supported, too!
136
+ If you write like this, it becomes ``monospaced text``.
134
137
 
135
138
  *Example output
136
139
 
137
140
  If you write like this, it becomes ''emphasised''.
138
141
  And if you write like this, it becomes '''strongly emphasised'''.
139
142
  ==This is dull, but== And struck-out text is supported, too!
143
+ If you write like this, it becomes ``monospaced text``.
140
144
 
141
145
  !Headings
142
146
 
@@ -126,17 +126,21 @@ http://jp.rubyist.net/theme/clover/clover_h1.png
126
126
 
127
127
  ��=��2�ĤǤϤ������ʬ�ϼ�����ˤʤ�ޤ���
128
128
 
129
+ ��`��2�ĤǤϤ������ʬ������ɽ���ˤʤ�ޤ���
130
+
129
131
  *������
130
132
 
131
133
  ���Τ褦�ˤ����''��Ĵ''�ˤʤ�ޤ���
132
134
  �����ơ����Τ褦�ˤ����'''����˶�Ĵ'''����ޤ���
133
135
  ==���뤤����==����ˡ����ä����⥵�ݡ��Ȥ��Ƥ��ޤ���
136
+ �ޤ��ޤ������Τ褦�ˤ����''����ɽ��''�ˤʤ�ޤ���
134
137
 
135
138
  *������
136
139
 
137
140
  ���Τ褦�ˤ����''��Ĵ''�ˤʤ�ޤ���
138
141
  �����ơ����Τ褦�ˤ����'''����˶�Ĵ'''����ޤ���
139
142
  ==���뤤����==����ˡ����ä����⥵�ݡ��Ȥ��Ƥ��ޤ���
143
+ �ޤ��ޤ������Τ褦�ˤ����''����ɽ��''�ˤʤ�ޤ���
140
144
 
141
145
  !���Ф�
142
146
 
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hikidoc'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hikidoc"
8
+ spec.version = HikiDoc::VERSION
9
+ spec.authors = ['Kazuhiko', "SHIBATA Hiroshi"]
10
+ spec.email = ['kazuhiko@fdiary.net', "shibata.hiroshi@gmail.com"]
11
+ spec.description = %q{'HikiDoc' is a text-to-HTML conversion tool for web writers.}
12
+ spec.summary = %q{'HikiDoc' is a text-to-HTML conversion tool for web writers. HikiDoc allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid HTML (or XHTML).}
13
+ spec.homepage = "https://github.com/hiki/hikidoc"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8; -*-
1
+ # -*- coding: utf-8 -*-
2
2
  # Copyright (c) 2005, Kazuhiko <kazuhiko@fdiary.net>
3
3
  # Copyright (c) 2007 Minero Aoki
4
4
  # All rights reserved.
@@ -38,7 +38,7 @@ rescue LoadError
38
38
  end
39
39
 
40
40
  class HikiDoc
41
- VERSION = "0.0.4" # FIXME
41
+ VERSION = "0.0.6" # FIXME
42
42
 
43
43
  class Error < StandardError
44
44
  end
@@ -408,7 +408,7 @@ class HikiDoc
408
408
 
409
409
  link, uri, mod, wiki_name = m[1, 4]
410
410
  if wiki_name and wiki_name[0, 1] == "^"
411
- pending_str = m.pre_match + wiki_name[1..-1]
411
+ pending_str = m.pre_match + wiki_name[1..-1] + str
412
412
  next
413
413
  end
414
414
 
@@ -437,7 +437,7 @@ class HikiDoc
437
437
  end
438
438
 
439
439
  def compile_bracket_link(link)
440
- if m = /\A(?>[^|\\]+|\\.)*\|/.match(link)
440
+ if m = /\A(.*)\|/.match(link)
441
441
  title = m[0].chop
442
442
  uri = m.post_match
443
443
  fixed_uri = fix_uri(uri)
@@ -479,23 +479,26 @@ class HikiDoc
479
479
  IMAGE_EXTS = %w(.jpg .jpeg .gif .png)
480
480
 
481
481
  def image?(uri)
482
- IMAGE_EXTS.include?(File.extname(uri).downcase)
482
+ IMAGE_EXTS.include?(uri[/\.[^.]+\z/].to_s.downcase)
483
483
  end
484
484
 
485
485
  STRONG = "'''"
486
486
  EM = "''"
487
487
  DEL = "=="
488
+ TT = "``"
488
489
 
489
490
  STRONG_RE = /'''.+?'''/
490
491
  EM_RE = /''.+?''/
491
492
  DEL_RE = /==.+?==/
493
+ TT_RE = /``.+?``/
492
494
 
493
- MODIFIER_RE = Regexp.union(STRONG_RE, EM_RE, DEL_RE)
495
+ MODIFIER_RE = Regexp.union(STRONG_RE, EM_RE, DEL_RE, TT_RE)
494
496
 
495
497
  MODTAG = {
496
498
  STRONG => "strong",
497
499
  EM => "em",
498
- DEL => "del"
500
+ DEL => "del",
501
+ TT => 'tt'
499
502
  }
500
503
 
501
504
  def compile_modifier(str)
@@ -525,6 +528,8 @@ class HikiDoc
525
528
  return str[0, 2], str[2...-2]
526
529
  when /\A==/
527
530
  return str[0, 2], str[2...-2]
531
+ when /\A``/
532
+ return str[0, 2], str[2...-2]
528
533
  else
529
534
  raise UnexpectedError, "must not happen: #{str.inspect}"
530
535
  end
@@ -673,6 +678,8 @@ class HikiDoc
673
678
  @f.puts convertor.convert(str)
674
679
  return
675
680
  rescue NameError, RuntimeError
681
+ @f.puts %Q|<pre class="prettyprint">#{text(str)}</pre>|
682
+ return
676
683
  end
677
684
  end
678
685
  preformatted(text(str))
@@ -722,6 +729,10 @@ class HikiDoc
722
729
  "<del>#{item}</del>"
723
730
  end
724
731
 
732
+ def tt(item)
733
+ "<tt>#{item}</tt>"
734
+ end
735
+
725
736
  def text(str)
726
737
  escape_html(str)
727
738
  end
@@ -226,6 +226,8 @@ TEST}}
226
226
  "[[Hiki|http:hikiwiki.html]]")
227
227
  assert_convert(%Q|<p><img src="http://hikiwiki.org/img.png" alt="img.png" /></p>\n|,
228
228
  "http://hikiwiki.org/img.png")
229
+ assert_convert(%Q|<p><img src="http://hikiwiki.org:80/img.png" alt="img.png" /></p>\n|,
230
+ "http://hikiwiki.org:80/img.png")
229
231
  assert_convert(%Q|<p><a href="http://hikiwiki.org/ja/?c=edit;p=Test">| +
230
232
  %Q|http://hikiwiki.org/ja/?c=edit;p=Test</a></p>\n|,
231
233
  "http://hikiwiki.org/ja/?c=edit;p=Test")
@@ -246,6 +248,8 @@ TEST}}
246
248
  "[[&]]")
247
249
  assert_convert(%Q|<p><a href="aa">aa</a>bb<a href="cc">cc</a></p>\n|,
248
250
  "[[aa]]bb[[cc]]")
251
+ assert_convert(%Q!<p><a href="aa">a|a</a></p>\n!,
252
+ "[[a|a|aa]]")
249
253
  end
250
254
 
251
255
  def test_inter_wiki_name
@@ -295,6 +299,8 @@ TEST}}
295
299
  "^WikiName",
296
300
  :use_wiki_name => false,
297
301
  :use_not_wiki_name => false)
302
+ assert_convert("<p>foo WikiName bar</p>\n",
303
+ "foo ^WikiName bar")
298
304
  end
299
305
 
300
306
  def test_use_wiki_name_option
@@ -359,6 +365,9 @@ TEST}}
359
365
  assert_convert("<dl>\n<dt>foo</dt>\n" +
360
366
  "<dd><strong>bar</strong></dd>\n</dl>\n",
361
367
  ":foo:'''bar'''")
368
+ assert_convert("<dl>\n<dt>foo</dt>\n" +
369
+ "<dd><tt>bar</tt></dd>\n</dl>\n",
370
+ ":foo:``bar``")
362
371
  end
363
372
 
364
373
  def test_definition_with_modifier_link
@@ -370,6 +379,10 @@ TEST}}
370
379
  "<strong><a href=\"http://hikiwiki.org/\">Hiki</a></strong>" +
371
380
  "</dd>\n</dl>\n",
372
381
  ":Website:'''[[Hiki|http://hikiwiki.org/]]'''")
382
+ assert_convert("<dl>\n<dt>Website</dt>\n<dd>" +
383
+ "<tt><a href=\"http://hikiwiki.org/\">Hiki</a></tt>" +
384
+ "</dd>\n</dl>\n",
385
+ ":Website:``[[Hiki|http://hikiwiki.org/]]``")
373
386
  end
374
387
 
375
388
  def test_table
@@ -409,6 +422,10 @@ TEST}}
409
422
  "'''foo''' and '''bar'''")
410
423
  assert_convert("<p><em>foo</em> and <em>bar</em></p>\n",
411
424
  "''foo'' and ''bar''")
425
+ assert_convert("<p><tt>foo</tt></p>\n",
426
+ "``foo``")
427
+ assert_convert("<p><tt>foo==bar</tt>baz==</p>\n",
428
+ "``foo==bar``baz==")
412
429
  end
413
430
 
414
431
  def test_nested_modifier
@@ -423,6 +440,8 @@ TEST}}
423
440
  "[['''Hiki'''|http://hikiwiki.org/]]")
424
441
  assert_convert("<p><strong><a href=\"http://hikiwiki.org/\">Hiki</a></strong></p>\n",
425
442
  "'''[[Hiki|http://hikiwiki.org/]]'''")
443
+ assert_convert("<p><tt><a href=\"http://hikiwiki.org/\">Hiki</a></tt></p>\n",
444
+ "``[[Hiki|http://hikiwiki.org/]]``")
426
445
  end
427
446
 
428
447
  def test_pre_and_plugin
@@ -437,18 +456,34 @@ TEST}}
437
456
  def test_plugin_in_modifier
438
457
  assert_convert("<p><strong><span class=\"plugin\">{{foo}}</span></strong></p>\n",
439
458
  "'''{{foo}}'''")
459
+ assert_convert("<p><tt><span class=\"plugin\">{{foo}}</span></tt></p>\n",
460
+ "``{{foo}}``")
440
461
  end
441
462
 
442
- if Object.const_defined?(:Syntax)
443
-
444
- def test_syntax_ruby
463
+ def test_syntax_ruby
464
+ if Object.const_defined?(:Syntax)
445
465
  assert_convert("<pre><span class=\"keyword\">class </span><span class=\"class\">A</span>\n <span class=\"keyword\">def </span><span class=\"method\">foo</span><span class=\"punct\">(</span><span class=\"ident\">bar</span><span class=\"punct\">)</span>\n <span class=\"keyword\">end</span>\n<span class=\"keyword\">end</span></pre>\n",
446
466
  "<<< ruby\nclass A\n def foo(bar)\n end\nend\n>>>")
447
467
  assert_convert("<pre><span class=\"keyword\">class </span><span class=\"class\">A</span>\n <span class=\"keyword\">def </span><span class=\"method\">foo</span><span class=\"punct\">(</span><span class=\"ident\">bar</span><span class=\"punct\">)</span>\n <span class=\"keyword\">end</span>\n<span class=\"keyword\">end</span></pre>\n",
448
468
  "<<< Ruby\nclass A\n def foo(bar)\n end\nend\n>>>")
449
469
  assert_convert("<pre><span class=\"punct\">'</span><span class=\"string\">a&lt;&quot;&gt;b</span><span class=\"punct\">'</span></pre>\n",
450
470
  "<<< ruby\n'a<\">b'\n>>>")
471
+
472
+ # redefine method for below tests
473
+ class << Syntax::Convertors::HTML
474
+ def for_syntax(syntax)
475
+ raise
476
+ end
477
+ end
451
478
  end
479
+
480
+ # use google-code-prettify
481
+ assert_convert("<pre class=\"prettyprint\">class A\n def foo(bar)\n end\nend</pre>\n",
482
+ "<<< ruby\nclass A\n def foo(bar)\n end\nend\n>>>")
483
+ assert_convert("<pre class=\"prettyprint\">class A\n def foo(bar)\n end\nend</pre>\n",
484
+ "<<< Ruby\nclass A\n def foo(bar)\n end\nend\n>>>")
485
+ assert_convert("<pre class=\"prettyprint\">'a&lt;\"&gt;b'</pre>\n",
486
+ "<<< ruby\n'a<\">b'\n>>>")
452
487
  end
453
488
 
454
489
  def test_plugin_in_pre_with_header