9 texi2omf [options] texifile
13 --format=FORM format is FORM. Supported: HTML, PS, PDF
14 --location=FILE path to file on disk.
17 Use the following commands (enclose in @ignore)
28 (options
, files
) = getopt
.getopt (sys
.argv
[1:], '',
29 ['format=', 'location=', 'version='])
34 email
= os
.getenv ('MAILADDRESS')
35 name
= os
.getenv ('USERNAME')
40 elif o
== '--location':
41 location
= 'file:%s' % a
42 elif o
== '--version':
55 'pdf' : 'application/pdf',
56 'ps.gz' : 'application/postscript',
57 'ps' : 'application/postscript',
60 if not formats
.has_key (format
):
61 sys
.stderr
.write ("Format `%s' unknown\n" % format
)
67 today
= time
.localtime()
69 texi
= open (infile
).read()
72 location
= 'file:%s' % re
.sub (r
'\.*', '.html', infile
)
76 'date': '%d-%d-%d' % today
[:3],
77 'mimeformat': formats
[format
],
78 'maintainer': "%s (%s)" % (name
, email
),
80 'location' : location
,
83 for a
in ['subject','creator', 'title', 'subtitle', 'version', 'category', 'type',
84 'description', 'license']:
86 m
= re
.search ('@omf%s (.*)\n'% a
, texi
)
88 omf_vars
[a
] = m
.group (1)
89 elif not omf_vars
.has_key (a
):
92 if not omf_vars
['title']:
94 m
= re
.search ('@title (.*)\n', texi
)
99 m
= re
.search ('@subtitle (.*)\n', texi
)
101 subtitle
= m
.group (1)
104 title
= '%s -- %s' % (title
, subtitle
)
106 omf_vars
['title'] = title
108 if not omf_vars
['creator']:
109 m
= re
.search ('@author (.*)\n', texi
)
111 omf_vars
['creator'] = m
.group (1)
115 print r
'''<?xml version="1.0" encoding="UTF-8"?>
116 <!DOCTYPE omf PUBLIC "-//OMF//DTD Scrollkeeper OMF Variant V1.0//EN" "http://scrollkeeper.sourceforge.net/dtds/scrollkeeper-omf-1.0/scrollkeeper-omf.dtd">
131 <version identifier="%(version)s" date="%(date)s" />
132 <subject category="%(category)s"/>
139 <format mime="%(mimeformat)s" />
140 <identifier url="%(location)s"/>
142 <rights type="%(license)s" />