#!/usr/bin/sed -f # This sed script converts text files from Steve Jackson Games' # Ventura Publisher format to something approximating LaTeX. It # isn't even remotely good LaTeX (the \rm between every paragraph # is particularly repulsive), but it's a start. This script also # doesn't provide the \documentstyle[GURPS]{book}\begin{document}... # \end{document} setup stuff. Its handling of the the mess that is # a Ventura table is primitive -- it just breaks the lines apart # into individual LaTeX paragraphs. # Replace Ventura headers with LaTeX equivalents. s/@A-HEAD .*= \(.*\)/\\chapter{\1}/ s/@B-HEAD .*= \(.*\)/\\section*{\1}/ s/@C-HEAD .*= \(.*\)/\\subsection*{\1}/ s/@D-HEAD .*= \(.*\)/\\subsubsection*{\1}/ s/@SB HEAD = $// s/@SB HEAD = \(.*\)/\\sidebar{\1}/ s/@SB HEAD NO BK = $// s/@SB HEAD NO BK = \(.*\)/\\sidebar{\1}/ s/@SB BODY = *// s/@SB SUBHEAD = \(.*\)/{\bf \1}/ # typeface changes s/ *<[DMR]> */\\rm /g s/ * */\\it /g s/ * */\\bi /g s/ * */\\bf /g # some Ventura special characters s/<\$E\(.*\)\/\(.*\)>/\\frac{\1}{\2}/g s/ *./$\\times$/g s/ *<192>/\\copyright /g s/ *<167>/$^\\circ$/g s/ *<186>/\\registered /g / \. *$/N / <196> *$/N s/ *\. \n*\. \n*\./\\ldots/g s/\..20\..20\./\\ldots/g s/ *<196>[ \n]*/---/g s/ *<_>[ \n]*/~/g # Protect LaTeX's special characters. s/%/\\%/g s/&/\\&/g s/\$/\\$/g s/#/\\#/g # I don't know what to do with any other @ commands, beyond # breaking them into paragraphs to preserve their lines.... s/@.* = \(.*\) *$/\1/g # These commands are a complete mystery to me. Anyone # who knows what they are for, please tell me! s/.MDBO.//g s/.MDNM.//g # LaTex requires a blank line to end a paragraph. Assume that a # line ending with anything but a space is the end of a paragraph. # In Ventura, a typeface change is revoked by the end of a paragraph. /[^ ]$/{ s/$/\\rm/ a\ } # There must be a blank line between the "a\" and the "}" above. # WISH LIST # Handle "blah \n<196> blah" and "blah \n. . . blah" # Distinguish between en-dashes and hyphens and minuses. Make: # "after a 2-second delay, he rolled a 9, -4 for TLs 5-9. 9-4=5, so" # produce: # "after a 2-second delay, he rolled a 9, $-$4 for TLs 5--9. 9$-$4=5, so" # (of course, # "after a 2-second delay, he rolled a 9, $-4$ for TLs 5--9. $9-4=5$, so" # would be better...).