wikicloth 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -3
- data/Rakefile +19 -11
- data/lang/de.yml +24 -0
- data/lang/en.yml +35 -0
- data/lib/wikicloth.rb +47 -26
- data/lib/wikicloth/core_ext.rb +4 -0
- data/lib/wikicloth/extension.rb +60 -0
- data/lib/wikicloth/extensions/lua.rb +82 -0
- data/lib/wikicloth/extensions/lua/COPYING +18 -0
- data/lib/wikicloth/extensions/lua/luawrapper.lua +245 -0
- data/lib/wikicloth/extensions/math.rb +39 -0
- data/lib/wikicloth/extensions/poem.rb +15 -0
- data/lib/wikicloth/extensions/references.rb +48 -0
- data/lib/wikicloth/extensions/source.rb +46 -0
- data/lib/wikicloth/i18n.rb +108 -0
- data/lib/wikicloth/namespaces.rb +62 -0
- data/lib/wikicloth/parser.rb +21 -15
- data/lib/wikicloth/section.rb +1 -5
- data/lib/wikicloth/version.rb +1 -1
- data/lib/wikicloth/wiki_buffer.rb +151 -39
- data/lib/wikicloth/wiki_buffer/html_element.rb +24 -59
- data/lib/wikicloth/wiki_buffer/link.rb +3 -2
- data/lib/wikicloth/wiki_buffer/table.rb +2 -2
- data/lib/wikicloth/wiki_buffer/var.rb +80 -28
- data/lib/wikicloth/wiki_link_handler.rb +22 -29
- data/sample_documents/lua.wiki +58 -0
- data/test/locales.yml +264 -0
- data/test/test_helper.rb +1 -0
- data/test/wiki_cloth_test.rb +142 -27
- data/wikicloth.gemspec +2 -1
- metadata +34 -8
- data/lib/wikicloth/lexer.rb +0 -105
- data/lib/wikicloth/token.rb +0 -41
data/wikicloth.gemspec
CHANGED
@@ -25,5 +25,6 @@ spec = Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency 'activesupport'
|
26
26
|
s.add_development_dependency 'i18n'
|
27
27
|
s.add_development_dependency 'rake'
|
28
|
-
s.add_development_dependency '
|
28
|
+
s.add_development_dependency 'rdoc'
|
29
|
+
s.add_development_dependency(RUBY_VERSION =~ /^1\.9/ ? "simplecov" : "rcov")
|
29
30
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikicloth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 8
|
9
|
+
- 0
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Ricciardi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-04-13 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -103,7 +103,7 @@ dependencies:
|
|
103
103
|
type: :development
|
104
104
|
version_requirements: *id006
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
|
-
name:
|
106
|
+
name: rdoc
|
107
107
|
prerelease: false
|
108
108
|
requirement: &id007 !ruby/object:Gem::Requirement
|
109
109
|
none: false
|
@@ -116,6 +116,20 @@ dependencies:
|
|
116
116
|
version: "0"
|
117
117
|
type: :development
|
118
118
|
version_requirements: *id007
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rcov
|
121
|
+
prerelease: false
|
122
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
type: :development
|
132
|
+
version_requirements: *id008
|
119
133
|
description: mediawiki parser
|
120
134
|
email: nricciar@gmail.com
|
121
135
|
executables: []
|
@@ -136,12 +150,22 @@ files:
|
|
136
150
|
- examples/info.rb
|
137
151
|
- examples/print.rb
|
138
152
|
- init.rb
|
153
|
+
- lang/de.yml
|
154
|
+
- lang/en.yml
|
139
155
|
- lib/wikicloth.rb
|
140
156
|
- lib/wikicloth/core_ext.rb
|
141
|
-
- lib/wikicloth/
|
157
|
+
- lib/wikicloth/extension.rb
|
158
|
+
- lib/wikicloth/extensions/lua.rb
|
159
|
+
- lib/wikicloth/extensions/lua/COPYING
|
160
|
+
- lib/wikicloth/extensions/lua/luawrapper.lua
|
161
|
+
- lib/wikicloth/extensions/math.rb
|
162
|
+
- lib/wikicloth/extensions/poem.rb
|
163
|
+
- lib/wikicloth/extensions/references.rb
|
164
|
+
- lib/wikicloth/extensions/source.rb
|
165
|
+
- lib/wikicloth/i18n.rb
|
166
|
+
- lib/wikicloth/namespaces.rb
|
142
167
|
- lib/wikicloth/parser.rb
|
143
168
|
- lib/wikicloth/section.rb
|
144
|
-
- lib/wikicloth/token.rb
|
145
169
|
- lib/wikicloth/version.rb
|
146
170
|
- lib/wikicloth/wiki_buffer.rb
|
147
171
|
- lib/wikicloth/wiki_buffer/html_element.rb
|
@@ -158,12 +182,14 @@ files:
|
|
158
182
|
- sample_documents/images.wiki
|
159
183
|
- sample_documents/klaus_schulze.wiki
|
160
184
|
- sample_documents/lists.wiki
|
185
|
+
- sample_documents/lua.wiki
|
161
186
|
- sample_documents/pipe_trick.wiki
|
162
187
|
- sample_documents/random.wiki
|
163
188
|
- sample_documents/tv.wiki
|
164
189
|
- sample_documents/wiki.png
|
165
190
|
- sample_documents/wiki_tables.wiki
|
166
191
|
- tasks/wikicloth_tasks.rake
|
192
|
+
- test/locales.yml
|
167
193
|
- test/test_helper.rb
|
168
194
|
- test/wiki_cloth_test.rb
|
169
195
|
- wikicloth.gemspec
|
data/lib/wikicloth/lexer.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
# not actually used by wikicloth atm
|
2
|
-
module WikiCloth
|
3
|
-
|
4
|
-
class Lexer
|
5
|
-
|
6
|
-
def initialize(input)
|
7
|
-
@input = input
|
8
|
-
@return_previous_token = false
|
9
|
-
end
|
10
|
-
|
11
|
-
def get_next_token
|
12
|
-
if @return_previous_token
|
13
|
-
@return_previous_token = false
|
14
|
-
return @previous_token
|
15
|
-
end
|
16
|
-
|
17
|
-
token = Token.new
|
18
|
-
prepend_input = nil
|
19
|
-
|
20
|
-
case @input
|
21
|
-
when /\A\s+/
|
22
|
-
token.kind = Token::Space
|
23
|
-
when /\A:/
|
24
|
-
token.kind = Token::Colon
|
25
|
-
when /\A([']{2,5})/
|
26
|
-
token.kind = Token::BoldItalic
|
27
|
-
when /\A\n([*]{1,})/
|
28
|
-
token.kind = Token::ListItem
|
29
|
-
when /\A~~~~/
|
30
|
-
token.kind = Token::Signature
|
31
|
-
when /\A<!--/
|
32
|
-
token.kind = Token::BeginComment
|
33
|
-
when /\A-->/
|
34
|
-
token.kind = Token::EndComment
|
35
|
-
when /\A[\w\(\)\.\%;\#\-\/,'&\*~]+/
|
36
|
-
# swallowed bold/italic
|
37
|
-
if $&[-2,2] == "''"
|
38
|
-
prepend_input = "''"
|
39
|
-
token.value = $&[0..-3]
|
40
|
-
elsif $&[-3,3] == "'''"
|
41
|
-
prepend_input = "'''"
|
42
|
-
token.value = $&[0..-4]
|
43
|
-
elsif $&[-5,5] == "'''''"
|
44
|
-
prepend_input = "'''''"
|
45
|
-
token.value = $&[0..-6]
|
46
|
-
# accidently swallowed closing comment
|
47
|
-
elsif $&[-2,2] == "--" && $'[0,1] == '>'
|
48
|
-
prepend_input = '--'
|
49
|
-
token.value = $&[0..-3]
|
50
|
-
else
|
51
|
-
token.value = $&
|
52
|
-
end
|
53
|
-
token.kind = Token::Word
|
54
|
-
when /\A\{\|/
|
55
|
-
token.kind = Token::BeginTable
|
56
|
-
when /\A\|\}/
|
57
|
-
token.kind = Token::EndTable
|
58
|
-
when /\A\|/
|
59
|
-
token.kind = Token::Pipe
|
60
|
-
when /\A=/
|
61
|
-
token.kind = Token::Equals
|
62
|
-
when /\A"/
|
63
|
-
token.kind = Token::Quote
|
64
|
-
when /\A\n/
|
65
|
-
token.kind = Token::NewLine
|
66
|
-
when /\A\{\{/
|
67
|
-
token.kind = Token::OpenRes
|
68
|
-
when /\A\}\}/
|
69
|
-
token.kind = Token::CloseRes
|
70
|
-
when /\A\[\[/
|
71
|
-
token.kind = Token::OpenLink
|
72
|
-
token.value = $&
|
73
|
-
when /\A\]\]/
|
74
|
-
token.kind = Token::CloseLink
|
75
|
-
token.value = $&
|
76
|
-
when /\A\[/
|
77
|
-
token.kind = Token::OpenLink
|
78
|
-
token.kind = $&
|
79
|
-
when /\A\]/
|
80
|
-
token.kind = Token::CloseLink
|
81
|
-
token.kind = $&
|
82
|
-
when /\A\<\s*\//
|
83
|
-
token.kind = Token::OpenElement
|
84
|
-
when /\A\</
|
85
|
-
token.kind = Token::OpenElement
|
86
|
-
when /\A\>/
|
87
|
-
token.kind = Token::CloseElement
|
88
|
-
when ''
|
89
|
-
token.kind = Token::End
|
90
|
-
end
|
91
|
-
token.value ||= $&
|
92
|
-
|
93
|
-
raise "Unknown token #{@input}" if token.unknown?
|
94
|
-
@input = "#{prepend_input}#{$'}"
|
95
|
-
|
96
|
-
@previous_token = token
|
97
|
-
token
|
98
|
-
end
|
99
|
-
|
100
|
-
def revert
|
101
|
-
@return_previous_token = true
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
data/lib/wikicloth/token.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# not actually used by wikicloth atm
|
2
|
-
module WikiCloth
|
3
|
-
|
4
|
-
class Token
|
5
|
-
OpenRes = 1
|
6
|
-
CloseRes = 2
|
7
|
-
OpenLink = 3
|
8
|
-
CloseLink = 4
|
9
|
-
Heading = 5
|
10
|
-
Word = 6
|
11
|
-
NewLine = 7
|
12
|
-
OpenElement = 8
|
13
|
-
CloseElement = 9
|
14
|
-
Equals = 10
|
15
|
-
Quote = 11
|
16
|
-
BeginComment = 12
|
17
|
-
EndComment = 13
|
18
|
-
BeginTable = 14
|
19
|
-
EndTable = 15
|
20
|
-
Pipe = 16
|
21
|
-
BoldItalic = 17
|
22
|
-
ListItem = 18
|
23
|
-
Signature = 19
|
24
|
-
Space = 20
|
25
|
-
Colon = 21
|
26
|
-
End = 22
|
27
|
-
|
28
|
-
attr_accessor :kind
|
29
|
-
attr_accessor :value
|
30
|
-
|
31
|
-
def initialize
|
32
|
-
@kind = nil
|
33
|
-
@value = nil
|
34
|
-
end
|
35
|
-
|
36
|
-
def unknown?
|
37
|
-
@kind.nil?
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|