trac-wiki 0.3.37 → 0.3.38

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e3ed3f2aa66db2cd00b4504c240b78d5478cb985246fd445ccfcd3f328697c9
4
- data.tar.gz: 55c633635589b06b0d1a3f40ffb23f494179b52c1932bcd199f05ea51ce21bd9
3
+ metadata.gz: 29aaefb0e1d2ed2f2ca6abaa8a26fcadd3d9ac2138a196510546f7871076e6df
4
+ data.tar.gz: bf3fedd286e9acbc2046eb2ccdd1f9df8b9e1b1b6627862f6788b4b195cd4833
5
5
  SHA512:
6
- metadata.gz: fbb4fe3d82e1c47ecee7af3578290fd1ff97a0d8a2a0556103c345e636916e134c9cae51105982f329eb275cc773719d89f0901630a83daaa092c01b612267b2
7
- data.tar.gz: 975d14bf33f828ff65fcee758d11fc678ce688fe2e07b4d5ca33a89949337c995fb94f0fa06bc8de00dab312a3665a14515907236c552d8bf295a05035341768
6
+ metadata.gz: 0d482aba906025d5d56d2e85672880f10738a56bd770fcce8b8f22871cb34103aefc6bac3a353a781a15d18350780d9fd66d02632fc8615d742f3cfaf2eef5e5
7
+ data.tar.gz: f80ce4b8758e17d21681e8bbd15fa4450e39121e8fc05c825d8b740b76f647c37a21789464ad85f93828fa7d7fde413673c3b223bf6f96a5a0bc808a8c6621b8
@@ -91,7 +91,7 @@ module TracWiki
91
91
  attr_writer :math
92
92
  def math?; @math; end
93
93
 
94
- # allow some <b> <form> <html>
94
+ # allow some <b> <form> <html>
95
95
  # html will be sanitized
96
96
  attr_writer :allow_html
97
97
  def allow_html?; @allow_html; end
@@ -255,7 +255,7 @@ module TracWiki
255
255
  begin
256
256
  sprintf fmt, *args
257
257
  rescue Exception => e
258
- "(sprintf error:`#{e}`)"
258
+ "(sprintf error:`#{e}`)"
259
259
  end
260
260
  },
261
261
  '!digest' => proc { |env| Base64.urlsafe_encode64(Digest::SHA256.digest(env.expand_arg(0))) },
@@ -376,6 +376,13 @@ module TracWiki
376
376
  end
377
377
  end
378
378
 
379
+ def end_to_tag(tag)
380
+ if @stack.include?(tag)
381
+ end_tag while @stack.last != tag
382
+ end_tag
383
+ end
384
+ end
385
+
379
386
  def end_paragraph
380
387
  end_tag while !@stack.empty?
381
388
  @p = false
@@ -515,7 +522,7 @@ module TracWiki
515
522
  notlink, link = $1, $2
516
523
  make_link(link, nil, link, 0, !!notlink)
517
524
  # [[Image(pic.jpg|tag)]]
518
- when str =~ /\A\[\[Image\(([^,]*?)(,(.*?))?\)\]\]/ # image
525
+ when str =~ /\A\[\[Image\(([^,]*?)(,(.*?))?\)\]\]/ # image
519
526
  make_image($1, $3)
520
527
  # [[link]]
521
528
  # [ link2 | text5 ]
@@ -543,7 +550,7 @@ module TracWiki
543
550
  when math? && str =~ /\A\$(.+?)\$/ # inline math (tt)
544
551
  @tree.tag(:span, {:class => 'math'}, $1)
545
552
  @was_math = true
546
- when str =~ /\A(\&\w*;)/ # html entity
553
+ when str =~ /\A(\&\w*;)/ # html entity
547
554
  #print "add html ent: #{$1}\n"
548
555
  @tree.add_raw($1)
549
556
  when str =~ /\A([:alpha:]|[:digit:])+/
@@ -571,7 +578,7 @@ module TracWiki
571
578
  when str =~ /\A,,/
572
579
  toggle_tag 'sub', $& # _{}
573
580
  when str =~ /\A!\./
574
- @tree.add('') # !. \relax
581
+ @tree.add('') # !. \relax
575
582
  when str =~ /\A!(\{\{|[\S])/
576
583
  @tree.add($1) # !neco !{{
577
584
  # when str =~ /\A!(\{\{)/
@@ -761,6 +768,29 @@ module TracWiki
761
768
  end_paragraph
762
769
  @tree.tag(:div, { class: "merge #{merge_class}" }, who)
763
770
  end
771
+
772
+ def do_wikimedia_table(text)
773
+ end_paragraph
774
+ start_tag(:table)
775
+ start_tag(:tr)
776
+ offset = 0
777
+ text.split("\n").each do |line|
778
+ offset += line.length + 1
779
+ if line == '|-'
780
+ end_to_tag :tr
781
+ start_tag(:tr)
782
+ elsif line =~ /^([!\|])(.*)/
783
+ end_to_tag :td
784
+ fst, rest = $1, $2
785
+ start_tag($1 == '|' ? :td : :th)
786
+ parse_inline(rest.strip, offset)
787
+ else
788
+ parse_inline(' ' +line.strip, offset)
789
+ end
790
+ end
791
+ end_to_tag :table
792
+ end
793
+
764
794
  def do_pre(text)
765
795
  end_paragraph
766
796
  nowikiblock = make_nowikiblock(text)
@@ -876,6 +906,9 @@ module TracWiki
876
906
  # pre {{{ ... }}}
877
907
  when str =~ /\A\{\{\{\r?\n(.*?)\r?\n\}\}\}/m
878
908
  do_pre($1)
909
+ # wikimedia table {| ... |}
910
+ when str =~ /\A\{\|\r?\n(.*?)\r?\n\|\}/m
911
+ do_wikimedia_table($1)
879
912
  # horizontal rule
880
913
  when str =~ /\A\s*-{4,}\s*$/
881
914
  do_hr()
@@ -892,11 +925,11 @@ module TracWiki
892
925
  #when str =~ /\A([:\w\s]+)::(\s+|\r?\n)/
893
926
  when str =~ /\A(.+)::(\s+|\r?\n)/
894
927
  do_term($1)
895
- # li
928
+ # li *
896
929
  when str =~ /\A((\s*)([*-]|[aAIi\d]\.)\s+)(.*?)$(\r?\n)?/
897
930
  parse_li_line($2.size, $3)
898
931
  parse_inline($4, $1.size)
899
- # citation
932
+ # citation >
900
933
  when str =~ /\A(>[>\s]*)(.*?)$(\r?\n)?/
901
934
  do_citation($1.count('>'))
902
935
  parse_inline($2, $1.size)
@@ -1,3 +1,3 @@
1
1
  module TracWiki
2
- VERSION = '0.3.37'
2
+ VERSION = '0.3.38'
3
3
  end
@@ -675,6 +675,11 @@ describe 'TracWiki::Parser' do
675
675
  tc "<p>-- --</p>\n", "--\t-- "
676
676
  end
677
677
 
678
+ it 'should parse wm-table' do
679
+ tc "<table><tr><td>Hello</td>\n<th>World!</th>\n</tr>\n<tr><td>Hello</td>\n<td>World!</td>\n</tr>\n</table>\n", "{|\n|Hello\n!World!\n|-\n|Hello\n|World!\n|}\n\n"
680
+ tc "<table><tr><td><strong>Hello</strong></td>\n<td>World!</td>\n</tr>\n<tr><td>Hello</td>\n<td>World!</td>\n</tr>\n</table>\n", "{|\n|**Hello**\n|World!\n|-\n|Hello\n|World!\n|}\n\n"
681
+ tc "<table><tr><td><strong>Hello</strong></td>\n<td>Wor ld</td>\n</tr>\n</table>\n", "{|\n|**Hello**\n|Wor\nld\n|}\n\n"
682
+ end
678
683
  it 'should parse table' do
679
684
  tc "<table><tr><td>Hello</td>\n<td>World!</td>\n</tr>\n</table>\n", "||Hello||World!||"
680
685
  tc "<table><tr><td>Hello</td>\n<td>World!</td>\n</tr>\n<tr><td>Hello</td>\n<td>World!</td>\n</tr>\n</table>\n", "||Hello||World!||\n||Hello||World!||\n\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trac-wiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.37
4
+ version: 0.3.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitas Stradal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-12 00:00:00.000000000 Z
11
+ date: 2019-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bacon