trac-wiki 0.2.23 → 0.2.24
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.
- data/lib/trac-wiki/env.rb +4 -2
- data/lib/trac-wiki/parser.rb +5 -4
- data/lib/trac-wiki/version.rb +1 -1
- data/test/parser_test.rb +17 -6
- metadata +2 -2
data/lib/trac-wiki/env.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module TracWiki
|
2
3
|
|
3
4
|
class Env
|
@@ -207,8 +208,9 @@ module TracWiki
|
|
207
208
|
arg.sub!(/\A\s*\|?/, '')
|
208
209
|
env = { 'arg' => arg , depth: (depth||0) + 1 }
|
209
210
|
idx = 1
|
211
|
+
print "arg:#{arg.encoding}\n"
|
210
212
|
arg.split(/\|/).each do |val|
|
211
|
-
if val =~ /\A\s*(\w+)\s*=\s*(.*)/
|
213
|
+
if val =~ /\A\s*(\w+)\s*=\s*(.*)/m
|
212
214
|
env[$1] = $2
|
213
215
|
else
|
214
216
|
env[idx.to_s] = val
|
@@ -249,7 +251,7 @@ module TracWiki
|
|
249
251
|
end
|
250
252
|
#print "text: #{text.nil?}\n"
|
251
253
|
#print "ret: #{ret.nil?}\n"
|
252
|
-
return ret + str
|
254
|
+
return ret + str.gsub(/\\\r?\n/, '')
|
253
255
|
end
|
254
256
|
end
|
255
257
|
|
data/lib/trac-wiki/parser.rb
CHANGED
@@ -282,6 +282,7 @@ module TracWiki
|
|
282
282
|
# make_local_link("LocalLink") #=> "/LocalLink"
|
283
283
|
# make_local_link("Wikipedia:Bread") #=> "http://en.wikipedia.org/wiki/Bread"
|
284
284
|
def make_local_link(link) #:doc:
|
285
|
+
# FIXME: xss when no_escape
|
285
286
|
link, anch = link.split(/#/, 2)
|
286
287
|
if no_escape?
|
287
288
|
return "#{@base}#{link}" if ! anch
|
@@ -478,9 +479,8 @@ module TracWiki
|
|
478
479
|
when str =~ /\A`(.*?)`/ # inline pre (tt)
|
479
480
|
@tree.tag(:tt, $1)
|
480
481
|
when math? && str =~ /\A\$(.+?)\$/ # inline math (tt)
|
481
|
-
|
482
|
-
|
483
|
-
#@tree.tag(:span, {class:'math'}, $1)
|
482
|
+
#@tree.add("\\( #{$1} \\)")
|
483
|
+
@tree.tag(:span, {class:'math'}, $1)
|
484
484
|
@was_math = true
|
485
485
|
when str =~ /\A(\&\w*;)/ # html entity
|
486
486
|
#print "add html ent: #{$1}\n"
|
@@ -645,7 +645,8 @@ module TracWiki
|
|
645
645
|
|
646
646
|
def do_math(text)
|
647
647
|
end_paragraph
|
648
|
-
|
648
|
+
#@tree.add("$$#{text}$$\n")
|
649
|
+
@tree.tag(:div, {class:'math'}, text)
|
649
650
|
@was_math = true
|
650
651
|
end
|
651
652
|
def do_merge(merge_type, who)
|
data/lib/trac-wiki/version.rb
CHANGED
data/test/parser_test.rb
CHANGED
@@ -48,6 +48,7 @@ end
|
|
48
48
|
|
49
49
|
describe TracWiki::Parser do
|
50
50
|
it 'should not parse linkd' do
|
51
|
+
tc "<p>[[ahoj]]</p>\n", "[ahoj]", :no_link => true
|
51
52
|
tc "<p>[[ahoj]]</p>\n", "[[ahoj]]", :no_link => true
|
52
53
|
tc "<p>[[ahoj|bhoj]]</p>\n", "[[ahoj|bhoj]]", :no_link => true
|
53
54
|
tc "<ul><li>[[ahoj|bhoj]]</li>\n</ul>\n", "* [[ahoj|bhoj]]", :no_link => true
|
@@ -162,17 +163,17 @@ describe TracWiki::Parser do
|
|
162
163
|
end
|
163
164
|
|
164
165
|
it 'should parse math' do
|
165
|
-
tc "<p
|
166
|
-
tc "<p>test
|
167
|
-
tc "<p>test
|
166
|
+
tc "<p><span class=\"math\">the</span></p>\n", '$the$', math: true
|
167
|
+
tc "<p>test <span class=\"math\">the</span> west</p>\n", 'test $the$ west', math: true
|
168
|
+
tc "<p>test <span class=\"math\">e^{i\\pi}</span> test</p>\n", 'test $e^{i\pi}$ test', math: true
|
168
169
|
tc "<p>test $ e<sup>{i\\pi} test</sup></p>\n", 'test $ e^{i\pi} test', math: true
|
169
170
|
tc "<p>$the$</p>\n", '$the$', math: false
|
170
171
|
|
171
|
-
tc "<p>ahoj</p>\n
|
172
|
+
tc "<p>ahoj</p>\n<div class=\"math\">e^{i\\pi}</div>\n<p>nazdar</p>\n", "ahoj\n$$e^{i\\pi}$$\nnazdar", math: true
|
172
173
|
tc "<p>ahoj $$e<sup>{i\\pi}$$ nazdar</sup></p>\n", "ahoj\n$$e^{i\\pi}$$\nnazdar", math: false
|
173
174
|
|
174
|
-
tc "
|
175
|
-
tc "
|
175
|
+
tc "<div class=\"math\">\\\\</div>\n", "$$\\\\$$", math: true
|
176
|
+
tc "<div class=\"math\">\n^test\n</div>\n", "$$\n^test\n$$", math: true
|
176
177
|
|
177
178
|
tc "<p>$a<sup>b</sup>c$</p>\n", "!$a^b^c$", math: true
|
178
179
|
tc "<p>$a<strong>b</strong>c$</p>\n", "!$a**b**c$", math: true
|
@@ -228,6 +229,10 @@ describe TracWiki::Parser do
|
|
228
229
|
it 'should parse links' do
|
229
230
|
# Links
|
230
231
|
tc "<p><a href=\"link\">link</a></p>\n", "[[link]]"
|
232
|
+
tc "<p><a href=\"link\">Flink</a></p>\n", "[[link|Flink]]"
|
233
|
+
|
234
|
+
# FIXME: http://trac.edgewall.org/wiki/TracLinks: this is wrong
|
235
|
+
#tc "<p><a href=\"link\">Flink</a></p>\n", "[link Flink]"
|
231
236
|
tc "<p><a href=\"BASE/link\">link</a></p>\n", "[[link]]", base: 'BASE'
|
232
237
|
tc "<p><a href=\"BASE/link\">link</a></p>\n", "[[link]]", base: 'BASE/'
|
233
238
|
tc "<p><a href=\"link#link\">link#link</a></p>\n", "[[link#link]]"
|
@@ -1007,6 +1012,12 @@ eos
|
|
1007
1012
|
tc "<p><a href=\"http://example.com/there#i+m\">There</a></p>\n", "[[there#i m|There]]", base: 'http://example.com/'
|
1008
1013
|
tc "<p><a href=\"#here+i+m\">Here</a></p>\n", "[[#here i m|Here]]", base: 'http://example.com/'
|
1009
1014
|
end
|
1015
|
+
it 'should parse dnl inside macro' do
|
1016
|
+
tc "<p>d<blockquote>e</blockquote></p>\n", "{{!ifeq a|b|c|d\n e}}"
|
1017
|
+
tc "<p>d e</p>\n", "{{!ifeq a|b|c|d\\\n e}}"
|
1018
|
+
tc "<p>d<strong>e</strong></p>\n", "{{!ifeq a|b|c|d**\\\ne**}}"
|
1019
|
+
tc "<p>d<strong>e</strong></p>\n", "{{!ifeq a|b|c|d*\\\n*e**}}"
|
1020
|
+
end
|
1010
1021
|
|
1011
1022
|
end
|
1012
1023
|
# vim: tw=0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trac-wiki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.24
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|