#!/usr/bin/env perl use strict; use warnings; use utf8; use feature qw(unicode_strings say); use English '-no_match_vars'; binmode STDOUT, ':encoding(UTF-8)'; binmode STDERR, ':encoding(UTF-8)'; use Text::Markdown 'markdown'; sub slurp { my ($filename) = @_; local $INPUT_RECORD_SEPARATOR = undef; open my $fh, '<', $filename; binmode $fh, ':encoding(UTF-8)'; return <$fh>; } sub main { my $ChangeLog = slurp 'docs/ChangeLog'; $ChangeLog =~ s/(^\s*[^+].*?:\n[ ]*)([+])/$1\n$2/xmsg; say beginning_text() . process_changelog(html_escape($ChangeLog)) . end_text(); } main(); sub process_changelog { my ($in) = @_; my @release_html; # Extracts the text from the 'New in XXXX.XX' to the next 'New in XXXX.XX' # if there are no 'New in' left it extracts to the end of the document. while ($in =~ s/(New in ([\d.]+)(.*?))(New in [\d.]+|$)/$4/s) { my $sec = $3; my $release = $2; print STDERR "$release\n"; my $md_obj = Text::Markdown->new; my $mid = $md_obj->markdown($sec); my $start = <<"END";