view o2s5.source @ 2:85a60c32503c default tip

theme fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 24 Sep 2011 04:00:11 +0900
parents 450bcedf4ed4
children
line wrap: on
line source

#!/usr/bin/perl



my $depth = 0;
my $section = 1;
my $note = 1;
my $abstract = 0;
my $current = fh000;
my $tag = "content000";

my $back = "white";
my $fore = "black";

my $subtitle = '';
my $affilation = '';
my $closing = "</div>";
my $opening = '<div class="slide">';
my $xoxo = '';

my $tfont = 1;

my $ul = 0;
my $theme = "default";
my $in_title = "";

@opt  = grep(! /\.ind/,@ARGV);
@ARGV = grep(  /\.ind/,@ARGV);

sub title_init {

    if (grep(/-p/,@opt)) {
	$theme = "pixel";
    } elsif (grep(/-f/,@opt)) {
	$theme = "flower";
    } elsif (grep(/-n/,@opt)) {
	$theme = "nautilus";
    } elsif (grep(/-i/,@opt)) {
	$theme = "i18n";
    } elsif (grep(/-b/,@opt)) {
	$theme = "blue";
    } elsif (grep(/-2/,@opt)) {
	$closing = "</div>";
	$opening = '<div class="slide">';
    } else {
	$xoxo = '<ol class="xoxo presentation">'
    }

$slidy_init = <<"RogueRogue";
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-US">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 1st November 2003), see www.w3.org" />
<title>HTML Slidy</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content=
"Copyright &#169; 2005-2010 W3C (MIT, ERCIM, Keio)" />
<meta name="duration" content="5" />
<meta name="font-size-adjustment" content="-2" />
<link rel="stylesheet" href="ui/slidy2/styles/slidy.css" type="text/css" />
<link rel="stylesheet" href="ui/slidy2/styles/w3c-blue.css" type="text/css" />
<script src="ui/slidy2/scripts/slidy.js" charset="utf-8" type="text/javascript">
</script>
</head>
<body>
<div class="background"><img alt="" id="head-icon"
src="ui/slidy2/graphics/icon-blue.png" /><object id="head-logo"
data="ui/slidy2/graphics/w3c-logo-white.svg" type="image/svg+xml"
title="W3C logo"><a href="http://www.w3.org/"><img
alt="W3C logo" id="head-logo-fallback"
src="ui/slidy2/graphics/w3c-logo-white.gif" /></a></object></div>

<div class="background slanty">
<img src="ui/slidy2/graphics/w3c-logo-slanted.jpg" alt="slanted W3C logo" />
</div>
<div class="slide cover title">
  <!-- hidden style graphics to ensure they are saved with other content -->
  <img class="hidden" src="ui/slidy2/graphics/bullet.png" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/fold.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/unfold.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/fold-dim.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/nofold-dim.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/unfold-dim.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/bullet-fold.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/bullet-unfold.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/bullet-fold-dim.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/bullet-nofold-dim.gif" alt="" />
  <img class="hidden" src="ui/slidy2/graphics/bullet-unfold-dim.gif" alt="" />

<img src="ui/slidy2/graphics/keys2.jpg" alt="Cover page images (keys)"
 class="cover" /><br clear="all" />
<h1>$title</h1>

<p><a>$author</a>,
$in_title
<br />
<br />
<br />
</div>
RogueRogue

$init = <<"RogueRogue";
<html>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>$title</title>
<!-- metadata -->
<meta name="generator" content="o2s5" />
<meta name="version" content="0.1" />
<meta name="author" content="Shinji KONO" />
<meta name="company" content="" />
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
<!-- style sheet links -->
<link href="ui/syntax.css" id="syntaxStyle" media="all" rel="stylesheet" type="text/css" />
<link href="ui/core/outline.css" id="outlineStyle" media="screen" rel="stylesheet" type="text/css" />
<link href="ui/core/print.css" id="slidePrint" media="print" rel="stylesheet" type="text/css" />
<link href="ui/core/opera.css" id="operaFix" media="projection" rel="stylesheet" type="text/css" />
<link href="ui/core/math.css" id="mathStyle" media="all" rel="stylesheet" type="text/css" />
<link href="ui/themes/$theme/slides.css" id="slideProj" media="projection" rel="stylesheet" type="text/css" />
<!-- S5 JS -->
<script src="ui/prototype.js" type="text/javascript"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    MathML: { useMathMLspacing: true },
    "HTML-CSS": { scale: 90 }
  });
  if (window._onload_fired_) MathJax.Hub.Startup.onload();
</script>
<script type="text/javascript">
  if (!(Prototype.Browser.Gecko || navigator.userAgent.match(/MathPlayer/))) {
    var s = document.createElement('script');
    s.src = "ui/MathJax/MathJax.js?config=MML_HTMLorMML";
    document.querySelector('head').appendChild(s);        
    window.addEventListener("load", function(){window._onload_fired_ = true} , false);        
  };
</script>
<script src="ui/core/slides.js" type="text/javascript"></script>
</head>
<body>

<div class="layout">
<div id="controls"><!-- DO NOT EDIT --></div>
<div id="currentSlide"><!-- DO NOT EDIT --></div>
<div id="header"></div>
<div id="footer">
<h1>$title</h1>
<h2>$author</h2>
</div>
</div>
$xoxo
<div class="presentation">
<div class="slide">
<h1>$title</h1>
<h2>$subtitle</h2>
<h3>$author</h3>
<h4>$affilation</h4>
$in_title

