diff options
| author | lemurianmage <azureazure@disroot.org> | 2026-06-12 23:35:20 +0200 |
|---|---|---|
| committer | lemurianmage <azureazure@disroot.org> | 2026-06-12 23:35:20 +0200 |
| commit | 7da42c6e577f49ad4981f24c833b2e1d86357e0b (patch) | |
| tree | b1921f453b86cd5062adbd34b5e1b8dccc8f32ef /template.pl | |
| parent | cf102ad6c7d171dd500cae8b419b7f5c1e796ab4 (diff) | |
| download | slimegirl.nexus-7da42c6e577f49ad4981f24c833b2e1d86357e0b.tar.gz | |
redesign and move to markdown with a perl+make build system
Diffstat (limited to 'template.pl')
| -rwxr-xr-x | template.pl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/template.pl b/template.pl new file mode 100755 index 0000000..747ac7c --- /dev/null +++ b/template.pl @@ -0,0 +1,32 @@ +#!/usr/bin/env perl + +# this script is generally responsible for all html postprocessing that md2html can't do + +use v5.39; +use utf8; +use autodie; + +use Mojo::DOM; + +my $template = do { + local $/ = undef; + open my $fh, '<', 'template.html'; + <$fh>; +}; + +my $dom = Mojo::DOM->new($template); + +my $content = `md2html $ARGV[0]`; +# inject content @ <article> +$dom->at('article')->append_content($content); + +# replace <title> with the contents of the first <h1> +my $title_dom = $dom->at('h1'); +$dom->at('title')->content($title_dom->text) if ($title_dom); + +for my $img ($dom->find('img')->each) { + my $alt = $img->attr('alt'); + $img->attr(title => $alt); +} + +say "$dom"; |
