summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-08-12 09:51:18 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-08-12 09:51:18 (EDT)
commitc0f12961b11ab4f8ec839c911dd5d4dff03a7092 (patch)
treead168042fcb28ca154183a0c403256b4cc1004e4 /scripts
parent16676d4ba54db28e6abf38c1df9970398e877026 (diff)
Implement "sectlink" macro.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/MarkdownBook/Book.pm4
1 files changed, 4 insertions, 0 deletions
diff --git a/scripts/MarkdownBook/Book.pm b/scripts/MarkdownBook/Book.pm
index 09225df..a3d9eeb 100644
--- a/scripts/MarkdownBook/Book.pm
+++ b/scripts/MarkdownBook/Book.pm
@@ -189,10 +189,14 @@ sub subst_macros
sub _do_subst_macro
{
my ($self, $macro, @args) = @_;
+ my $sec;
if ($macro eq 'toc') {
return $self->_do_gen_toc();
} elsif ($macro eq 'sectlink') {
+ die('Invalid arguments to "sectlink" macro') if @args != 1;
+ $sec = $self->{'sections_by_id'}->{$args[0]};
+ return '[ยง ' . $sec->number() . '][' . $sec->id() . ']';
} else {
die("Unrecognized macro \"$macro\"");
}