RogueRogue

    if (grep(/-2/,@opt)) {
	$closing = "</div>";
	$opening = '<div class="slide">';
	$init = $slidy_init;
    }
    &init();
}

sub o2s5 {
my ($current) = @_;
%content = ();

my $in_comment = 0;

line: while (<$current>) {
    if (/^<!---/) {
	$in_comment = 1;
	next;
    }
    if ($in_comment) {
	if (/^<.*--->/) {
	    $in_comment = 0;
	}
	next;
    }
    chop;	# strip record separator
    s/([^\\])\\n/\1\n/g;
    s/\\\\/\\/g;
    if( (!/^\s/) && (!/^$/) && $pre) {
	print $fh "</pre>\n";
	$pre = 0;
    }
    if (/^-*input: (.*)/) {
	my $fd;
	# $fdbase = $current; $fdbase ++;
	open($fd,"<$1");
	$fdbase = $fd;
	push(@depend,$1);
#	print STDOUT "$1 ";
	do o2s5($fdbase);
	next line;
    }
    if (/^-title:/) {
	$title = substr($_, 8, length($_) - 7);
	# &title($title);
	next line;
    }
    if (/^--*date:/) {
	for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) {
	    ;
	}
	$tmp += 5;
	$day = substr($_, $tmp, length($_) - $tmp + 1);
	next line;
    }
    if (/^--*number:/) {
	for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) {
	    ;
	}
	$tmp += 7;
	$number = substr($_, $tmp, length($_) - $tmp + 1);
	next line;
    }
    if (/^--*note:/) {
	$note = 2;
#	printf $fh "<quote>\n";
	next line;
    }
    if (/^--*author:/) {
	for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) {
	    ;
	}
	$tmp += 7;
	$author = substr($_, $tmp, length($_) - $tmp + 1);
	next line;
    }
    if (/^--*affilation:/) {
	for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) {
	    ;
	}
	$tmp += 11;
	$affilation = substr($_, $tmp, length($_) - $tmp + 1);
	next line;
    }
    if (/^--*subtitle:/) {
	for ($tmp = 1; substr($_, $tmp, 1) eq '-'; $tmp++) {
	    ;
	}
	$tmp += 9;
	$subtitle = substr($_, $tmp, length($_) - $tmp + 1);
	next line;
    }
    if (/^--*abstract:/) {
	$abstract = 1;
#	printf $fh "\n";
	next line;
    }
    if (/^-/) {
	if ($ul) {
	    print $fh "</ul>\n";
	    $ul = 0;
	}
	if ($title && $title ne 'done') {
	    &title($title);
	    $title = 'done';
	}
	if ($abstract == 1) {
#	    printf $fh "\n";
	    $abstract = 0;
	}
	if ($note) {
	    if ($note == 2) {
#		printf $fh "\n";
	    $note = 0;
	    }
	}
	for ($depth = 1; substr($_, $depth, 1) eq '-'; $depth++) {
	    ;
	}
	$section_title = substr($_, $depth, length($_) - $depth + 1);
	if ($section) {
	print $fh <<"RogueRogue";
$closing
RogueRogue
	}
	print $fh <<RogueRogue;
$opening
<h1>$section_title</h1>
RogueRogue
	$section++;
	$content{$tag} = " " x $depth . $section_title;
	$tag++;
	next line;
    }
    if ($title ne 'done') {
	$in_title .= $_;
	next;
    }

    if (/^\t/) {
	if (! $ul) {
	    $ul = 1;
	    print $fh "<ul>";
	}
	print $fh "<li>$_\n</li>\n";
	$paragraph = 0;
    } elsif (/^\s/) {
	if(! $pre) {
	    $pre = 1;
	    print $fh "<pre>";
	}
	$paragraph = 0;
	print $fh $_,"<br>\n";
    } elsif (/^$/) {
	if(! $pre && ! $paragraph) {
	    print $fh $_,"<p>";
	    $paragraph = 1;
	}
    } else {
	print $fh $_,"<br>\n";
	$paragraph = 0;
    }
  }
#    if (defined $section_title) {
#    }

}


foreach $arg (@ARGV) {
  my $fd;
  # $fdbase = $current; $fdbase ++;
  open($fd,"<$arg") || die("$arg cannot open");
  $fdbase = $fd;
  $out = $arg;
  $out =~ s/\.ind$//;
  $out =~ s/\.index$//;
  $out .=  ".html";
  # $fh = "out00"; 
  if($arg eq $out) {
      $out .= ".html";
  }
  my $ofd;
  open($ofd,"|nkf -w >$out"); 
  $fh = $ofd;
  do o2s5($fdbase);
}

close($fh);






sub init {

open(IN,"| tar zxf -");

my $tmp = << 'EOFEOF';
   REPLACED-BY-FILE
EOFEOF

print IN unpack("u*",$tmp);
close IN;

}

# <!--入口--->

sub title {
	$title = $_[0];
  &title_init;

# <!-- embedded styles -->
# <style type="text/css" media="all">
# .imgcon {width: 525px; margin: 0 auto; padding: 0; text-align: center;}
# #anim {width: 270px; height: 320px; position: relative; margin-top: 0.5em;}
# #anim img {position: absolute; top: 42px; left: 24px;}
# img#me01 {top: 0; left: 0;}
# img#me02 {left: 23px;}
# img#me04 {top: 44px;}
# img#me05 {top: 43px;left: 36px;}
# </style>

    print $fh $init;


}






# end