trac-wiki 0.0.5 → 0.0.6

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.
@@ -227,7 +227,7 @@ module TracWiki
227
227
  until str.empty?
228
228
  case str
229
229
  # raw url
230
- when /\A(\~)?((https?|ftps?):\/\/\S+?)(?=([\,.?!:;"'\)]+)?(\s|$))/
230
+ when /\A(!)?((https?|ftps?):\/\/\S+?)(?=([\]\,.?!:;"'\)]+)?(\s|$))/
231
231
  str = $'
232
232
  if $1
233
233
  @out << escape_html($2)
@@ -243,7 +243,12 @@ module TracWiki
243
243
  str = $'
244
244
  @out << make_image($1, $3)
245
245
  # [[link]]
246
- when /\A\[\[\s*([^|]*?)\s*(\|\s*(.*?))?\s*\]\]/m
246
+ # [ link1 | text2 ]
247
+ when /\A \[ \s* ([^\[|]*?) \s* (\|\s*(.*?))? \s* \] /mx
248
+ str = $'
249
+ link, content, whole= $1, $3, $&
250
+ make_link(link, content, whole)
251
+ when /\A \[\[ \s* ([^|]*?) \s* (\|\s*(.*?))? \s* \]\] /mx
247
252
  str = $'
248
253
  link, content, whole= $1, $3, $&
249
254
  make_link(link, content, whole)
@@ -257,7 +262,7 @@ module TracWiki
257
262
  def make_link(link, content, whole)
258
263
  uri = make_explicit_link(link)
259
264
  # specail "link" [[BR]]:
260
- if link =~ /br/i
265
+ if link =~ /^br$/i
261
266
  @out << '<br/>'
262
267
  return
263
268
  end
@@ -1,3 +1,3 @@
1
1
  module TracWiki
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
data/test/parser_test.rb CHANGED
@@ -46,6 +46,11 @@ describe TracWiki::Parser do
46
46
  tc "<p>This <strong>is bold</strong></p>\n", "This **is\nbold**"
47
47
  end
48
48
 
49
+ it 'should be toc' do
50
+ tc "<p>{{toc}}</p>\n", "{{toc}}"
51
+ tc "<h2>ahoj</h2><p>{{toc}}</p>\n<h2>ahoj</h2>", "==ahoj==\n{{toc}}\n\n==ahoj==\n"
52
+ end
53
+
49
54
  it 'should parse bolditalic' do
50
55
  tc "<p>This is <strong><em>bolditallic</em></strong>.</p>\n", "This is '''''bolditallic'''''."
51
56
  tc "<p>This is <strong> <em>bolditallic</em> </strong>.</p>\n", "This is ''' ''bolditallic'' '''."
@@ -388,6 +393,9 @@ describe TracWiki::Parser do
388
393
  tc("<p>How about <em>a link, like <a href=\"http://example.org\">http://example.org</a>, in italic</em> text?</p>\n",
389
394
  "How about ''a link, like http://example.org, in italic'' text?")
390
395
 
396
+ tc("<p>How about <em>a link, like <a href=\"http://example.org\">http://example.org</a>, in italic</em> text?</p>\n",
397
+ "How about ''a link, like [http://example.org], in italic'' text?")
398
+
391
399
  # Another test
392
400
  tc("<p>Formatted fruits, for example:<em>apples</em>, oranges, <strong>pears</strong> ...</p>\n",
393
401
  "Formatted fruits, for example:''apples'', oranges, **pears** ...")
@@ -451,9 +459,12 @@ describe TracWiki::Parser do
451
459
  tc "<p>Hello ! world</p>\n", "Hello !\nworld\n"
452
460
  # Not escaping inside URLs
453
461
  tc "<p><a href=\"http://example.org/~user/\">http://example.org/~user/</a></p>\n", "http://example.org/~user/"
462
+ tc "<p><a href=\"http://example.org/~user/\">http://example.org/~user/</a></p>\n", "[http://example.org/~user/]"
454
463
 
455
464
  # Escaping links
456
- tc "<p>http://www.example.org/</p>\n", "~http://www.example.org/"
465
+ tc "<p>http://www.example.org/</p>\n", "!http://www.example.org/"
466
+ tc "<p>[http://www.example.org/]</p>\n", "![!http://www.example.org/]"
467
+ tc "<p>[<a href=\"http://www.example.org/\">http://www.example.org/</a>]</p>\n", "![http://www.example.org/]"
457
468
  end
458
469
 
459
470
  it 'should parse horizontal rule' do
@@ -510,6 +521,7 @@ describe TracWiki::Parser do
510
521
  tc "<table><tr><th>Header</th></tr></table>", "||=Header=||"
511
522
 
512
523
  tc "<table><tr><td>c1</td><td><a href=\"Link\">Link text</a></td><td><img src=\"Image\"/></td></tr></table>", "||c1||[[Link|Link text]]||[[Image(Image)]]||"
524
+ tc "<table><tr><td>c1</td><td><a href=\"Link\">Link text</a></td><td><img src=\"Image\"/></td></tr></table>", "||c1||[Link|Link text]||[[Image(Image)]]||"
513
525
  end
514
526
 
515
527
  it 'should parse following table' do
@@ -715,6 +727,7 @@ describe TracWiki::Parser do
715
727
 
716
728
  it 'should support no_escape' do
717
729
  tc("<p><a href=\"a%2Fb%2Fc\">a/b/c</a></p>\n", "[[a/b/c]]")
730
+ tc("<p><a href=\"a%2Fb%2Fc\">a/b/c</a></p>\n", "[a/b/c]")
718
731
  tc("<p><a href=\"a/b/c\">a/b/c</a></p>\n", "[[a/b/c]]", :no_escape => true)
719
732
  end
720
733
  end
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.0.5
4
+ version: 0.0.6
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: 2013-04-11 00:00:00.000000000 Z
12
+ date: 2013-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon