Changeset 280
- Timestamp:
- 02/09/08 23:49:25 (10 months ago)
- Files:
-
- trunk/src/ingy/Document-Tools/lib/Document/Emitter/HTML.pm (modified) (5 diffs)
- trunk/src/ingy/WikiText-Creole/lib/WikiText/Creole/Parser.pm (modified) (3 diffs)
- trunk/src/ingy/WikiText-Creole/t/data/lists (modified) (1 diff)
- trunk/src/ingy/WikiText-Creole/t/data/phrases (added)
- trunk/src/ingy/WikiText-Creole/t/data/tables (added)
- trunk/src/ingy/WikiText-Creole/t/phrases_html.t (added)
- trunk/src/ingy/WikiText-Creole/t/tables_html.t (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/ingy/Document-Tools/lib/Document/Emitter/HTML.pm
r278 r280 5 5 use base 'Document::Receiver'; 6 6 use CGI::Util; 7 8 my $type_tags = { 9 b => 'strong', 10 i => 'em', 11 wikilink => 'a', 12 }; 7 13 8 14 sub init { … … 31 37 my $self = shift; 32 38 my $node = shift; 33 my $tag = $node->{type}; 39 my $type = $node->{type}; 40 my $tag = $type_tags->{$type} || $type; 34 41 # XXX For tables maybe... 35 42 # $tag =~ s/-.*//; … … 37 44 ($tag =~ /^(br|hr)$/) 38 45 ? "<$tag />\n" 39 : ($t ageq "wikilink")46 : ($type eq "wikilink") 40 47 ? $self->begin_wikilink($node) 41 : "<$tag>"; 48 : "<$tag>" . 49 ($tag =~ /^(ul|ol|table|tr)$/ ? "\n" : ""); 42 50 } 43 51 … … 56 64 my $self = shift; 57 65 my $node = shift; 58 my $tag = $node->{type}; 66 my $type = $node->{type}; 67 my $tag = $type_tags->{$type} || $type; 59 68 $tag =~ s/-.*//; 60 69 return if ($tag =~ /^(br|hr)$/); … … 64 73 } 65 74 $self->{output} .= "</$tag>" . 66 ($tag =~ /^(p|hr| table|ul|ol|h\d)$/ ? "\n" : "");75 ($tag =~ /^(p|hr|ul|ol|li|h\d|table|tr|td)$/ ? "\n" : ""); 67 76 } 68 77 trunk/src/ingy/WikiText-Creole/lib/WikiText/Creole/Parser.pm
r279 r280 4 4 sub create_grammar { 5 5 my $all_blocks = [ 6 'pre','h6', 'h5', 'h4', 'h3', 'h2', 'h1', 6 'pre', 'table', 7 'h6', 'h5', 'h4', 'h3', 'h2', 'h1', 7 8 'ul', 'ol', 'hr', 'p', 8 9 ]; … … 28 29 ?:[\#\-\*]+\ # Lists 29 30 | 30 [\^\|\>] # Headings and indents 31 | 32 \.\w+\s*\n) # Wafl blocks 33 ) 31 [\=\|] # Headings and tables 32 )) 34 33 .*\S.*\n)+ # Otherwise, collect non-empty lines 35 34 ) … … 42 41 match => qr/^\{\{\{\n(.*?\n)\}\}\}\n+/s, 43 42 }, 43 table => { 44 match => qr/^((\|.*\n)+)\n*/m, 45 blocks => ['tr'], 46 }, 47 tr => { 48 match => qr/^(\|.*\n)/m, 49 blocks => ['td'], 50 filter => sub { s/\|\s*$// }, 51 }, 52 td => { 53 match => qr/^\|([^\|]*)/, 54 phrases => $all_phrases, 55 filter => sub { s/^\s*(.*?)\s*$/$1/ }, 56 }, 44 57 h1 => { 45 58 match => re_header(1), 46 phrases => $all_phrases,47 59 }, 48 60 h2 => { 49 61 match => re_header(2), 50 phrases => $all_phrases,51 62 }, 52 63 h3 => { 53 64 match => re_header(3), 54 phrases => $all_phrases,55 65 }, 56 66 h4 => { 57 67 match => re_header(4), 58 phrases => $all_phrases,59 68 }, 60 69 h5 => { 61 70 match => re_header(5), 62 phrases => $all_phrases,63 71 }, 64 72 h6 => { 65 73 match => re_header(6), 66 phrases => $all_phrases,67 74 }, 68 75 ul => { trunk/src/ingy/WikiText-Creole/t/data/lists
r273 r280 15 15 -ul 16 16 --- html 17 <ul><li>Item one.<ul><li>Subitem one.</li></ul> 18 </li></ul> 17 <ul> 18 <li>Item one.<ul> 19 <li>Subitem one.</li> 20 </ul> 21 </li> 22 </ul> 19 23 === Sublists are well formed XHTML 20 24 --- creole
