Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/doc/perl-Collectd/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Collectd/wiki2commonmark.pl
#!/usr/bin/perl

use strict;
use warnings;

=head1 NAME

wiki2changelog.pl

=head1 DESCRIPTION

This script takes the change log from one of the "Version x.y" pages in
collectd's wiki and converts it to the format used by the "ChangeLog" file.
This is usually done as part of the release process.

=cut

our %GithubUsers = (
	'Mfournier'    => '@mfournier',
	'Octo'         => '@octo',
	'Tokkee'       => '@tokkee',
);

sub format_link
{
	my $page = shift;
	my $text = @_ ? shift : $page;

	if ($page =~ m/^User:([A-Z][a-z]*)$/) {
		if (exists ($GithubUsers{$1})) {
			return $GithubUsers{$1};
		}
	}

	$page =~ s# #_#g;

	return "[$text](https://collectd.org/wiki/index.php/$page)";
}

while (<>)
{
	chomp;
	my $line = $_;

	if ($line =~ m#^\* (.*)#) {
		$line = $1;
	} else {
		next;
	}

	$line =~ s#(?<!\[)\[([^\s\]]+)\s+([^\]]+)\](?!\])#[$2]($1)#g;
	$line =~ s#\{\{Plugin\|([^}]+)\}\}#format_link("Plugin:$1", "$1 plugin")#ge;
	$line =~ s@\{\{Issue\|([^}]+)\}\}@#$1@g;
	$line =~ s#\[\[([^|\]]+)\|([^\]]+)\]\]#format_link($1, $2)#ge;
	$line =~ s#\[\[([^|\]]+)\]\]#format_link($1)#ge;

	$line =~ s#('')?Ruben Kerkhof('')?#\@rubenk#g;
	$line =~ s#('')?Pavel Rochnyak('')?#\@rpv-tomsk#g;
	$line =~ s#('')?Maryam Tahhan('')?#\@maryamtahhan#g;
	$line =~ s#('')?Florian Forster('')?#\@octo#g;

	$line =~ s#'''(.*?)'''#**$1**#g;
	$line =~ s#''(.*?)''#*$1*#g;
	$line =~ s#<code>(.*?)</code>#`$1`#g;

	print "$line\n";
}

Hry