Skip Menu |

This queue is for tickets about the HTML-WikiConverter-Markdown CPAN distribution.

Report information
The Basics
Id: 97385
Status: resolved
Priority: 0/
Queue: HTML-WikiConverter-Markdown

People
Owner: Jeff.Fearn [...] gmail.com
Requestors: Jeff.Fearn [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.05
Fixed in: 0.06



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 {
P.S. you can pull from github if you want. https://github.com/jfearn/HTML-WikiConverter-Markdown