Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed support for Unicode anchors in Mojolicious::Plugin::PODRenderer
(closes #652)
  • Loading branch information
kraih committed Jul 24, 2014
1 parent a9a574a commit b193c67
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -3,6 +3,7 @@
- Welcome to the Mojolicious core team Jan Henning Thorsen.
- Added val method to Mojo::DOM. (batman, sri)
- Improved Mojo::Collection performance.
- Fixed support for Unicode anchors in Mojolicious::Plugin::PODRenderer.

5.16 2014-07-21
- Improved Mojo::Asset::File to allow appending data to existing files.
Expand Down
7 changes: 3 additions & 4 deletions lib/Mojolicious/Plugin/PODRenderer.pm
Expand Up @@ -58,13 +58,12 @@ sub _html {
# Rewrite headers
my $toc = Mojo::URL->new->fragment('toc');
my (%anchors, @parts);
my $pod = Pod::Simple::HTML->new;
for my $e ($dom->find('h1, h2, h3')->each) {

# Anchor and text
my $name = my $text = $e->all_text;
$name =~ s/\s+/_/g;
$name =~ s/[^\w\-]//g;
my $anchor = $name;
my $text = $e->all_text;
my $anchor = my $name = $pod->section_escape($text);
my $i = 1;
$anchor = $name . $i++ while $anchors{$anchor}++;

Expand Down
4 changes: 3 additions & 1 deletion lib/Mojolicious/templates/mojobar.html.ep
Expand Up @@ -111,7 +111,9 @@
$(".mojoscroll").click(function(e) {
e.preventDefault();
e.stopPropagation();
var hash = "#" + this.href.split("#")[1];
var hash = this.href.split("#")[1];
hash = hash.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&");
hash = "#" + hash;
var target = $(hash);
var old = target.attr('id');
target.attr('id', '');
Expand Down

0 comments on commit b193c67

Please sign in to comment.