Subject: | PATCH: Support IDs for headings |
Currently if you have an ID for your heading it is missing from the output. Markdown allows heading anchors to be specified after the heading.
e.g.
## This is a big heading {#thisisitsid}
Here is a small patch to enable this behaviour:
diff --git a/lib/HTML/WikiConverter/Markdown.pm b/lib/HTML/WikiConverter/Markdown.pm
index 3c5b1e3..5d46e69 100644
--- a/lib/HTML/WikiConverter/Markdown.pm
+++ b/lib/HTML/WikiConverter/Markdown.pm
@@ -152,14 +152,20 @@ sub _header_start {
sub _header_end {
my( $self, $node, $rules ) = @_;
- return '' unless $self->header_style eq 'setext';
+ my $anchor = '';
+
+ if($node->id()) {
+ $anchor = "\t{#" . $node->id() . "}";
+ }
+
+ return $anchor unless $self->header_style eq 'setext';
( my $level = $node->tag ) =~ s/\D//g;
- return unless $level;
+ return $anchor unless $level;
my $symbol = $level == 1 ? '=' : '-';
my $len = length $self->get_elem_contents($node);
my $bar = ($symbol) x $len;
- return "\n$bar\n";
+ return "$anchor\n$bar\n";
}
sub _link {