tdiary 3.2.2.20130518 → 3.2.2.20130527

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +17 -11
  4. data/Rakefile +2 -0
  5. data/config.ru +2 -1
  6. data/tdiary.gemspec +7 -0
  7. data/tdiary.rb +6 -2
  8. data/tdiary/cli.rb +27 -1
  9. data/tdiary/environment.rb +0 -1
  10. data/tdiary/tasks/release.rake +7 -1
  11. data/tdiary/version.rb +1 -1
  12. metadata +87 -132
  13. data/vendor/hikidoc-0.0.6/COPYING +0 -28
  14. data/vendor/hikidoc-0.0.6/NEWS +0 -30
  15. data/vendor/hikidoc-0.0.6/NEWS.ja +0 -30
  16. data/vendor/hikidoc-0.0.6/README +0 -86
  17. data/vendor/hikidoc-0.0.6/README.ja +0 -83
  18. data/vendor/hikidoc-0.0.6/Rakefile +0 -68
  19. data/vendor/hikidoc-0.0.6/TextFormattingRules +0 -320
  20. data/vendor/hikidoc-0.0.6/TextFormattingRules.ja +0 -318
  21. data/vendor/hikidoc-0.0.6/bin/hikidoc +0 -66
  22. data/vendor/hikidoc-0.0.6/lib/hikidoc.rb +0 -914
  23. data/vendor/hikidoc-0.0.6/setup.rb +0 -1360
  24. data/vendor/hikidoc-0.0.6/test/run-test.rb +0 -13
  25. data/vendor/hikidoc-0.0.6/test/test_hikidoc.rb +0 -506
  26. data/vendor/imagesize-0.1.1/Manifest.txt +0 -19
  27. data/vendor/imagesize-0.1.1/README.txt +0 -49
  28. data/vendor/imagesize-0.1.1/lib/image_size.rb +0 -305
  29. data/vendor/imagesize-0.1.1/lib/image_size/version.rb +0 -9
  30. data/vendor/imagesize-0.1.1/setup.rb +0 -1585
  31. data/vendor/imagesize-0.1.1/test/2-4-7.png +0 -0
  32. data/vendor/imagesize-0.1.1/test/4_1_2.gif +0 -0
  33. data/vendor/imagesize-0.1.1/test/bmp.bmp +0 -0
  34. data/vendor/imagesize-0.1.1/test/cursor.xbm +0 -6
  35. data/vendor/imagesize-0.1.1/test/detect.swf +0 -0
  36. data/vendor/imagesize-0.1.1/test/pbm.pbm +0 -0
  37. data/vendor/imagesize-0.1.1/test/pcx.pcx +0 -0
  38. data/vendor/imagesize-0.1.1/test/pgm.pgm +0 -5
  39. data/vendor/imagesize-0.1.1/test/test.xpm +0 -38
  40. data/vendor/imagesize-0.1.1/test/test_helper.rb +0 -2
  41. data/vendor/imagesize-0.1.1/test/test_image_size.rb +0 -71
  42. data/vendor/imagesize-0.1.1/test/tiff.tiff +0 -0
  43. data/vendor/imagesize-0.1.1/test/tokyo_tower.jpg +0 -0
  44. data/vendor/imagesize-0.1.1/test/tower_e.gif.psd +0 -0
  45. data/vendor/rdtool-0.6.38/COPYING.txt +0 -339
  46. data/vendor/rdtool-0.6.38/Gemfile +0 -3
  47. data/vendor/rdtool-0.6.38/HISTORY +0 -318
  48. data/vendor/rdtool-0.6.38/LGPL-2.1 +0 -502
  49. data/vendor/rdtool-0.6.38/LICENSE.txt +0 -58
  50. data/vendor/rdtool-0.6.38/README.html +0 -66
  51. data/vendor/rdtool-0.6.38/README.ja.html +0 -73
  52. data/vendor/rdtool-0.6.38/README.rd +0 -76
  53. data/vendor/rdtool-0.6.38/README.rd.ja +0 -85
  54. data/vendor/rdtool-0.6.38/Rakefile +0 -152
  55. data/vendor/rdtool-0.6.38/TODO +0 -22
  56. data/vendor/rdtool-0.6.38/bin/rd2 +0 -283
  57. data/vendor/rdtool-0.6.38/bin/rdswap.rb +0 -207
  58. data/vendor/rdtool-0.6.38/doc/rd-draft.html +0 -456
  59. data/vendor/rdtool-0.6.38/doc/rd-draft.ja.html +0 -466
  60. data/vendor/rdtool-0.6.38/doc/rd-draft.rd +0 -479
  61. data/vendor/rdtool-0.6.38/doc/rd-draft.rd.ja +0 -487
  62. data/vendor/rdtool-0.6.38/lib/rd/block-element.rb +0 -114
  63. data/vendor/rdtool-0.6.38/lib/rd/complex-list-item.rb +0 -65
  64. data/vendor/rdtool-0.6.38/lib/rd/desclist.rb +0 -55
  65. data/vendor/rdtool-0.6.38/lib/rd/document-struct.rb +0 -46
  66. data/vendor/rdtool-0.6.38/lib/rd/dot.rd2rc +0 -18
  67. data/vendor/rdtool-0.6.38/lib/rd/element.rb +0 -160
  68. data/vendor/rdtool-0.6.38/lib/rd/filter.rb +0 -255
  69. data/vendor/rdtool-0.6.38/lib/rd/head-filter.rb +0 -14
  70. data/vendor/rdtool-0.6.38/lib/rd/inline-element.rb +0 -233
  71. data/vendor/rdtool-0.6.38/lib/rd/labeled-element.rb +0 -14
  72. data/vendor/rdtool-0.6.38/lib/rd/list.rb +0 -57
  73. data/vendor/rdtool-0.6.38/lib/rd/loose-struct.rb +0 -11
  74. data/vendor/rdtool-0.6.38/lib/rd/methodlist.rb +0 -57
  75. data/vendor/rdtool-0.6.38/lib/rd/output-format-visitor.rb +0 -30
  76. data/vendor/rdtool-0.6.38/lib/rd/package.rb +0 -4
  77. data/vendor/rdtool-0.6.38/lib/rd/parser-util.rb +0 -14
  78. data/vendor/rdtool-0.6.38/lib/rd/post-install +0 -1
  79. data/vendor/rdtool-0.6.38/lib/rd/pre-setup.rb +0 -18
  80. data/vendor/rdtool-0.6.38/lib/rd/rbl-file.rb +0 -69
  81. data/vendor/rdtool-0.6.38/lib/rd/rbl-suite.rb +0 -37
  82. data/vendor/rdtool-0.6.38/lib/rd/rd-struct.rb +0 -86
  83. data/vendor/rdtool-0.6.38/lib/rd/rd2html-ext-lib.rb +0 -266
  84. data/vendor/rdtool-0.6.38/lib/rd/rd2html-ext-opt.rb +0 -34
  85. data/vendor/rdtool-0.6.38/lib/rd/rd2html-lib.rb +0 -490
  86. data/vendor/rdtool-0.6.38/lib/rd/rd2html-opt.rb +0 -67
  87. data/vendor/rdtool-0.6.38/lib/rd/rd2man-lib.rb +0 -251
  88. data/vendor/rdtool-0.6.38/lib/rd/rd2rdo-lib.rb +0 -19
  89. data/vendor/rdtool-0.6.38/lib/rd/rd2rmi-lib.rb +0 -32
  90. data/vendor/rdtool-0.6.38/lib/rd/rdblockparser.ry +0 -518
  91. data/vendor/rdtool-0.6.38/lib/rd/rdblockparser.tab.rb +0 -1061
  92. data/vendor/rdtool-0.6.38/lib/rd/rdfmt.rb +0 -15
  93. data/vendor/rdtool-0.6.38/lib/rd/rdinlineparser.ry +0 -503
  94. data/vendor/rdtool-0.6.38/lib/rd/rdinlineparser.tab.rb +0 -1243
  95. data/vendor/rdtool-0.6.38/lib/rd/rdvisitor.rb +0 -214
  96. data/vendor/rdtool-0.6.38/lib/rd/reference-resolver.rb +0 -114
  97. data/vendor/rdtool-0.6.38/lib/rd/search-file.rb +0 -14
  98. data/vendor/rdtool-0.6.38/lib/rd/tree.rb +0 -103
  99. data/vendor/rdtool-0.6.38/lib/rd/version.rb +0 -41
  100. data/vendor/rdtool-0.6.38/lib/rd/visitor.rb +0 -86
  101. data/vendor/rdtool-0.6.38/rdtool.gemspec +0 -125
  102. data/vendor/rdtool-0.6.38/setup.rb +0 -1596
  103. data/vendor/rdtool-0.6.38/test/data/includee1.html +0 -1
  104. data/vendor/rdtool-0.6.38/test/data/includee2.html +0 -1
  105. data/vendor/rdtool-0.6.38/test/data/includee3.nothtml +0 -1
  106. data/vendor/rdtool-0.6.38/test/data/includee4.xhtml +0 -0
  107. data/vendor/rdtool-0.6.38/test/data/label.rbl +0 -2
  108. data/vendor/rdtool-0.6.38/test/data/label2.rbl +0 -2
  109. data/vendor/rdtool-0.6.38/test/data/sub/includee2.html +0 -1
  110. data/vendor/rdtool-0.6.38/test/data/sub/includee4.html +0 -0
  111. data/vendor/rdtool-0.6.38/test/dummy-observer.rb +0 -6
  112. data/vendor/rdtool-0.6.38/test/dummy.rb +0 -33
  113. data/vendor/rdtool-0.6.38/test/temp-dir.rb +0 -19
  114. data/vendor/rdtool-0.6.38/test/test-block-parser.rb +0 -46
  115. data/vendor/rdtool-0.6.38/test/test-desclist-item.rb +0 -219
  116. data/vendor/rdtool-0.6.38/test/test-document-element.rb +0 -46
  117. data/vendor/rdtool-0.6.38/test/test-document-struct.rb +0 -66
  118. data/vendor/rdtool-0.6.38/test/test-element.rb +0 -46
  119. data/vendor/rdtool-0.6.38/test/test-headline.rb +0 -80
  120. data/vendor/rdtool-0.6.38/test/test-inline-parser.rb +0 -46
  121. data/vendor/rdtool-0.6.38/test/test-list-item.rb +0 -54
  122. data/vendor/rdtool-0.6.38/test/test-list.rb +0 -53
  123. data/vendor/rdtool-0.6.38/test/test-methodlist-item.rb +0 -73
  124. data/vendor/rdtool-0.6.38/test/test-nonterminal-element.rb +0 -170
  125. data/vendor/rdtool-0.6.38/test/test-nonterminal-inline.rb +0 -33
  126. data/vendor/rdtool-0.6.38/test/test-output-format-visitor.rb +0 -48
  127. data/vendor/rdtool-0.6.38/test/test-parser-util.rb +0 -41
  128. data/vendor/rdtool-0.6.38/test/test-rbl-file.rb +0 -156
  129. data/vendor/rdtool-0.6.38/test/test-rbl-suite.rb +0 -43
  130. data/vendor/rdtool-0.6.38/test/test-rd2html-lib.rb +0 -496
  131. data/vendor/rdtool-0.6.38/test/test-rdtree.rb +0 -17
  132. data/vendor/rdtool-0.6.38/test/test-rdvisitor.rb +0 -29
  133. data/vendor/rdtool-0.6.38/test/test-reference-resolver.rb +0 -202
  134. data/vendor/rdtool-0.6.38/test/test-reference.rb +0 -132
  135. data/vendor/rdtool-0.6.38/test/test-search-file.rb +0 -22
  136. data/vendor/rdtool-0.6.38/test/test-terminal-inline.rb +0 -41
  137. data/vendor/rdtool-0.6.38/test/test-textblock.rb +0 -44
  138. data/vendor/rdtool-0.6.38/test/test-tree.rb +0 -82
  139. data/vendor/rdtool-0.6.38/test/test-version.rb +0 -57
  140. data/vendor/rdtool-0.6.38/test/test-visitor.rb +0 -230
  141. data/vendor/rdtool-0.6.38/utils/rd-mode.el +0 -464
