#!/usr/local/bin/python
# $Id: report2lout.py,v 1.1 1997/05/22 19:40:09 connolly Exp $
# http://www.w3.org/pub/WWW/COPYRIGHT

import xml2lout, html2lout
from xml2lout import ON, OFF, CASE, ATTR, RESET, INC, VALUE, CHAR
from loutwr import BOL, INDENT, LB, RB


Rules = (
    ############
    # Report rules

    (('report',),
     (BOL, '@SysInclude', LB, 'tab', RB,
      BOL, '@SysInclude', LB, 'report', RB, #@@ these go with <!doctype
      BOL, '@Report', BOL),
     ()),
    
    (('report', 'h1'),
     (BOL, INDENT, '@Title', LB), #@@ clines style
     (RB,)),
    
    (('titlepage', 'forum'), (OFF,), (ON,)), #@@
    (('titlepage', 'release'), (OFF,), (ON,)), #@@
    (('titlepage', 'updates'), (OFF,), (ON,)), #@@
    (('titlepage', 'c'), (OFF,), (ON,)),
    (('titlepage', 'report-name'), (OFF,), (ON,)), #@@

    (('report', 'address', 'author'),  #@@ clines style
     (BOL, INDENT, '@Author', LB),
     (RB,)),
    
    (('report', 'address', 'affiliation'),  #@@ clines style
     (RB, BOL, INDENT, '@Institution', LB),
     ()),
    
    (('report', 'address', 'date'),
     (BOL, INDENT, '@DateLine', LB),
     (RB,)),
    
    (('report', 'address'),
     (),
     (BOL, INDENT, '@OptimizePages', LB, 'Yes', RB, BOL, '//')),
    
    (('abstract',),
     (BOL, '@Abstract'),
     (BOL, '@End', '@Abstract', BOL)),
    
    (('abstract', 'h2'),
     (BOL, INDENT, '@Title', LB),
     (RB, BOL, '@Begin')),
    
    (('abstract', 'h3'),
     (BOL, INDENT, '@Heading', LB),
     (RB)),
    
    (('abstract', 'p',),
     (BOL, '@LP', BOL),
     ()),
    
    (('abstract', 'keywords',),
     (BOL, '@DP'),
     ()),
    
    (('abstract', 'keywords', 'h3'),
     (LB, '@B', LB),
     (RB, RB)),
    
    (('contents',), (OFF,), (ON,)),

    ############
    # Large Scale Structure rules
    
    (('sect',),
     (BOL, '@Section'),
     (BOL, '@End', '@Section')),
    
    (('sect', 'h2'),
     (BOL, INDENT, '@Title', LB),
     (RB, BOL, '@Begin')),
    
    (('sect', 'h2', 'a'),
     (),
     (RB, BOL, INDENT, '@Tag', LB, (ATTR, 'name'))),
    
    (('num',), (OFF,), (ON,)),
    
    (('subsects',),
     (BOL, '@BeginSubSections'),
     (BOL, '@EndSubSections')),
    
    (('subsect',),
     (BOL, '@SubSection'),
     (BOL, '@End', '@SubSection')),
    
    (('subsect', 'h3'),
     (BOL, INDENT, '@Title', LB),
     (RB, BOL, '@Begin')),
    
    (('subsect', 'h3', 'a'),
     (),
     (RB, BOL, INDENT, '@Tag', LB, (ATTR, 'name'))),
    
    (('subsubsects',),
     (BOL, '@BeginSubSubSections'),
     (BOL, '@EndSubSubSections')),
    
    (('subsubsect',),
     (BOL, '@SubSubSection'),
     (BOL, '@End', '@SubSubSection')),
    
    (('subsubsect', 'h4'),
     (BOL, INDENT, '@Title', LB),
     (RB, BOL, '@Begin')),
    
    ##########
    # References
    (('references',), (OFF,), (ON,)), #@@
    
    
    ############
    # Text rules
    
    (('emdash',),
     ((CHAR, '---'), OFF),
     (ON,)),
    
    (('q', 'c'),
     (OFF,),
     (ON,)),
    
    )

class T(html2lout.T):
    def __init__(self, wr):
	html2lout.T.__init__(self, wr)
	self.rules = Rules + self.rules

if __name__ == '__main__':
    import sys
    x = T(sys.stdout)
    x.convert(sys.stdin)
