DragonFly commits List (threaded) for 2007-03
DragonFly BSD
DragonFly commits List (threaded) for 2007-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: doc/share/mk doc.docbook.mk doc.project.mk doc/share/sgml mirrors-master.xsl


From: "Justin C. Sherrill" <justin@xxxxxxxxxxxxxxxxxx>
Date: Mon, 26 Mar 2007 22:08:44 -0400 (EDT)

On Mon, March 26, 2007 6:51 pm, Justin C. Sherrill wrote:
> On Mon, March 26, 2007 5:30 pm, Trevor Kendall wrote:
>>>   Fix handbook building:
>>
>> What happened to moving the handbook to the wiki? Stalled?
>
> I was working on a docbook/sgml -> moinmoin wiki markup Perl script; I'll
> post it here.  My life got interrupted with working in the evenings; I'd
> like to finish it, but there's no reason someone else can't run with it.
>

Aaand here it is.
#!/usr/bin/perl

use File::Find;

# go through each .sgml file,
# get each tag
# replace as appropriate
# reprint line




find(\&gettags, "/Users/justin/cvswork/doc/en/books/handbook");

sub gettags {

	if (/sgml/) 
	{
		my $lines;
		chdir($File::Find::dir);
		open(FILE,"<","$_");
		while (<FILE>)
		{
			$lines .= $_;
		}
		close (FILE);

		# added by me
		$lines =~ s/<email>//sg;
		$lines =~ s/<\/email>//sg;
		$lines =~ s/<address>//sg;
		$lines =~ s/<\/address>//sg;
		$lines =~ s/<affiliation>//sg;
		$lines =~ s/<\/affiliation>//sg;
		$lines =~ s/<blockquote>//sg;
		$lines =~ s/<\/blockquote>//sg;
		$lines =~ s/<example>//sg;
		$lines =~ s/<\/example>//sg;
		$lines =~ s/<mediaobject>//sg;
		$lines =~ s/<\/mediaobject>//sg;
		$lines =~ s/<textobject>//sg;
		$lines =~ s/<\/textobject>//sg;
		
		$lines =~ s/<sect1(.*?)<title>(.*?)<\/title>/=$2=\n/sg;
		$lines =~ s/<\/sect1>//sg;
		$lines =~ s/<sect2(.*?)<title>(.*?)<\/title>/==$2==\n/sg;
		$lines =~ s/<\/sect2>//sg;
		$lines =~ s/<sect3(.*?)<title>(.*?)<\/title>/===$2===\n/sg;
		$lines =~ s/<\/sect3>//sg;
		$lines =~ s/<sect4(.*?)<title>(.*?)<\/title>/====$2====\n/sg;
		$lines =~ s/<\/sect4>//sg;
		$lines =~ s/<sect5(.*?)<title>(.*?)<\/title>/=====$2=====\n/sg;
		$lines =~ s/<\/sect5>//sg;
		$lines =~ s/<sect\dinfo>//sg;
		$lines =~ s/<\/sect\dinfo>//sg;

		$lines =~ s/<note>(.*?)<\/note>/Note:: $1/sg;
		$lines =~ s/<tip>(.*?)<\/tip>/Tip:: $1/sg;
		$lines =~ s/<important>(.*?)<\/important>/Important:: $1/sg;
		$lines =~ s/<caution>(.*?)<\/caution>/Caution:: $1/sg;
		$lines =~ s/<warning>(.*?)<\/warning>/Warning:: $1/sg;
		
		$lines =~ s/<application>(.*?)<\/application>/''$1''/sg;
		$lines =~ s/<userinput>(.*?)<\/userinput>/'''$1'''/sg;
		$lines =~ s/<filename>(.*?)<\/filename>/''$1''/sg;

		$lines =~ s/<programlisting>(.*?)<\/programlisting>/{{{$1}}}/sg;
		$lines =~ s/<literallayout>(.*?)<\/literallayout>/{{{$1}}}/sg;
		
		$lines =~ s/<ulink url=(.*?)>(.*?)<\/ulink>/[$1 $2]/sg;
		$lines =~ s/<link linkend="(.*?)">(.*?)<\/link>/[:$1:$2]/sg;


		# inherited

		$lines =~ s/<!--(.*?)-->//sg;
		$lines =~ s/<chapter(.*?)>(.*?)<title>(.*?)<\/title>//sg;
		$lines =~ s/<\/chapter>//sg;
		$lines =~ s/<para>//sg;
		$lines =~ s/<\/para>/\n/sg;
		
		$lines =~ s/<section(.*?)<title>(.*?)<\/title>/==$2==\n/sg;
		$lines =~ s/<section(.*?)>//sg;
		$lines =~ s/<\/section>//sg;
		
		$lines =~ s/<bridgehead(.*?)>(.*?)<\/bridgehead>/====$2====\n$3/sg;
		
		$lines =~ s/<figure(.*?)<title>(.*?)<\/title>(.*?)<(.*?)fileref(.*?)\/([^\/]*?)"(.*?)<\/figure>/\[\[Image:$IMGPATH-$6|frame|none|$2\]\]/sg;
		$lines =~ s/<guiicon(.*?)fileref(.*?)\/([^\/]*?)"(.*?)<\/guiicon>/\[\[Image:$IMGPATH-$3\]\]/sg;
		
		$lines =~ s/<emphasis>(.*?)<\/emphasis>/''$1''/sg;
		$lines =~ s/<literal>(.*?)<\/literal>/\{\{Literal|$1\}\}/sg;
		$lines =~ s/\&(.?)KEY;/\{\{K|$1\}\}/sg;
		$lines =~ s/<keycap>(.?)KEY<\/keycap>/\{\{K|$1\}\}/sg;
		$lines =~ s/<keycap>(.*?)<\/keycap>/\{\{KEY|$1\}\}/sg;
		
		$lines =~ s/<itemizedlist>//sg;
		$lines =~ s/<\/itemizedlist>//sg;
		$lines =~ s/<orderedlist>//sg;
		$lines =~ s/<\/orderedlist>//sg;
		$lines =~ s/<variablelist>//sg;
		$lines =~ s/<\/variablelist>//sg;
		$lines =~ s/<varlistentry>//sg;
		$lines =~ s/<\/varlistentry>//sg;
		
		$lines =~ s/<term>(.*?)<\/term>/====$1====/sg;
		$lines =~ s/<listitem>/\*/sg;
		while($lines =~ s/\n\* *\n/\n\*/sg){};
		$lines =~ s/<\/listitem>//sg;
		
		$lines =~ s/<superscript>/<sup>/sg;
		$lines =~ s/<\/superscript>/<\/sup>/sg;
		$lines =~ s/<subscript>/<sup>/sg;
		$lines =~ s/<\/subscript>/<\/sup>/sg;
		
		$lines =~ s/<note>(.*?)<title>(.*?)<\/title>(.*?)<\/note>/\{\{Note|$2|$3\}\}/sg;
		$lines =~ s/<note>(.*?)<\/note>/\{\{Note|Note|$1\}\}/sg;
		$lines =~ s/<tip>(.*?)<title>(.*?)<\/title>(.*?)<\/tip>/\{\{Note|$2|$3\}\}/sg;
		$lines =~ s/<tip>(.*?)<\/tip>/\{\{Note|A Tip|$1\}\}/sg;
		
		
		while($lines =~ s/\n //sg){};
		while($lines =~ s/\|\n //sg){};
		while($lines =~ s/ \n/\n/sg){};
		while($lines =~ s/\n\n/\n/sg){};

	
		print "$lines";
	
	}
}


sub id_tag
{
	my $var = shift;
	
	if ($var =~ m/<!/)
	{
		return "IGNORE";	
	}

	$var =~ s/ renderas=sect1//g;
	$var =~ s/ renderas=sect2//g;
	$var =~ s/ cols=3//g;
	$var =~ s/ id='colophon'//g;
 
	$var =~ s/ id=".+"//g;
	$var =~ s/ cols=".+"//g;
	$var =~ s/ frame=".+"//g;
	$var =~ s/ pgwide=".+"//g;
	$var =~ s/ class=".+"//g;
	$var =~ s/ colwidth=".+"//g;
	$var =~ s/ valign=".+"//g;
	$var =~ s/ action=".+"//g;
	$var =~ s/ renderas=".+"//g;
	
	$var =~ s/ fileref=".+"//g;
	$var =~ s/ arearefs=".+"//g;
	$var =~ s/ linkend=".+"//g;
	$var =~ s/ url=".+"//g;
	
	$var =~ s/<//;
	$var =~ s/>//;
	$var =~ s/\//slash_/;
	
	return $var;
	
}


#$lines =~ s/<!--(.*?)-->//sg;
#$lines =~ s/<chapter(.*?)>(.*?)<title>(.*?)<\/title>//sg;
#$lines =~ s/<\/chapter>//sg;
#$lines =~ s/<para>//sg;
#$lines =~ s/<\/para>/\n/sg;
#
#$lines =~ s/<section(.*?)<title>(.*?)<\/title>/==$2==\n/sg;
#$lines =~ s/<section(.*?)>//sg;
#$lines =~ s/<\/section>//sg;
#
#$lines =~ s/<bridgehead(.*?)>(.*?)<\/bridgehead>/====$2====\n$3/sg;
#
#$lines =~ s/<figure(.*?)<title>(.*?)<\/title>(.*?)<(.*?)fileref(.*?)\/([^\/]*?)"(.*?)<\/figure>/\[\[Image:$IMGPATH-$6|frame|none|$2\]\]/sg;
#$lines =~ s/<guiicon(.*?)fileref(.*?)\/([^\/]*?)"(.*?)<\/guiicon>/\[\[Image:$IMGPATH-$3\]\]/sg;
#
#$lines =~ s/<emphasis>(.*?)<\/emphasis>/''$1''/sg;
#$lines =~ s/<literal>(.*?)<\/literal>/\{\{Literal|$1\}\}/sg;
#$lines =~ s/\&(.?)KEY;/\{\{K|$1\}\}/sg;
#$lines =~ s/<keycap>(.?)KEY<\/keycap>/\{\{K|$1\}\}/sg;
#$lines =~ s/<keycap>(.*?)<\/keycap>/\{\{KEY|$1\}\}/sg;
#
#$lines =~ s/<itemizedlist>//sg;
#$lines =~ s/<\/itemizedlist>//sg;
#$lines =~ s/<orderedlist>//sg;
#$lines =~ s/<\/orderedlist>//sg;
#$lines =~ s/<variablelist>//sg;
#$lines =~ s/<\/variablelist>//sg;
#$lines =~ s/<varlistentry>//sg;
#$lines =~ s/<\/varlistentry>//sg;
#
#$lines =~ s/<term>(.*?)<\/term>/====$1====/sg;
#$lines =~ s/<listitem>/\*/sg;
#while($lines =~ s/\n\* *\n/\n\*/sg){};
#$lines =~ s/<\/listitem>//sg;
#
#$lines =~ s/<superscript>/<sup>/sg;
#$lines =~ s/<\/superscript>/<\/sup>/sg;
#$lines =~ s/<subscript>/<sup>/sg;
#$lines =~ s/<\/subscript>/<\/sup>/sg;
#
#$lines =~ s/<note>(.*?)<title>(.*?)<\/title>(.*?)<\/note>/\{\{Note|$2|$3\}\}/sg;
#$lines =~ s/<note>(.*?)<\/note>/\{\{Note|Note|$1\}\}/sg;
#$lines =~ s/<tip>(.*?)<title>(.*?)<\/title>(.*?)<\/tip>/\{\{Note|$2|$3\}\}/sg;
#$lines =~ s/<tip>(.*?)<\/tip>/\{\{Note|A Tip|$1\}\}/sg;
#
#
#while($lines =~ s/\n //sg){};
#while($lines =~ s/\|\n //sg){};
#while($lines =~ s/ \n/\n/sg){};
#while($lines =~ s/\n\n/\n/sg){};
#
#print $lines;
#
#__END__
#
#while($lines =~ /<tip>(.*?)<\/tip>/s) {
#  $content = $1;
#  $formatted = $content;
#  if ($formatted =~ /<title>(.*?)<\/title>/) {
#    $title = $1;
#    $formatted =~ s/<title>$title<\/title>//s;
#  } else {
#    $title = "A Tip";
#  }
#  $formatted =~ s/\{\{K\|(.*?)\}\}/'''$1'''/sg;
#  $formatted =~ s/\{\{KEY\|(.*?)\}\}/'''$1'''/sg;
#  $formatted =~ s/\{\{Literal\|(.*?)\}\}/<tt>$1<\/tt>/sg;
#  $formatted =~ s/\{//sg;
#  $formatted =~ s/\}//sg;
#  $content =~s/\(/\\\(/g;
#  $content =~s/\)/\\\)/g;
#  $content =~s/\?/\\\?/g;
#  $content =~s/\//\\\//g;
#  $content =~s/\*/\\\*/g;
#  #print $content;
#  $lines =~ s/<tip>$content<\/tip>/\{\{Tip|$title|$formatted\}\}/sg;
#
#}
#
#while($lines =~ /<note>(.*?)<\/note>/sg) {
#  $content = $1;
#  $formatted = $content;
#  if ($formatted =~ /<title>(.*?)<\/title>/) {
#    $title = $1;
#    $formatted =~ s/<title>$title<\/title>//s;
#  } else {
#    $title = "Note";
#  }
#  $formatted =~ s/\{\{K\|(.*?)\}\}/'''$1'''/sg;
#  $formatted =~ s/\{\{KEY\|(.*?)\}\}/'''$1'''/sg;
#  $formatted =~ s/\{\{Literal\|(.*?)\}\}/<tt>$1<\/tt>/sg;
#  $formatted =~ s/\{//sg;
#  $formatted =~ s/\{//sg;
#  $content =~s/\(/\\\(/g;
#  $content =~s/\)/\\\)/g;
#  $content =~s/\?/\\\?/g;
#  $content =~s/\//\\\//g;
#  $content =~s/\*/\\\*/g;
#  $lines =~ s/<note>$content<\/note>/\{\{Note|$title|$formatted\}\}/sg;
#}


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]