diff options
-rw-r--r-- | lib/Text/MarkdownBook/Book.pm | 8 |
1 files changed, 7 insertions, 1 deletions
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\""); |