diff --git a/stories/A_Child_s_Letter.The_Mirror.tex b/stories/A_Child_s_Letter.The_Mirror.tex new file mode 100644 index 0000000..347a54e --- /dev/null +++ b/stories/A_Child_s_Letter.The_Mirror.tex @@ -0,0 +1,88 @@ +\chapauth{A Child's Letter} +\chapter{The Mirror} + +Luke Bavarious' eyes rolled around in their sockets, finally allowing +him to focus again on the bathroom mirror. His Beretta still in hand, he +wiped the few remaining flecks of sick from his mouth. + +{\em What can't I remember? I don't have any idea what I've, + what's\ldots uggh! Too much shitty tequila}, he concluded. Again, he +vomited. + +The reflection gazing back at him nodded even as Bavarious nodded. + +{\em I can't live like this! I'm a cop, dammit! I'm a cop! I'm a + copI'macopI'macopI'macop}, he thought, his mind shrieking the mantra, +causing liquid rust to ooze from his flaring nostrils. + +The reflection gazing back at him blinked. Bavarious did not. + +{\em What the hell?!} + +Suddenly, rancid vomit streamed from the Bavarious in the mirror, +splattering the glass and causing the other to recoil. Bavarious +stepped---or stumbled, rather---back, raised his weapon, and aimed for +the reflection's chest. + +{\sc Boom!} + +Red pain arced across his frame moments after he pulled the +trigger. Shards of silvered glass protruded evilly from his hands and +chest, callously inviting Bavarious' tattered sports coat to greedily +lick away every spent drop of blood. + +On the other side of what had been the mirror, the ``reflection'' stood, +grinning lustily at its fallen doppelgänger. + +``Who\ldots what\ldots what are you!'' wondered Bavarious aloud. + +{\em I am you}, projected the specter as it placed a shaking withered +hand on either side of the mirror's frame and thrust an impossibly long +and spidery leg through the opening. + +``The {\em fuck} you are!'' shouted Bavarious, who fired three more +rounds into the advancing creature. As every mushrooming burst of metal +rage ripped into it, Bavarious felt as though {\em he} had been shot. + +``What are you {\em doing} to me!'' he roared, or tried to: his voice, +hoarse, weakly reverberated throughout the dismal room. His crimson +lifeforce spread out before him, pooling in a macabre circle. + +{\em What am I doing to you? The question, Luke, is what are you doing + to you.} + +{\em I don't know what you're---shit, now {\em I'm} doing it---} + +``I don't know what you're talking about!'' + +{\em I know}, it smiled as it injected itself into Baravious' +reality. {\em I know.} + +That's when Bavarious realized the smile wasn't one of joy or elation; +rather, it was one of rueful, inescapable sadness. The kind of smile one +smiles when, having done everything to avoid a foregone conclusion, the +conclusion looms inevitable. + +{\em I don't want to die}, whined Bavarious. {\em What do I do?} + +``You...die, Luke,'' it whispered. + +Gently---lovingly, it stroked Bavarious' cheek with its bony +fingers. With every tortured breath, Bavarious felt his body contort, +stretch out, become more like that of the entity now cradling his +convulsing head. + +Maybe it was a trick of the greenish ultraviolet light; maybe it was his +uncontrollable spasms, but Bavarious was almost---no, he was one hundred +percent positive that the monster was somehow {\em condensing}, +coalescing: somehow, its thready arms and legs were gaining proportion +even as its previously gaunt features seemed to swell with health. + +Through the multifaceted, bloodstained reflection of a shattered +bathroom mirror, the last thing Bavarious ever saw was {\em himself} +reach down and collect his Beretta. + +{\em I'm a cop}, he sighed. + +``I'm a cop,'' he said aloud, tucking his sidearm within the confines of +his tattered sports coat and walking briskly from the room. diff --git a/toepub.py b/toepub.py new file mode 100755 index 0000000..4eb96b0 --- /dev/null +++ b/toepub.py @@ -0,0 +1,203 @@ +#! /usr/bin/env python3 + +import re + +block1_re = re.compile(r'{\\(?P[\w*]+) (?P[^{}]+)}') +block2_re = re.compile(r'\\(?P[\w*]+)(\[[^]]+\])?{(?P[^{}]*)}') + + +chapauth = None +chapimg = None +display = True +pfx = '' + +def texsub(m): + global pfx, display + + cmd = m.group('cmd') + txt = m.group('txt') + if cmd == 'em': + return '%s' % txt + elif cmd == 'bf': + return '%s' % txt + elif cmd == 'sf': + return '%s' % txt + elif cmd == 'sc': + return '%s' % txt + elif cmd == 'rm': + return '%s' % txt + elif cmd == 'url': + return '%s' % (txt, txt) + elif cmd == 'begin': + if txt in ('center',): + return + elif txt in ('quotation', 'quote'): + pfx = '> ' + elif txt == 'textblock': + display = False + else: + print(cmd, txt) + raise TypeError(cmd) + elif cmd == 'end': + if txt == 'textblock': + display = True + else: + pfx = '' + return '' + elif cmd in ('include', + 'chapter', + 'chapimg', + 'chapauth', + 'illustration', + 'scriptsize', + 'section*', + 'part'): + return '#%s %s' % (cmd, txt) + elif cmd in ('pagenumbering', + 'includegraphics', + 'newcommand', + 'hbox'): + return '' + elif cmd in ('TeX', + 'LaTeX'): + return cmd + else: + print(cmd, txt) + raise TypeError(cmd) + +decor_stack = [] +decor_re = re.compile(r'({\\(?P\w\w) ?|})') + +def decorsub(m): + cmd = m.group('cmd') + if not cmd: + if not decor_stack: + return m.group(0) + cmd = decor_stack.pop() + return '' % cmd + else: + if cmd == 'bf': + cmd = 'strong' + elif cmd == 'em': + pass + elif cmd == 'sc': + decor_stack.append('span') + return '' + else: + raise TypeError(cmd) + decor_stack.append(cmd) + return '<%s>' % cmd + +def art(artist, url, title=None): + alt = title or ("Artwork by %s" % artist) + print('
') + print('%s' % (url, alt)) + if title: + print('%s by %s' % (title, artist)) + else: + print(alt) + print('
') + +outbuf = '' + +def outline(l): + global chapimg, chapauth, outbuf + + l = l.strip() + if not l: + print(outbuf) + elif l[0] == '%': + return + l = l.replace(r'\'e', 'é') + l = l.replace(r'\,c', 'ç') + l = l.replace(r'\'n', 'ń') + l = l.replace("''", '”') + l = l.replace("``", '“') + l = l.replace("'", '’') + l = l.replace("`", '‘') + l = l.replace('---', '—') + l = l.replace('--', '–') + l = l.replace('\\\\', '
') + l = l.replace('\_', '_') + l = l.replace('\#', '#') + l = l.replace('\$', '$') + l = l.replace('\ ', ' ') + l = l.replace(r'\-', '') + l = l.replace(r'\~n', 'ñ') + l = l.replace(r'{\ldots}', '…') + l = l.replace(r'\ldots', '…') + l = l.replace(r'\copyright', '©') + l = block1_re.sub(texsub, l) + l = block2_re.sub(texsub, l) + l = l.replace('{}', '') + l = decor_re.sub(decorsub, l) + + if not l: + return + if l[0] == '#': + if l.startswith('#include'): + include(l[9:] + '.tex') + elif l.startswith('#chapimg'): + chapimg = l[9:-1].split('{') + elif l.startswith('#chapauth'): + chapauth = l[10:] + elif l.startswith('#chapter'): + print('

%s

' % l[9:]) + if chapauth: + print('

by %s

' % chapauth) + chapauth = None + if chapimg: + art(chapimg[0], chapimg[1]) + chapimg = None + elif l.startswith('#part'): + print('

%s

' % l[6:]) + elif l.startswith('#illustration'): + artist, title, url = l[14:].split('{') + title = title[:-1] + url = url[:-1] + art(artist, url, title) + elif l.startswith('#section*'): + print('

%s

' % l[10:]) + else: + print('<--! %s -->' % l) + elif l[0] == '\\': + what = l[1:5].lower() + if what in ('bigs', 'vfil'): + print('
') + elif what == 'newp': + print('
') + elif what == 'noin': + print(l[10:]) + elif what in ('hbox', + 'inde', + 'tabl', + 'appe', + 'page', + 'list'): + pass + elif l[1:9] == 'maketitl': + print('

Horrors 2

') + print('

The Something Awful Forums

') + else: + print('================= %r' % what) + elif display: + print('%s%s' % (pfx, l)) + +def include(fn): + if fn == 'praise.tex': + return + f = open(fn) + + for l in f: + outline(l) + +f = open('horrors2.ltx') + +# skip LaTeX crap +for l in f: + if l.startswith('\\begin{document'): + break + +for l in f: + outline(l) +