11 texi2omf [options] FILE.texi > FILE.omf
15 --format=FORM set format FORM (HTML, PS, PDF, [XML]).
16 --location=FILE file name as installed on disk.
19 Use the following commands (enclose in @ignore)
30 (options, files) = getopt.getopt (sys.argv[1:], '',
31 ['format=', 'location=', 'version='])
36 email = os.getenv ('MAILADDRESS')
37 name = os.getenv ('USERNAME')
40 for (o, a) in options:
43 elif o == '--location':
44 location = 'file:%s' % a
45 elif o == '--version':
58 'pdf' : 'application/pdf',
59 'ps.gz' : 'application/postscript',
60 'ps' : 'application/postscript',
64 if not formats.has_key (format):
65 sys.stderr.write ("Format `%s' unknown\n" % format)
71 today = time.localtime ()
73 texi = open (infile).read ()
76 location = 'file:/%s' % re.sub (r'\..*', '.' + format, infile)
79 'date': '%d-%d-%d' % today[:3],
80 'mimeformat': formats[format],
81 'maintainer': "%s (%s)" % (name, email),
83 'location' : location,
87 omf_caterories = ['subject', 'creator', 'maintainer', 'contributor',
88 'title', 'subtitle', 'version', 'category', 'type',
89 'description', 'license', 'language',]
91 for a in omf_caterories:
92 m = re.search ('@omf%s (.*)\n'% a, texi)
94 omf_vars[a] = m.group (1)
95 elif not omf_vars.has_key (a):
98 if not omf_vars['title']:
100 m = re.search ('@title (.*)\n', texi)
105 m = re.search ('@subtitle (.*)\n', texi)
107 subtitle = m.group (1)
110 title = '%s -- %s' % (title, subtitle)
112 omf_vars['title'] = title
114 if not omf_vars['creator']:
115 m = re.search ('@author (.*)\n', texi)
117 omf_vars['creator'] = m.group (1)
121 print r'''<?xml version="1.0" encoding="UTF-8"?>
122 <!DOCTYPE omf PUBLIC "-//OMF//DTD Scrollkeeper OMF Variant V1.0//EN" "http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd">
137 <version identifier="%(version)s" date="%(date)s" />
138 <subject category="%(category)s"/>
145 <format mime="%(mimeformat)s" />
146 <identifier url="%(location)s"/>
147 <language code="%(language)s"/>
148 <rights type="%(license)s" />