summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-08-13 21:56:23 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-08-13 21:56:23 (EDT)
commit8fcbf58f2ca41b492aaf0336f118314b0fa69daa (patch)
tree8d558e812ecb44a78120270b82ac280554ef783d
parent477e047c6e89332bf5dfb49eb2ceedaf62f4b3dd (diff)
Support chapters in sectlink macro.
-rw-r--r--lib/Text/MarkdownBook/Book.pm8
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\"");