raf 0.1.1 → 1.0.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -1
- data/History.rdoc +2 -20
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -16
- data/RELEASE +1 -1
- data/VERSION +1 -1
- data/raf.gemspec +3 -1
- metadata +32 -63
- data/.document +0 -5
- data/bin/raf +0 -19
- data/bin/raf2html +0 -29
- data/lib/parserutility.rb +0 -21
- data/lib/raf.rb +0 -7
- data/lib/raf2html.rb +0 -157
- data/lib/raf2html_element.rb +0 -198
- data/lib/rafblockparser.output +0 -670
- data/lib/rafblockparser.ry +0 -358
- data/lib/rafblockparser.tab.rb +0 -715
- data/lib/rafelement.rb +0 -229
- data/lib/rafinlineparser.output +0 -1804
- data/lib/rafinlineparser.ry +0 -415
- data/lib/rafinlineparser.tab.rb +0 -972
- data/sample.raf +0 -4
- data/test/helper.rb +0 -18
- data/test/test_descblock.rb +0 -88
- data/test/test_emphasis.rb +0 -76
- data/test/test_erb.rb +0 -23
- data/test/test_footnote.rb +0 -38
- data/test/test_headline.rb +0 -43
- data/test/test_helper.rb +0 -2
- data/test/test_image.rb +0 -81
- data/test/test_italic.rb +0 -76
- data/test/test_itemlistblock.rb +0 -151
- data/test/test_numlistblock.rb +0 -342
- data/test/test_paragraph.rb +0 -76
- data/test/test_quoteblock.rb +0 -109
- data/test/test_reference.rb +0 -47
- data/test/test_ruby.rb +0 -66
- data/test/test_strike.rb +0 -76
- data/test/test_tableblock.rb +0 -63
- data/test/test_verb.rb +0 -86
- data/test/ts_block.rb +0 -10
- data/test/ts_inline.rb +0 -8
- data/test/ts_rafparser.rb +0 -4
data/lib/raf2html_element.rb
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) garin <garin54@gmail.com> 2011
|
3
|
-
# See the included file COPYING for details.
|
4
|
-
require "rafblockparser.tab"
|
5
|
-
module Raf
|
6
|
-
|
7
|
-
class Element
|
8
|
-
def newline_to_br(str)
|
9
|
-
str.gsub("\n", "<br />\n")
|
10
|
-
end
|
11
|
-
|
12
|
-
# @inline_parser.parse の配列を文字列に変換する
|
13
|
-
def inline_parse_to_str(array)
|
14
|
-
str = ""
|
15
|
-
array.each do |obj|
|
16
|
-
str += obj.apply
|
17
|
-
end
|
18
|
-
str
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# ----- Blocks
|
23
|
-
class WhiteLine < Element
|
24
|
-
def apply
|
25
|
-
"\n"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class PlainTextBlock < Element
|
30
|
-
def apply
|
31
|
-
@contents.map {|c| c.apply }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class HeadLine < Element
|
36
|
-
# @contents = [level, title, id, index]
|
37
|
-
def apply
|
38
|
-
return "" if @contents[0] == 1
|
39
|
-
str = ""
|
40
|
-
str += "<h#{@contents[0]} id='raf-head#{@contents[0]}-#{@contents[2]}'>"
|
41
|
-
str += "<a id='#{@contents[1].to_code}'></a>"
|
42
|
-
str += " #{@contents[3]}" unless @contents[0] == 1 or @contents[0] == 5 or @contents[0] == 6
|
43
|
-
str += "#{@contents[1]}</h#{@contents[0]}>\n"
|
44
|
-
str
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class Paragraph < Element
|
49
|
-
def apply
|
50
|
-
"<p>#{@contents.map{|c| c.apply}}</p>\n"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class Quote < Element
|
55
|
-
def apply
|
56
|
-
"<pre>#{@contents}</pre>\n"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
class ItemList < Element
|
61
|
-
def apply
|
62
|
-
return "" if @contents.empty?
|
63
|
-
type = :dummy
|
64
|
-
str = "<ul>\n"
|
65
|
-
@contents.each do |item|
|
66
|
-
type_pre = type
|
67
|
-
case item
|
68
|
-
when :INDENT
|
69
|
-
type = :indent
|
70
|
-
str += "\n<ul>\n"
|
71
|
-
when :DEDENT
|
72
|
-
type = :dedent
|
73
|
-
str += "</li>\n" if type_pre == :item
|
74
|
-
str += "</ul>\n</li>\n"
|
75
|
-
else
|
76
|
-
type = :item
|
77
|
-
str += "</li>\n" if type_pre == :item
|
78
|
-
str += "<li>#{item.apply}"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
str += "\n</li>" if type == :item
|
82
|
-
str += "\n</ul>\n"
|
83
|
-
str
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class NumList < Element
|
88
|
-
def apply
|
89
|
-
str = "<ol>\n"
|
90
|
-
@contents.map do |item|
|
91
|
-
if item == :INDENT
|
92
|
-
str += "<ol>\n"
|
93
|
-
elsif item == :DEDENT
|
94
|
-
str += "</ol>\n"
|
95
|
-
else
|
96
|
-
str += "<li>#{item.apply}</li>\n"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
str += "</ol>\n"
|
100
|
-
str
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
class Desc < Element
|
105
|
-
# @contents = [title, lines]
|
106
|
-
def apply
|
107
|
-
str = "<dl id='#{@contents[0].to_code}'>\n<dt>#{@contents[0]}</dt>\n"
|
108
|
-
str += "<dd>#{inline_parse_to_str(@contents[1])}</dd>\n" unless inline_parse_to_str(@contents[1]).empty?
|
109
|
-
str += "</dl>"
|
110
|
-
str
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
class Table < Element
|
115
|
-
def apply
|
116
|
-
str = "<table>"
|
117
|
-
@contents.each do |line|
|
118
|
-
str += "\n<tr>"
|
119
|
-
line.each do |item|
|
120
|
-
if item =~ /^\s*\*/
|
121
|
-
str += "<th>#{item.sub(/^\s*\*/, "").sub(/\*\s*$/,"")}</th>"
|
122
|
-
else
|
123
|
-
str += "<td>#{item}</td>"
|
124
|
-
end
|
125
|
-
end
|
126
|
-
str += "\n</tr>"
|
127
|
-
end
|
128
|
-
str += "\n</table>"
|
129
|
-
str
|
130
|
-
end
|
131
|
-
end
|
132
|
-
# --- Blocks end
|
133
|
-
|
134
|
-
# --- Inlines
|
135
|
-
class Label < Element
|
136
|
-
# @contents = [label, title]
|
137
|
-
def apply
|
138
|
-
"<a href='##{@contents[0]}' id='#{@contents[0]}'>#{@contents[1]}</a>"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
class Reference < Element
|
143
|
-
def apply
|
144
|
-
"<a href='#{@contents[1]}' title='#{@contents[1]}'>#{@contents[0]}</a>"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
class Plain < Element
|
149
|
-
def apply
|
150
|
-
"#{newline_to_br(CGI.escapeHTML(@contents.join))}"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
class Emphasis < Element
|
155
|
-
def apply
|
156
|
-
"<em>#{@contents.map{|c| c.apply}}</em>"
|
157
|
-
end
|
158
|
-
end
|
159
|
-
class Italic < Element
|
160
|
-
def apply
|
161
|
-
"<i>#{@contents.map{|c| c.apply}}</i>"
|
162
|
-
end
|
163
|
-
end
|
164
|
-
class Strike < Element
|
165
|
-
def apply
|
166
|
-
"<s>#{@contents.map{|c| c.apply}}</s>"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
class Verb < Element
|
171
|
-
def apply
|
172
|
-
"#{@contents}"
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
class Manuedo < Element
|
177
|
-
def apply
|
178
|
-
"<span class='manuedo'>/#{@contents.map{|c| c.apply}}/</span>"
|
179
|
-
end
|
180
|
-
end
|
181
|
-
class Ruby < Element
|
182
|
-
def apply
|
183
|
-
"<ruby><rb>#{@contents[0]}</rb><rp>(</rp><rt>#{@contents[1]}</rt><rp>)</rp></ruby>"
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
class Footnote < Element
|
188
|
-
def apply
|
189
|
-
"<a href='#raf-footnote-#{@contents[1]}' name='raf-footnote-#{@contents[1]}-reverse' title='#{@contents[0].map {|c| c.apply}}' class='footnote-reverse'><sup><small>*#{@contents[1]}</small></sup></a>"
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
class Image < Element
|
194
|
-
def apply
|
195
|
-
"<img src='#{@contents}' />"
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|