From 8fcbf58f2ca41b492aaf0336f118314b0fa69daa Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 13 Aug 2012 21:56:23 -0400 Subject: Support chapters in sectlink macro. --- (limited to 'lib/Text') diff --git a/lib/Text/MarkdownBook/Book.pm b/lib/Text/MarkdownBook/Book.pm index 4c49d1d..4c5f6c7 100644 --- a/lib/Text/MarkdownBook/Book.pm +++ b/lib/Text/MarkdownBook/Book.pm @@ -201,7 +201,13 @@ sub _do_subst_macro Carp::carp('Invalid arguments to "sectlink" macro'); } else { $sec = $self->{'sections_by_id'}->{$args[0]}; - return '[§ ' . $sec->number() . '][' . $sec->id() . ']'; + if (ref($sec) =~ m/^Text::MarkdownBook::Document/) { + return '[§ ' . $sec->id() . '][' . $sec->file() . ']'; + } elsif (ref($sec) eq 'Text::MarkdownBook::Section') { + return '[§ ' . $sec->number() . '][' . $sec->id() . ']'; + } else { + Carp::carp("Unknown section \"$args[0]\" in sectlink macro"); + } } } else { Carp::carp("Unrecognized macro \"$macro\""); -- cgit v0.9.1