@@ -1,14 +0,0 @@
1
-
2
- module RD
3
- # interface
4
- module LabeledElement
5
- def to_label
6
- @label ||= calculate_label
7
- end
8
- alias label to_label
9
-
10
- def calculate_label
11
- raise "[BUG] must override."
12
- end
13
- end
14
- end
@@ -1,57 +0,0 @@
1
- require 'rd/block-element'
2
- require 'rd/element'
3
-
4
- module RD
5
- class List < BlockElement
6
- include NonterminalElement
7
- attr_reader :items
8
-
9
- def initialize
10
- @items = []
11
- end
12
-
13
- alias each_item each_child
14
-
15
- def children
16
- @items
17
- end
18
- end
19
-
20
- class ListItem < BlockElement
21
- include NonterminalElement
22
-
23
- attr_reader :content
24
-
25
- def initialize
26
- @content = []
27
- end
28
-
29
- alias each_block each_child
30
-
31
- def children
32
- @content
33
- end
34
- end
35
-
36
- class ItemList < List
37
- def accept(visitor)
38
- visitor.visit_ItemList(self)
39
- end
40
- end
41
- class ItemListItem < ListItem
42
- def accept(visitor)
43
- visitor.visit_ItemListItem(self)
44
- end
45
- end
46
-
47
- class EnumList < List
48
- def accept(visitor)
49
- visitor.visit_EnumList(self)
50
- end
51
- end
52
- class EnumListItem < ListItem
53
- def accept(visitor)
54
- visitor.visit_EnumListItem(self)
55
- end
56
- end
57
- end # RD
@@ -1,11 +0,0 @@
1
- require 'rd/document-struct'
2
- require 'rd/element'
3
- require 'rd/tree'
4
-
5
- module RD
6
- class DocumentStructure
7
- LOOSE = DocumentStructure.new
8
- LOOSE.define_relationship(NonterminalElement, Element)
9
- LOOSE.define_relationship(Tree, DocumentElement)
10
- end
11
- end
@@ -1,57 +0,0 @@
1
- require 'rd/element'
2
- require 'rd/list'
3
- require 'rd/complex-list-item'
4
- require 'rd/labeled-element'
5
-
6
- module RD
7
- class MethodList < List
8
- def accept(visitor)
9
- visitor.visit_MethodList(self)
10
- end
11
- end
12
-
13
- class MethodListItem < ListItem
14
- include ComplexListItem
15
-
16
- attr_reader :term
17
- attr_reader :description
18
-
19
- def initialize
20
- @term = nil
21
- @description = []
22
- end
23
-
24
- def accept(visitor)
25
- visitor.visit_MethodListItem(self)
26
- end
27
-
28
- def children
29
- @description
30
- end
31
-
32
- class Term < Element
33
- include TerminalElement
34
- include LabeledElement
35
-
36
- attr_reader :content
37
-
38
- def initialize(content = "")
39
- @content = content
40
- end
41
-
42
- def each_element
43
- yield(self)
44
- end
45
- alias each each_element
46
-
47
- def accept(visitor)
48
- visitor.visit_MethodListItemTerm(self)
49
- end
50
-
51
- def calculate_label
52
- @content.sub(/\s*(?:\(|\{).*$/, "")
53
- end
54
- private :calculate_label
55
- end
56
- end
57
- end # RD
@@ -1,30 +0,0 @@
1
- require 'rd/visitor'
2
- require 'rd/rd-struct'
3
- require 'rd/search-file'
4
-
5
- module RD
6
- class OutputFormatVisitor < Visitor
7
- include SearchFile
8
-
9
- # must-have constants
10
- OUTPUT_SUFFIX = ""
11
- INCLUDE_SUFFIX = []
12
-
13
- attr_accessor :include_suffix
14
- attr_accessor :filename
15
- attr_accessor :input_filename
16
-
17
- def initialize
18
- super
19
- @include_suffix = self.class::INCLUDE_SUFFIX.clone
20
- @filename = nil
21
- @input_filename = "-"
22
- end
23
-
24
- def apply_to_Include(element)
25
- fname = search_file(element.filename, element.tree.include_paths,
26
- @include_suffix)
27
- File.readlines(fname).join("") if fname
28
- end
29
- end
30
- end # RD
@@ -1,4 +0,0 @@
1
- require 'rd/version'
2
- module RD
3
- PACKAGE_VERSION = RD::VERSION
4
- end
@@ -1,14 +0,0 @@
1
-
2
- module RD
3
- module ParserUtility
4
- def add_children_to_element(parent, *children)
5
- # parent.add_children_under_document_struct(children,
6
- # tree.document_struct)
7
- parent.add_children_without_document_struct(children)
8
- end
9
-
10
- def tree
11
- raise NotImplementedError, "Subclass Responsibility"
12
- end
13
- end
14
- end
@@ -1 +0,0 @@
1
- install_files ["dot.rd2rc"], "#{config('rbdir')}/rd", 0644
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- mode: ruby; coding: utf-8; indent-tabs-mode: nil -*-
3
- #
4
- # Copyright(C) Youhei SASAKI All rights reserved.
5
- # $Lastupdate: 2012/05/06 23:15:30$
6
- #
7
- # License: Ruby's License or GPL-2+
8
- #
9
- # Code:
10
- Dir.chdir("#{srcdir_root}")
11
- Dir.glob("./lib/rd/*.ry").each { |f|
12
- obj = f.gsub(/\.ry$/,'.tab.rb')
13
- unless FileTest.exists?(obj)
14
- puts "racc #{f} -o #{obj}"
15
- system "racc #{f} -o #{obj}" unless srcfile?(obj)
16
- end
17
- }
18
-
@@ -1,69 +0,0 @@
1
- require 'rd/search-file'
2
-
3
- module RD
4
- class RBLFile
5
- include SearchFile
6
-
7
- SUFFIX = "rbl"
8
- attr_reader :labels
9
- attr_reader :filename
10
-
11
- def initialize(filename)
12
- @filename = RBLFile.basename(filename)
13
- @labels = []
14
- end
15
-
16
- def RBLFile.create_rbl_file(filename, resolver)
17
- file = File.open(RBLFile.rbl_file_path(filename), "w")
18
- file.print(RBLFile.labels_to_string(resolver))
19
- file.close
20
- end
21
-
22
- def RBLFile.rbl_file_path(filename)
23
- basename(filename) + "." + SUFFIX
24
- end
25
-
26
- def RBLFile.basename(path)
27
- if /\.(rd|rb)$/ === path
28
- $`
29
- else
30
- path
31
- end
32
- end
33
-
34
- def RBLFile.labels_to_string(resolver)
35
- (resolver.collect do |i|
36
- i.to_label + " => " + resolver.get_anchor(i)
37
- end).join("\n")
38
- end
39
-
40
- def load_rbl_file(search_paths)
41
- f = search_file(@filename, search_paths, [SUFFIX])
42
- raise "RBLFile not found." unless f
43
- src = File.readlines(f).join("")
44
- @labels = string_to_labels(src)
45
- end
46
-
47
- def string_to_labels(src)
48
- labels = []
49
- src.each_line do |i|
50
- labels << parse_line(i)
51
- end
52
- labels
53
- end
54
-
55
- def parse_line(src)
56
- col = src.rindex("=>")
57
- raise "RBL file parse error." unless col
58
- label = src[0 .. col - 1].strip
59
- anchor = src[col + 2 .. -1].strip
60
- [label, anchor]
61
- end
62
-
63
- def refer(label)
64
- label = @labels.find{|i| i[0] == label}
65
- return nil unless label
66
- label[1]
67
- end
68
- end
69
- end
@@ -1,37 +0,0 @@
1
- require "rd/rbl-file"
2
-
3
- module RD
4
- class RBLSuite
5
- attr_reader :rbl_files
6
-
7
- def initialize(search_paths)
8
- @search_paths = search_paths
9
- @rbl_files = []
10
- end
11
-
12
- def refer(label, filename)
13
- rbl = get_rbl_file(filename)
14
- [rbl.filename, rbl.refer(label)]
15
- end
16
-
17
- def get_rbl_file(filename)
18
- rbl = @rbl_files.find{|i| i.filename == RBLFile.basename(filename)}
19
- if rbl
20
- rbl
21
- else
22
- add_rbl_file(filename)
23
- end
24
- end
25
-
26
- def add_rbl_file(filename)
27
- rbl = RBLFile.new(filename)
28
- begin
29
- rbl.load_rbl_file(@search_paths)
30
- rescue RuntimeError
31
- ensure
32
- @rbl_files.push(rbl)
33
- end
34
- rbl
35
- end
36
- end
37
- end
@@ -1,86 +0,0 @@
1
- require 'rd/document-struct'
2
- require 'rd/tree'
3
- require 'rd/element'
4
- require 'rd/block-element'
5
- require 'rd/list'
6
- require 'rd/desclist'
7
- require 'rd/methodlist'
8
- require 'rd/inline-element'
9
-
10
- # definition of RD document structure.
11
-
12
- module RD
13
- # interface. can be component of ListItem.
14
- module ListItemComposable
15
- end
16
- # interface. can be component of Headline and Reference.
17
- module LabelComposable
18
- end
19
- # interface. can include Inline
20
- module InlineIncludable
21
- end
22
-
23
- class DocumentStructure
24
- RD = DocumentStructure.new
25
-
26
- RD.define_relationship(Tree, DocumentElement)
27
- RD.define_relationship(DocumentElement, BlockElement)
28
- RD.define_relationship(Headline, LabelComposable)
29
- RD.define_relationship(TextBlock, InlineElement)
30
- RD.define_relationship(ItemList, ItemListItem)
31
- RD.define_relationship(EnumList, EnumListItem)
32
- RD.define_relationship(DescList, DescListItem)
33
- RD.define_relationship(MethodList, MethodListItem)
34
- RD.define_relationship(ListItem, ListItemComposable)
35
- RD.define_relationship(DescListItem, DescListItem::Term)
36
- RD.define_relationship(DescListItem::Term, LabelComposable)
37
- RD.define_relationship(MethodListItem, MethodListItem::Term)
38
- RD.define_relationship(InlineIncludable, InlineElement)
39
- RD.define_relationship(Reference, LabelComposable)
40
- end
41
-
42
- class TextBlock
43
- include ListItemComposable
44
- end
45
- class Verbatim
46
- include ListItemComposable
47
- end
48
- class ItemList
49
- include ListItemComposable
50
- end
51
- class EnumList
52
- include ListItemComposable
53
- end
54
- class DescList
55
- include ListItemComposable
56
- end
57
- class StringElement
58
- include LabelComposable
59
- end
60
- class Emphasis
61
- include LabelComposable
62
- include InlineIncludable
63
- end
64
- class Code
65
- include LabelComposable
66
- include InlineIncludable
67
- end
68
- class Var
69
- include LabelComposable
70
- include InlineIncludable
71
- end
72
- class Keyboard
73
- include LabelComposable
74
- include InlineIncludable
75
- end
76
- class Index
77
- include LabelComposable
78
- include InlineIncludable
79
- end
80
- class Footnote
81
- include InlineIncludable
82
- end
83
- class Verb
84
- include LabelComposable
85
- end
86
- end
@@ -1,266 +0,0 @@
1
- =begin
2
- = rd2html-ext-lib.rb
3
- $Id: rd2html-ext-lib.rb,v 1.5 2003/10/30 12:12:33 rubikitch Exp rubikitch $
4
- Copyright(c) 2003 Rubikitch
5
- Licence: Ruby's License or GPL-2+
6
- =end
7
-
8
- require "rd/rd2html-lib"
9
-
10
- module RD
11
- class RD2HTMLExtVisitor < RD2HTMLVisitor
12
- # must-have constants
13
- OUTPUT_SUFFIX = "html"
14
- INCLUDE_SUFFIX = ["html"]
15
-
16
- METACHAR = { "<" => "&lt;", ">" => "&gt;", "&" => "&amp;" }
17
-
18
- attr_accessor :opt_headline_title, :opt_ref_extension, :opt_headline_secno, :opt_enable_br, :opt_native_inline, :opt_head_element
19
- attr(:head, true)
20
-
21
- def initialize
22
- @enum_count = [0, 0, 0, 0, 0, 0, 0]
23
- @levelold = 0
24
- @enum_start_level = 2
25
- @image_size = {}
26
- begin
27
- require 'image_size'
28
- @use_image_size = true
29
- rescue LoadError
30
- @use_image_size = false
31
- end
32
-
33
- super
34
- end
35
-
36
- def visit(tree)
37
- install_headline_title if opt_headline_title
38
- install_headline_secno if opt_headline_secno
39
- install_ref_extension if opt_ref_extension
40
- install_enable_br if opt_enable_br
41
- install_native_inline if opt_native_inline
42
- install_head_element if opt_head_element
43
- title_init if opt_headline_title || opt_headline_secno
44
- super
45
- end
46
-
47
- def install_headline_title
48
- extend HeadLineTitle
49
- end
50
-
51
- def install_native_inline
52
- extend NativeInline
53
- end
54
-
55
- def install_enable_br
56
- extend EnableBr
57
- end
58
-
59
- def install_headline_secno
60
- extend HeadLineTitle
61
- extend HeadlineSecno
62
- end
63
-
64
- def install_ref_extension
65
- extend RefExtension
66
- @ref_extension = []
67
- (methods + private_methods).sort.each do |m|
68
- if /^ref_ext/ =~ m
69
- @ref_extension.push(m.intern)
70
- end
71
- end
72
- @ref_extension.push(:default_ref_ext)
73
- end
74
-
75
- def install_head_element
76
- extend HeadElement
77
- end
78
-
79
- ################ <H1> to <Title>
80
- module HeadLineTitle
81
- def title_init
82
- @headline_called = false
83
- end
84
-
85
- def make_title(title)
86
- unless @headline_called || @title then
87
- @title = title.join.strip
88
- @headline_called = true
89
- end
90
- end
91
-
92
- def apply_to_Headline(element, title)
93
- make_title(title)
94
- super
95
- end
96
- end
97
-
98
- ################ index inline => native inline
99
- module NativeInline
100
- Delimiter = "\ca\ca"
101
- def html_body(contents)
102
- html = super
103
- a = html.split(Delimiter)
104
- a.each_with_index do |s, i|
105
- if i % 2 == 1
106
- meta_char_unescape!(s)
107
- end
108
- end
109
- a.join
110
- end
111
- private :html_body
112
-
113
- def apply_to_Index(element, content)
114
- %Q[#{Delimiter}#{content}#{Delimiter}]
115
- end
116
-
117
- def meta_char_unescape!(str)
118
- str.gsub!(/(&lt;|&gt;|&amp;)/) {
119
- METACHAR.index($&)
120
- }
121
- end
122
- private :meta_char_unescape!
123
-
124
- end
125
-
126
- ################ Enable <br>
127
- module EnableBr
128
- def apply_to_TextBlock(element, content)
129
- if (element.parent.is_a?(ItemListItem) or
130
- element.parent.is_a?(EnumListItem)) and
131
- consist_of_one_textblock?(element.parent)
132
- content.join.chomp
133
- else
134
- content = content.delete_if{|x| x == "\n"}.join("").gsub(/\n/, "<br />\n")
135
- %Q[<p>#{content.chomp}</p>]
136
- end
137
- end
138
- end
139
-
140
- ################ Headline Enumeration
141
- module HeadlineSecno
142
- def make_Headline_secno(element)
143
- level = element.level
144
- (@levelold+1).upto(@enum_count.length-1){|i| @enum_count[i]=0}
145
- @enum_count[level] += 1
146
- prefix = ""
147
- @enum_start_level.upto(level) do |l|
148
- prefix << @enum_count[l].to_s
149
- prefix << "." unless l == level
150
- end
151
- @levelold = level
152
- if prefix == '' then "Title:" else prefix end
153
- end
154
- private :make_Headline_secno
155
-
156
- def apply_to_Headline(element, title)
157
- anchor = refer(element)
158
- make_title(title)
159
- secno = make_Headline_secno element
160
- %Q[<h#{element.level}><a name="#{secno}" href="##{secno}">#{secno}</a> ] +
161
- %Q[<a name="#{anchor}">#{title}</a>] +
162
- %Q[</h#{element.level}><!-- RDLabel: "#{element.label}" -->\n]
163
- end
164
- end
165
-
166
- ################ TextBlock Label
167
- ################ Reference Extension from rd2rwiki-lib.rb
168
-
169
- module RefExtension
170
- def apply_to_RefToElement(element, content)
171
- content = content.join("")
172
- apply_ref_extension(element, element_label(element), content)
173
- end
174
- private
175
-
176
- def apply_ref_extension(element, label, content)
177
- @ref_extension.each do |entry|
178
- result = __send__(entry, element, label, content)
179
- return result if result
180
- end
181
- end
182
-
183
- def element_label(element)
184
- case element
185
- when RDElement
186
- element.to_label
187
- else
188
- element
189
- end
190
- end
191
-
192
- def default_ref_ext(element, label, content)
193
- if anchor = refer(element)
194
- content = content.sub(/^function#/, "")
195
- %Q[<a href="\##{anchor}">#{content}</a>]
196
- else
197
- # warning?
198
- label = hyphen_escape(element.to_label)
199
- %Q[<!-- Reference, RDLabel "#{label}" doesn't exist -->] +
200
- %Q[<em class="label-not-found">#{content}</em><!-- Reference end -->]
201
- #'
202
- end
203
- end
204
-
205
- def ref_ext_RubyML(element, label, content)
206
- return nil unless /^(ruby-(?:talk|list|dev|math)):(.+)$/ =~ label
207
- ml = $1
208
- article = $2.sub(/^0+/, '')
209
- content = "[#{label}]" if label == content
210
-
211
- %Q[<a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/#{ ml }/#{ article }">#{ content }</a>]
212
- end
213
-
214
- def ref_ext_RAA(element, label, content)
215
- return nil unless /^RAA:(.+)$/ =~ label
216
- name = CGI.escape($1)
217
- content = "[#{label}]" if label == content
218
- %Q[<a href="http://raa.ruby-lang.org/list.rhtml?name=#{ name }">#{ content }</a>]
219
- end
220
-
221
- def ref_ext_IMG(element, label, content)
222
- return nil unless /^IMG:(.+)$/i =~ label
223
- file = $1
224
- label.to_s == content.to_s and content = file
225
- if @use_image_size
226
- begin
227
- unless @image_size[ file ]
228
- open( file ) do |img|
229
- is = ImageSize::new( img )
230
- @image_size[ file ] = [ is.get_height, is.get_width ]
231
- end
232
- end
233
-
234
- height, width = @image_size[ file ]
235
- %Q[<img src="#{$1}" alt="#{content}" height="#{height}" width="#{width}" />]
236
- rescue
237
- %Q[<img src="#{$1}" alt="#{content}">]
238
- end
239
- else
240
- %Q[<img src="#{$1}" alt="#{content}" />]
241
- end
242
- end
243
- end # RefExtension
244
-
245
- ################
246
- module HeadElement
247
- def html_head
248
- ret = %|<head>\n|
249
- ret << html_title + "\n"
250
- ret << html_content_type + "\n" if html_content_type
251
- ret << link_to_css + "\n" if link_to_css
252
- ret << forward_links + "\n" if forward_links
253
- ret << backward_links + "\n" if backward_links
254
- if self.head
255
- ret << self.head + "\n"
256
- else
257
- ret << %Q[<!-- head-element:nil -->\n]
258
- end
259
- ret << %Q[</head>]
260
- end
261
- end
262
- end # RD2HTMLExtVisitor
263
- end # RD
264
-
265
- $Visitor_Class = RD::RD2HTMLExtVisitor
266
- $RD2_Sub_OptionParser = "rd/rd2html-ext-opt"