Нище приведені програми входять в збірку wiki2man, але тут бувають їх свіжіші версії.
Wiki to File
#!/bin/bash # 20070831 wiki2file hse@ukr.net tech JaFd http://wiki2man.sourceforge.net # Distributed under the terms of the GNU General Public License v3 or later version=0.2.8-rc1 version() { echo " wiki2file-$version Copyright (C) 2005 - 2006 hse@ukr.net tech JaFd http://wiki2man.sourceforge.net This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. " } usage() { echo " This script automate man pages wiki sources download from such wiki servers: DLOU (--language=uk) http://docs.linux.org.ua/index.php/Man:Contents RGWC (--language=ru-gentoo-wiki) http://ru.gentoo-wiki.com/Страницы_MAN over HTTP protocol and save it as local file. You can easier add support of new wiki servers!!! $ wiki2file [--language=<language>] [--wikimandir=<wikimandir>] [--url=<URL>] [--email=<E-mail>] --build --help --version Options: -l --language=<language> Language of manual pages, may be additional information. (uk) --language=new_wiki - print instruction how to add support of new wiki servers. -d --wikimandir=<wikimandir> Directory with wiki formated manual pages. (~/doc/uk) -u --url=<URL> URL of wiki server from which building manpages archive. (http://docs.linux.org.ua/dlou/index.php/Man_Contents) -m --email=<E-mail> E-mail addres of person which maintainer manual pages on the wiki. (docs@linux.org.ua) -b --build=<yes> Build manpages package. -h --help Print this help and exit. -v --version Print version and exit. " } checkutilities() { Mesg="$1" shift while [ $# != 0 ] do if ( ! which "${1}" >/dev/null 2>&1 ) then echo "Cannot find: $1 $Mesg" return 0 fi shift done return 1 } # Checking system: if ( checkutilities "Where am I?" awk cat cp date echo grep ls mail mkdir rm ) then exit 1 fi # Edit to suite yours configuration: # Local charset local_charset=utf8 # HTTP browser lynx='lynx -dump -cookie_file=~/.lynx_cookies -assume_charset '$local_charset' -assume_local_charset \ '$local_charset' -display_charset '$local_charset ########### RUSSIAN # Language lang='ru-gentoo-wiki' # Location of wiki formated man pages: wikimandir=~/doc/ru ########### UKRAINIAN # Language lang='uk' # Location of wiki formated man pages: wikimandir=~/doc/uk # Configuration from command line: build='' while [ $# != 0 ] do argument="$1" name=`echo "${argument}" |awk -F'=' '{print $1}'` argument=${argument##*=} if [[ "$name" == -[ldumbhv] ]] && ?span> <span class="hl opt"> then argument="$2"; shift; fi case "$name" in '-l'|'--language' ) lang="$argument" ;; '-d'|'--wikimandir' ) wikimandir="$argument" ;; '-u'|'--url' ) url="$argument" ;; '-m'|'--email' ) email="$argument" ;; '-b'|'--build' ) build='yes' ;; '-h'|'--help' ) usage exit 0 ;; '-v'|'--version' ) version exit 0 ;; * ) usage exit 1 ;; esac shift done # Create if needed output dir: mkdir -p $wikimandir/ case "$lang" in 'ru-gentoo-wiki' ) # Information: url='http://ru.gentoo-wiki.com/Страницы_MAN' email='docs@linux.org.ru' # url: link='http://ru.gentoo-wiki.com' # page: page='%D0%A1%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D1%8B_MAN' page='Страницы_MAN' # Create list of man pages: $lynx "$link/$page" |grep 'http://ru.gentoo-wiki.com/MAN_' |awk -F'http://ru.gentoo-wiki.com/MAN_' '{print $2}' \ > $wikimandir/manlist page='index.php?title=MAN_' symbol='_' # abs_1 CASE='SHOT' # abs_1 ;; 'uk' ) # Information: url='http://docs.linux.org.ua/dlou/index.php/Man_Contents' email='docs@linux.org.ua' # url: link='http://docs.linux.org.ua' # page: page='dlou/index.php/%D0%9A%D0%B0%D1%82%D0%B5%D0%B3%D0%BE%D1%80%D1%96%D1%8F:' page=$page'%D0%A1%D1%82%D0%BE%D1%80%D1%96%D0%BD%D0%BA%D0%B8_' page=$page'%D0%BF%D1%96%D0%B4%D1%80%D1%83%D1%87%D0%BD%D0%B8%D0%BA%D0%B0' page='dlou/index.php/Категорія:Сторінки підручника' # Create list of man pages: $lynx "$link/$page" > $wikimandir/manpage grep 'http://docs.linux.org.ua/dlou/index.php/Man:Man' $wikimandir/manpage |awk '{print $2}' |awk -F':' '{print $3}' \ |sed 's/Man/man/' > $wikimandir/manlis page='dlou/index.php?title=%D0%9A%D0%B0%D1%82%D0%B5%D0%B3%D0%BE%D1%80%D1%96%D1%8F:' page=$page'%D0%A1%D1%82%D0%BE%D1%80%D1%96%D0%BD%D0%BA%D0%B8_' page=$page'%D0%BF%D1%96%D0%B4%D1%80%D1%83%D1%87%D0%BD%D0%B8%D0%BA%D0%B0&from=' for i in `grep "$page" $wikimandir/manpage |awk '{print $2}'` do $lynx "$i" |grep 'http://docs.linux.org.ua/dlou/index.php/Man:Man' |awk '{print $2}' |awk -F':' '{print $3}' \ |sed 's/Man/man/' >> $wikimandir/manlis done cat $wikimandir/manlis |uniq -u > $wikimandir/manlist rm $wikimandir/manlis $wikimandir/manpage page='dlou/index.php?title=Man:Man' symbol='.' # man1/abs.1 CASE='FULL' # man1/abs.1 ;; 'new_wiki' ) echo " # For adding new wiki server support you must fill out next fields # in source of this script. # Information: url='<URL of manual pages site>' email='<E-mail>' # url: link='<URL wiki server>' # page: page='<Page with manual pages list on wiki server>' # Create list of man pages ( list like 'man1/abs.1' or 'abs.1'): $lynx "$link/$page" |grep '???' |awk ??? |sed ??? > $wikimandir/manlist page='<Page for edit manual pages on wiki server>' # May be need change $page defined above. symbol='?' # abs.1 -> symbol='.'; abs_1 -> symbol='_' CASE='SHOT' # abs.1 CASE='FULL' # man1/abs.1 # Send filled out this form to wiki2man mailing list to include your server # support in future release. " exit 0 ;; * ) echo "Only 'ru-gentoo-wiki', 'uk' and 'new_wiki' are supported '--language' for now!" exit 1 ;; esac # http://ru.gentoo-wiki.com/index.php/MAN_awk_1 # http://docs.linux.org.ua/index.php/Man:Man3/abs.3 # Download wiki formated man pages to local file: for i in `cat $wikimandir/manlist` do N=${i##*${symbol}} if ?span> <span class="hl opt"> then if ?span> <span class="hl opt"> then N=`echo $i |awk -F'/' '{print $1}' |awk -F'man' '{print $2}'` j=`echo $i |awk -F'/' '{print $2}'` mkdir -p $wikimandir/man$N echo -n "Download to: $wikimandir/man$N/$j ..." wget -q -c -N -O $wikimandir/man$N/$j "${link}/${page}${N}/${j}&action=raw" #& echo ' OK!' else j=`echo $i |awk -F'/' '{print $2}' |awk -F"${symbol}${N}" '{print $1}'` mkdir -p $wikimandir/man$N echo -n "Download to: $wikimandir/man$N/$j.$N ..." wget -q -c -N -O $wikimandir/man$N/$j.$N "${link}/${page}${N}/${j}${symbol}${N}&action=raw" #& echo ' OK!' fi else j=`echo $i |awk -F"${symbol}${N}" '{print $1}'` mkdir -p $wikimandir/man$N echo -n "Download to: $wikimandir/man$N/$j.$N ..." wget -q -c -N -O $wikimandir/man$N/$j.$N "${link}/${page}${j}${symbol}${N}&action=raw" #& echo ' OK!' fi done # Making manual pages package: if ?span> <span class="hl opt"> then makeman -l $lang -d $wikimandir -u $url -m $email fi exit 0
Groff to Wiki
Ще один скрипт (навпаки - groff to wiki)
Tech 09:53, 1 вересень 2007 (EEST)
#!/usr/bin/perl # g2w: groff-to-wiki translator # Author: Vitaliy Tsybulyak tech(at)oboz.com.ua # Distributed under the terms of the GNU General Public License v3 use strict; use warnings; use POSIX qw(locale_h); setlocale(LC_CTYPE, "uk_UA.koi8-u"); setlocale(LC_ALL, "uk_UA.koi8-u"); my $def = 0; # a wiki definition ;foo:bar my $pre = 0; # preformatted text while (<>) { chomp; s/\s+$//; # remove trailing spaces s/</</g; s/>/>/g; s/\\-/-/g; # replace \- with - s/\\e/\\/g; # replace \e with \ s/\\fB([^\\]+)\\f[PR]/<b>$1<\/b>/g; # bold attribute s/\\fI([^\\]+)\\f[PR]/<i>$1<\/i>/g; # italic attribute # make a link to another manpage s/^\.BR ([a-z_0-9.]+) \(([1-8])\)/?Man:Man$2\/$1.$2/; if(/^\.sp/) { print "\n\n"; next; #s/^\.sp/\n\n/; } next if (/^(\.RS|\.RE)/); s/^\.ti .*$/ /; if (/^\.TP/) { $def = 1; print "\n\n;"; next; } if (/^\.IP/) { print "\n* "; next; } if (/^\.nf/) { $pre = 1; next; } elsif (/^\.fi/) { $pre = 0; next; } if ($pre) { s/^/ /; # just add 4 spaces; will print the line later } # 6 cases: .BI .IB .BR .RB .RI .IR if (/^\.BI/) { my $b = 0; s/^\.BI\s+//; while (/([^" ]+)|"([^"]+)"/gc) { if ($b == 0) { if ($1) { print "<b>$1</b>"; $b = 1; } elsif ($2) { print "<b>$2</b>"; $b = 1; } } elsif ($b == 1) { if ($1) { print "<i>$1</i>"; $b = 0; } elsif ($2) { print "<i>$2</i>"; $b = 0; } } } if ($def) { print ": "; $def = 0; } elsif ($pre) { print "\n"; } else { print " "; } } elsif (/^\.IB/) { my $b = 1; s/^\.IB\s+//; while (/([^" ]+)|"([^"]+)"/gc) { if ($b == 0) { if ($1) { print "<b>$1</b>"; $b = 1; } elsif ($2) { print "<b>$2</b>"; $b = 1; } } elsif ($b == 1) { if ($1) { print "<i>$1</i>"; $b = 0; } elsif ($2) { print "<i>$2</i>"; $b = 0; } } } if ($def) { print ": "; $def = 0; } elsif ($pre) { print "\n"; } else { print " "; } } elsif (/^\.BR/) { my $b = 0; s/^\.BR\s+//; while (/([^" ]+)|"([^"]+)"/gc) { if ($b == 0) { if ($1) { print "<b>$1</b>"; $b = 1; } elsif ($2) { print "<b>$2</b>"; $b = 1; } } elsif ($b == 1) { if ($1) { print "$1"; $b = 0; } elsif ($2) { print "$2"; $b = 0; } } } if ($def) { print ": "; $def = 0; } elsif ($pre) { print "\n"; } else { print " "; } } elsif (/^\.RB/) { my $b = 1; s/^\.RB\s+//; while (/([^" ]+)|"([^"]+)"/gc) { if ($b == 0) { if ($1) { print "<b>$1</b>"; $b = 1; } elsif ($2) { print "<b>$2</b>"; $b = 1; } } elsif ($b == 1) { if ($1) { print "$1"; $b = 0; } elsif ($2) { print "$2"; $b = 0; } } } if ($def) { print ": "; $def = 0; } elsif ($pre) { print "\n"; } else { print " "; } } elsif (/^\.RI/) { my $r = 0; s/^\.RI\s+//; while (/([^" ]+)|"([^"]+)"/gc) { if ($r == 0) { if ($1) { print "$1"; $r = 1; } elsif ($2) { print "$2"; $r = 1; } } elsif ($r == 1) { if ($1) { print "<i>$1</i>"; $r = 0; } elsif ($2) { print "<i>$2</i>"; $r = 0; } } } if ($def) { print ": "; $def = 0; } elsif ($pre) { print "\n"; } else { print " "; } } elsif (/^\.IR/) { my $r = 1; s/^\.IR\s+//; while (/([^" ]+)|"([^"]+)"/gc) { if ($r == 0) { if ($1) { print "$1"; $r = 1; } elsif ($2) { print "$2"; $r = 1; } } elsif ($r == 1) { if ($1) { print "<i>$1</i>"; $r = 0; } elsif ($2) { print "<i>$2</i>"; $r = 0; } } } if ($def) { print ": "; $def = 0; } elsif ($pre) { print "\n"; } else { print " "; } } elsif (/^\.B /) { s/^\.B\s+//; print "<b>$_</b>"; if ($def) { print ": "; $def = 0; } elsif ($pre) { print "\n"; } else { print " "; } } elsif (/^\.I /) { s/^\.I\s+//; print "<i>$_</i>"; if ($def) { print ": "; $def = 0; } elsif ($pre) { print "\n"; } else { print " "; } } elsif (/^\.SH /) { s/^\.SH\s+//; s/"//g; print "\n=="; my @line = split(//,$_); print $line[0]; shift @line;; foreach (@line) { tr/АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯ/абвгґдеєжзиіїйклмнопрстуфхцчшщьюя/; print; } print "==\n"; next; } elsif (/^\.SS /) { s/^\.SS\s+//; s/"//g; print "\n=== $_ ===\n"; } elsif (/^\.PP?/) { print "\n\n"; } elsif (/^\.TH /) { s/^\.TH\s+//; print "\n<!-- $_ -->\n"; } elsif (/^\.br/) { print "\n<br>\n"; } elsif (/^\.\\"/) { s/^\.\\"//; print "\n<!-- $_ -->\n"; next; } elsif (/^\\"/) { next; } elsif (/^\.PD/) { next; } else { if ($def) { print "$_: "; $def = 0; } elsif ($pre) { print "$_\n"; } else { print "$_ "; } } }