diff options
author | Russ Allbery <eagle@eyrie.org> | 2010-09-26 23:15:11 +0000 |
---|---|---|
committer | Russ Allbery <eagle@eyrie.org> | 2010-09-26 23:15:11 +0000 |
commit | f95c170a04a8cc9daeafa50e5beff13c666ced0f (patch) | |
tree | 24d49bf2d484ac1571360fce9447b9ee434de5f8 | |
parent | 6b40eedd4752b8d8fc6a985876dd4d1220afddd9 (diff) |
When doing special parsing of table cells, extract <div> tags with all of
their options and lift the options into the <td> tag similar to how <span>
already worked. Add a border at the end of each table cell so that a
construct like <ul> wouldn't stay open across table cells.
-rwxr-xr-x | bin/spin | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -690,9 +690,9 @@ sub inline { } # Enclose some text in another tag. The one special thing that we do is if -# the enclosed text is entirely enclosed in <span> tags, we pull the options -# of the <span> out and instead apply them to the parent tag. Takes the tag -# and the text to enclose. +# the enclosed text is entirely enclosed in <span> or <div> tags, we pull the +# options of the <span> or <div> out and instead apply them to the parent tag. +# Takes the tag and the text to enclose. sub enclose { my ($tag, $text) = @_; my $close = $tag; @@ -700,6 +700,9 @@ sub enclose { if ($text =~ m%^(\s*)<span(?!.*<span)([^>]*)>(.*)</span>(\s*)\z%s) { my ($lead, $class, $text, $trail) = ($1, $2, $3, $4); return "$lead<$tag$class>$text</$close>$trail"; + } elsif ($text =~ m%^(\s*)<div(?!.*<div)([^>]*)>(.*)</div>(\s*)\z%s) { + my ($lead, $class, $text, $trail) = ($1, $2, $3, $4); + return "$lead<$tag$class>$text</$close>$trail"; } else { return "<$tag>$text</$close>"; } @@ -1008,7 +1011,7 @@ sub do_tablehead { my ($format, @cells) = @_; my $output = ' <tr' . format_string ($format) . ">\n"; for (@cells) { - $output .= ' ' . enclose ('th', parse ($_)) . "\n"; + $output .= ' ' . enclose ('th', parse ($_) . border) . "\n"; } $output .= " </tr>\n"; return (1, $output); @@ -1019,7 +1022,7 @@ sub do_tablerow { my ($format, @cells) = @_; my $output = ' <tr' . format_string ($format) . ">\n"; for (@cells) { - $output .= ' ' . enclose ('td', parse ($_)) . "\n"; + $output .= ' ' . enclose ('td', parse ($_) . border) . "\n"; } $output .= " </tr>\n"; return (1, $output); |