blocks; handle blocks with ` in them.
+
+---
+ WikiConverter/Markdown.pm | 21 ++++++++++++++++++++-
+ 1 files changed, 20 insertions(+), 1 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -114,8 +114,9 @@ sub rules {
+ em => { alias => 'i' },
+ b => { start => '**', end => '**' },
+ strong => { alias => 'b' },
+- code => { start => '`', end => '`' },
+
++ code => { replace => \&_code },
++ pre => { replace => \&_pre },
+ a => { replace => \&_link },
+ img => { replace => \&_img },
+ );
+@@ -153,6 +154,24 @@ sub _header_end {
+ return "\n$bar\n";
+ }
+
++sub _code {
++ my( $self, $node, $rules ) = @_;
++
++ my $text = $self->get_elem_contents($node);
++
++ my @list = sort { length($b) cmp length($a) } ($text =~ /`+/g);
++ return "`" . $list[0] . $text . $list[0] . "`";
++}
++
++sub _pre {
++ my( $self, $node, $rules ) = @_;
++
++ my $text = $self->get_elem_contents($node);
++
++ $text =~ s/^/ /mg;
++ return $text;
++}
++
+ sub _link {
+ my( $self, $node, $rules ) = @_;
+
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1011-Handle-tt-the-same-as-code.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1011-Handle-tt-the-same-as-code.patch
@@ -0,0 +1,19 @@
+From 9dd933238f25cab8eb04b2150bdfc8a5748cd158 Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Sun, 10 Dec 2006 23:30:52 -0800
+Subject: [PATCH] Handle the same as .
+
+---
+ WikiConverter/Markdown.pm | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -115,6 +115,7 @@ sub rules {
+ b => { start => '**', end => '**' },
+ strong => { alias => 'b' },
+
++ tt => { alias => 'code' },
+ code => { replace => \&_code },
+ pre => { replace => \&_pre },
+ a => { replace => \&_link },
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1004-Preserve-all-unsupported-inline-elements.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1004-Preserve-all-unsupported-inline-elements.patch
@@ -0,0 +1,22 @@
+From 4c3c91acc8c4c5836eb94f7bfd5806ed946d4610 Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Fri, 8 Dec 2006 23:34:42 -0800
+Subject: [PATCH] Preserve all unsupported inline elements.
+
+---
+ WikiConverter/Markdown.pm | 4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -129,6 +129,10 @@ sub rules {
+ $rules{$_} = { preserve => 1, attrs => \@common_attrs, start => "\n", end => "\n", line_format => 'multi' };
+ }
+
++ for(keys(%HTML::Tagset::isPhraseMarkup)) {
++ $rules{$_} = { preserve => 1, attrs => \@common_attrs } if !exists $rules{$_};
++ }
++
+ return \%rules;
+ }
+
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1009-Avoid-using-an-uninitialized-value-if-code-has-no-backquotes-inside.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1009-Avoid-using-an-uninitialized-value-if-code-has-no-backquotes-inside.patch
@@ -0,0 +1,21 @@
+From 9c35c24400f4ec9fd993990e2b22d5a2a3e81dce Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Sat, 9 Dec 2006 01:34:04 -0800
+Subject: [PATCH] Avoid using an uninitialized value if has no backquotes inside.
+
+---
+ WikiConverter/Markdown.pm | 3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -179,7 +179,8 @@ sub _code {
+ my $text = $self->get_elem_contents($node);
+
+ my @list = sort { length($b) cmp length($a) } ($text =~ /`+/g);
+- return "`" . $list[0] . $text . $list[0] . "`";
++ my $longest_backquotes = $list[0] || "";
++ return "`" . $longest_backquotes . $text . $longest_backquotes . "`";
+ }
+
+ sub _pre {
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1013-Allow-passing-through-raw-markdown-syntax-wrapped-in-markdown-tags.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1013-Allow-passing-through-raw-markdown-syntax-wrapped-in-markdown-tags.patch
@@ -0,0 +1,32 @@
+From 2bd53a175277d58d75f631dafe00cbf5012079b0 Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Sun, 17 Dec 2006 18:22:53 -0800
+Subject: [PATCH] Allow passing through raw markdown syntax wrapped in tags.
+
+---
+ WikiConverter/Markdown.pm | 7 +++++++
+ 1 files changed, 7 insertions(+), 0 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -121,6 +121,7 @@ sub rules {
+ pre => { replace => \&_pre },
+ a => { replace => \&_link },
+ img => { replace => \&_img },
++ markdown => { replace => \&_raw_passthrough },
+ );
+
+ for( 1..6 ) {
+@@ -146,6 +147,12 @@ sub _has_elements {
+ return 0;
+ }
+
++sub _raw_passthrough {
++ my( $self, $node, $rules ) = @_;
++ $node->deobjectify_text();
++ return $node->as_text();
++}
++
+ sub _blockelem {
+ my( $self, $node, $rules ) = @_;
+ $node->deobjectify_text();
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1015_Adjust_tests_for_changed_block_handling_in_patches_1006-1007.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1015_Adjust_tests_for_changed_block_handling_in_patches_1006-1007.patch
@@ -0,0 +1,35 @@
+--- a/t/markdown.t
++++ b/t/markdown.t
+@@ -290,19 +290,19 @@ __H__
+
+ __W__
+
+-My favorite animals
+-
+-Animal
+-Region
+-Physical traits
+-Food
+-
+-
+-Pacman frog
+-Gran Chaco (Argentina)
+-Half mouth, half stomach (quite literally!)
+-Crickets, fish, etc.
+-
++ My favorite animals
++
++ Animal
++ Region
++ Physical traits
++ Food
++
++
++ Pacman frog
++ Gran Chaco (Argentina)
++ Half mouth, half stomach (quite literally!)
++ Crickets, fish, etc.
++
+
+ __NEXT__
+ setext header ::header_style('setext')
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1010-Strip-formatting-inside-wiki-links.-Markdown-links-can-have-formatting-so-stop-using-a-for-that.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1010-Strip-formatting-inside-wiki-links.-Markdown-links-can-have-formatting-so-stop-using-a-for-that.patch
@@ -0,0 +1,60 @@
+From 71e93d0a82a97cc28d51fedc0c59307c17f976d2 Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Sat, 9 Dec 2006 14:53:52 -0800
+Subject: [PATCH] Strip formatting inside wiki links. Markdown links can have formatting, so stop using for that.
+
+---
+ WikiConverter/Markdown.pm | 20 ++++++++++++--------
+ 1 files changed, 12 insertions(+), 8 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -136,6 +136,14 @@ sub rules {
+ return \%rules;
+ }
+
++sub _has_elements {
++ my($node) = @_;
++ for($node->content_list) {
++ return 1 if($_->tag ne "~text");
++ }
++ return 0;
++}
++
+ sub _blockelem {
+ my( $self, $node, $rules ) = @_;
+ $node->deobjectify_text();
+@@ -186,9 +194,7 @@ sub _code {
+ sub _pre {
+ my( $self, $node, $rules ) = @_;
+
+- for($node->content_list) {
+- return _blockelem(@_) if($_->tag ne "~text");
+- }
++ return _blockelem(@_) if _has_elements($node);
+
+ my $text = $self->get_elem_contents($node);
+ $text =~ s/^/ /mg;
+@@ -201,19 +207,17 @@ sub _link {
+
+ return $self->_inline_elem($node, $rules) if( $node->attr('name') );
+
+- for($node->content_list) {
+- return $self->_inline_elem($node, $rules) if($_->tag ne "~text");
+- }
+-
+ my $url = $node->attr('href') || '';
+- my $text = $self->get_elem_contents($node);
+
+ # Handle internal links
+ if( my $pagename = $self->get_wiki_page( $url ) ) {
++ $node->deobjectify_text();
++ my $text = $node->as_text();
+ return "[[$text]]" if lc $text eq lc $pagename;
+ return "[[$text|$pagename]]";
+ }
+
++ my $text = $self->get_elem_contents($node);
+ $url = $self->_abs2rel($url);
+ my $title = $node->attr('title') || '';
+
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1008-Use-HTML-for-a-with-name-attr-or-child-elements-preserve-markdown-inside-a.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1008-Use-HTML-for-a-with-name-attr-or-child-elements-preserve-markdown-inside-a.patch
@@ -0,0 +1,42 @@
+From 8288f49029be78b21d9a760522f77a88f7f48c28 Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Sat, 9 Dec 2006 01:08:44 -0800
+Subject: [PATCH] Use HTML for with name attr or child elements; preserve markdown inside .
+
+Overly conservative; markdown links can have inline markdown in their text.
+---
+ WikiConverter/Markdown.pm | 16 ++++++++++++++++
+ 1 files changed, 16 insertions(+), 0 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -142,6 +142,15 @@ sub _blockelem {
+ return $node->as_HTML('<>&', ' ', {});
+ }
+
++sub _inline_elem {
++ my( $self, $node, $rules ) = @_;
++
++ my $content = $self->get_elem_contents($node);
++ my $empty = $rules->{empty} && ($content eq '');
++ my $end = $empty ? '' : ($content . '' . $node->tag . '>');
++ return $self->__preserve_start($node, $rules) . $end;
++}
++
+ sub _header_start {
+ my( $self, $node, $rules ) = @_;
+ return '' unless $self->header_style eq 'atx';
+@@ -187,6 +196,13 @@ sub _pre {
+
+ sub _link {
+ my( $self, $node, $rules ) = @_;
++ $rules = { attributes => ['name', 'href', @common_attrs] };
++
++ return $self->_inline_elem($node, $rules) if( $node->attr('name') );
++
++ for($node->content_list) {
++ return $self->_inline_elem($node, $rules) if($_->tag ne "~text");
++ }
+
+ my $url = $node->attr('href') || '';
+ my $text = $self->get_elem_contents($node);
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1005-A-markdown-pre-block-will-escape-markdown-or-markup-so-output-pre-s-with-child-elements-as-HTML.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1005-A-markdown-pre-block-will-escape-markdown-or-markup-so-output-pre-s-with-child-elements-as-HTML.patch
@@ -0,0 +1,27 @@
+From 8a787239c3c5e106ff500450e96ac28807c7675d Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Fri, 8 Dec 2006 23:54:54 -0800
+Subject: [PATCH] A markdown block will escape markdown or markup, so output s with child elements as HTML.
+
+---
+ WikiConverter/Markdown.pm | 8 +++++++-
+ 1 files changed, 7 insertions(+), 1 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -170,8 +170,14 @@ sub _code {
+ sub _pre {
+ my( $self, $node, $rules ) = @_;
+
+- my $text = $self->get_elem_contents($node);
++ for($node->content_list) {
++ if($_->tag ne "~text") {
++ $node->deobjectify_text();
++ return $node->as_HTML();
++ }
++ }
+
++ my $text = $self->get_elem_contents($node);
+ $text =~ s/^/ /mg;
+ return $text;
+ }
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1002-Use-syntax-for-mailto-URLs-with-the-email-as-link-text.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1002-Use-syntax-for-mailto-URLs-with-the-email-as-link-text.patch
@@ -0,0 +1,22 @@
+From 088ecec94d2e7d8222704e5cf1a0e43e566777a0 Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Fri, 8 Dec 2006 22:51:18 -0800
+Subject: [PATCH] Use <> syntax for mailto URLs with the email as link text.
+
+---
+ WikiConverter/Markdown.pm | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -171,8 +171,8 @@ sub _link {
+ my $style = $self->link_style;
+ $style = 'inline' if $url =~ /^\#/ and $self->force_inline_anchor_links;
+
+- if( $url eq $text ) {
+- return sprintf "<%s>", $url;
++ if( $url =~ /^(?:mailto:)?\Q$text\E$/ ) {
++ return sprintf "<%s>", $text;
+ } elsif( $style eq 'inline' ) {
+ return sprintf "[%s](%s %s)", $text, $url, $title if $title;
+ return sprintf "[%s](%s)", $text, $url;
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/README.origin
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/README.origin
@@ -0,0 +1,4 @@
+ * Patches 1001-1014 was found at
+ http://svcs.cs.pdx.edu/~jamey/wikiconverter/ and discussed at
+ http://ikiwiki.info/index/discussion/#index4h1 and at
+ http://www.bddebian.com/~wiki/AboutTheTWikiToIkiwikiConversion/ .
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/README
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/README
@@ -0,0 +1,3 @@
+0xxx: Grabbed from upstream development.
+1xxx: Possibly relevant for upstream adoption.
+2xxx: Only relevant for official Debian release.
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1007-Remove-special-handling-for-tables-now-subsumed-by-general-block-element-handling.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1007-Remove-special-handling-for-tables-now-subsumed-by-general-block-element-handling.patch
@@ -0,0 +1,22 @@
+From 9e4dfef118e0ecd604bc72b5cb22c2c59a1458cf Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Sat, 9 Dec 2006 00:26:09 -0800
+Subject: [PATCH] Remove special handling for tables, now subsumed by general block element handling.
+
+---
+ WikiConverter/Markdown.pm | 4 ----
+ 1 files changed, 0 insertions(+), 4 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -125,10 +125,6 @@ sub rules {
+ $rules{"h$_"} = { start => \&_header_start, end => \&_header_end, trim => 'both', block => 1 };
+ }
+
+- for( qw/ table caption tr th td / ) {
+- $rules{$_} = { preserve => 1, attrs => \@common_attrs, start => "\n", end => "\n", line_format => 'multi' };
+- }
+-
+ for(keys(%HTML::Tagset::isPhraseMarkup)) {
+ $rules{$_} = { preserve => 1, attrs => \@common_attrs } if !exists $rules{$_};
+ }
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/1012-Allow-and-use-rules-for-text-nodes-as-an-alternative-to-escaping-in-preprocessing.patch
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/1012-Allow-and-use-rules-for-text-nodes-as-an-alternative-to-escaping-in-preprocessing.patch
@@ -0,0 +1,61 @@
+From b0cd90c32240bc0c39236a8eb3259547a3752f4e Mon Sep 17 00:00:00 2001
+From: Jamey Sharp
+Date: Mon, 11 Dec 2006 01:42:57 -0800
+Subject: [PATCH] Allow and use rules for ~text nodes, as an alternative to escaping in preprocessing.
+
+---
+ WikiConverter.pm | 15 ++++++++-------
+ WikiConverter/Markdown.pm | 14 +++++++++-----
+ 2 files changed, 17 insertions(+), 12 deletions(-)
+
+--- a/lib/HTML/WikiConverter/Markdown.pm
++++ b/lib/HTML/WikiConverter/Markdown.pm
+@@ -102,6 +102,7 @@ sub rules {
+ my $self = shift;
+
+ my %rules = (
++ '~text' => { replace => \&_escape_text },
+ hr => { replace => "\n\n----\n\n" },
+ br => { preserve => 1, empty => 1 },
+ p => { block => 1, trim => 'both', line_format => 'multi', line_prefix => \&_p_prefix },
+@@ -185,7 +186,10 @@ sub _header_end {
+ sub _code {
+ my( $self, $node, $rules ) = @_;
+
+- my $text = $self->get_elem_contents($node);
++ return _inline_elem(@_) if _has_elements($node);
++
++ $node->deobjectify_text();
++ my $text = $node->as_text();
+
+ my @list = sort { length($b) cmp length($a) } ($text =~ /`+/g);
+ my $longest_backquotes = $list[0] || "";
+@@ -197,7 +201,9 @@ sub _pre {
+
+ return _blockelem(@_) if _has_elements($node);
+
+- my $text = $self->get_elem_contents($node);
++ $node->deobjectify_text();
++ my $text = $node->as_text();
++
+ $text =~ s/^/ /mg;
+ return $text;
+ }
+@@ -321,8 +327,6 @@ sub preprocess_node {
+
+ if( $node->parent->tag eq 'blockquote' and $self->_is_phrase_tag($node->tag) ) {
+ $self->_envelop_elem( $node, HTML::Element->new('p') );
+- } elsif( $node->tag eq '~text' ) {
+- $self->_escape_text($node);
+ }
+ }
+
+@@ -344,7 +348,7 @@ sub _escape_text {
+ $text =~ s/\!\[/\\![/g;
+ $text =~ s/\]\[/]\\[/g;
+ $text =~ s/\[\[/\\[[/g;
+- $node->attr( text => $text );
++ return $text;
+ }
+
+ sub postprocess_output {
--- libhtml-wikiconverter-markdown-perl-0.02.orig/debian/patches/series
+++ libhtml-wikiconverter-markdown-perl-0.02/debian/patches/series
@@ -0,0 +1,15 @@
+1001-Add-support-for-ikiwiki-links-if-wiki-uri-is-specified.patch
+1002-Use-syntax-for-mailto-URLs-with-the-email-as-link-text.patch
+1003-Use-indentation-for-pre-blocks-handle-code-blocks-with-in-them.patch
+1004-Preserve-all-unsupported-inline-elements.patch
+1005-A-markdown-pre-block-will-escape-markdown-or-markup-so-output-pre-s-with-child-elements-as-HTML.patch
+1006-Output-all-unknown-block-level-elements-and-their-descendants-unchanged.patch
+1007-Remove-special-handling-for-tables-now-subsumed-by-general-block-element-handling.patch
+1008-Use-HTML-for-a-with-name-attr-or-child-elements-preserve-markdown-inside-a.patch
+1009-Avoid-using-an-uninitialized-value-if-code-has-no-backquotes-inside.patch
+1010-Strip-formatting-inside-wiki-links.-Markdown-links-can-have-formatting-so-stop-using-a-for-that.patch
+1011-Handle-tt-the-same-as-code.patch
+1012-Allow-and-use-rules-for-text-nodes-as-an-alternative-to-escaping-in-preprocessing.patch
+1013-Allow-passing-through-raw-markdown-syntax-wrapped-in-markdown-tags.patch
+1014-Some-entity-handling-and-refactoring.patch
+1015_Adjust_tests_for_changed_block_handling_in_patches_1006-1007.patch