-rw-r--r-- | tags/b7/57/20170709220241.C21661C0A9@jawa.homebase.dk/unread | 0 |
#!/usr/bin/perl package IkiWiki::Plugin::h1title; use warnings; use strict; use IkiWiki 2.00; sub import { hook(type => "filter", id => "h1title", call => \&filter); } sub filter(@) { my %params = @_; my $page = $params{page}; my $content = $params{content}; if ($content =~ s/^\#(?=[^#])[ \t]*(.*?)[ \t]*\#*\n//) { $pagestate{$page}{meta}{title} = $1; } return $content; } 1 __END__ =head1 NAME ikiwiki Plug-in: h1title =head1 SYNOPSIS If there is a level 1 Markdown atx-style (hash mark) header on the first line, this plugin uses it to set the page title and removes it from the page body so that it won't be rendered twice. Level 1 headers in the remainder of the page will be ignored. For example, the following page will have title "My Title" and the rendered page body will begin with the level two header "Introduction." # My Title ## Introduction Introductory text with a list: * Item 1 * Item 2 ## Second header Second section This plugin can be used with page templates that use
-rw-r--r-- | tags/b7/57/20170709220241.C21661C0A9@jawa.homebase.dk/unread | 0 |