|
|
@ -24,6 +24,8 @@ class UCWTexGenerator(OutputGenerator): |
|
|
|
self.imageProcessor = imageProcessor |
|
|
|
self._bold = 0 |
|
|
|
self._italic = 0 |
|
|
|
|
|
|
|
self._floatpages = {} |
|
|
|
super().__init__(output_file, *args, **kwargs) |
|
|
|
|
|
|
|
def escape_special_chars(self, text: str) -> str: |
|
|
@ -159,9 +161,8 @@ class UCWTexGenerator(OutputGenerator): |
|
|
|
self.write(e.text) |
|
|
|
self.write(r"`") |
|
|
|
|
|
|
|
def generate_Figure(self, e: Figure): |
|
|
|
self.ensure_empty(2) |
|
|
|
self.writeln(r"\float{") |
|
|
|
def generate_nonfloat_Figure(self, e: Figure): |
|
|
|
self.writeln(r"\figure{") |
|
|
|
self.indent_more() |
|
|
|
self.generate(e.content) |
|
|
|
self.indent_less() |
|
|
@ -177,8 +178,31 @@ class UCWTexGenerator(OutputGenerator): |
|
|
|
self.indent_less() |
|
|
|
self.writeln("}") |
|
|
|
self.indent_less() |
|
|
|
self.writeln(r"}{}") |
|
|
|
self.ensure_empty(2) |
|
|
|
self.writeln(r"}{}{}") |
|
|
|
|
|
|
|
|
|
|
|
def generate_Figure(self, e: Figure): |
|
|
|
if "floatpage" in e.attributes: |
|
|
|
fp = e.attributes["floatpage"] |
|
|
|
flush = fp[-1]=="!" |
|
|
|
if flush: |
|
|
|
fp = fp[:-1] |
|
|
|
self._floatpages.setdefault(fp, []) |
|
|
|
self._floatpages[fp].append(e) |
|
|
|
if flush: |
|
|
|
self.writeln(r"\floatpage{") |
|
|
|
self.writeln(r"\vfill") |
|
|
|
for x in self._floatpages[fp]: |
|
|
|
self.generate_nonfloat_Figure(x) |
|
|
|
self.writeln(r"\vfill") |
|
|
|
self.writeln(r"}") |
|
|
|
del self._floatpages[fp] |
|
|
|
else: |
|
|
|
self.ensure_empty(2) |
|
|
|
self.writeln(r"\floatinsert{") |
|
|
|
self.generate_nonfloat_Figure(e) |
|
|
|
self.writeln(r"}") |
|
|
|
self.ensure_empty(2) |
|
|
|
|
|
|
|
def generate_Emph(self, e: Emph): |
|
|
|
if self._bold > 0: |
|
|
@ -236,9 +260,9 @@ class UCWTexGenerator(OutputGenerator): |
|
|
|
self.writeln(r"\halign{\strut"+"&".join([aligns[col[0]] for col in e.colspec])+r"\cr") |
|
|
|
self.indent_more() |
|
|
|
self.generate(e.head.content) |
|
|
|
self.writeln(r"\noalign{\hrule}") |
|
|
|
self.writeln(r"\noalign{\vskip 0.3em\hrule\vskip 0.3em}") |
|
|
|
self.generate(e.content[0].content) |
|
|
|
self.writeln(r"\noalign{\hrule}") |
|
|
|
self.writeln(r"\noalign{\vskip 0.3em\hrule\vskip 0.3em}") |
|
|
|
self.generate(e.foot.content) |
|
|
|
self.indent_less() |
|
|
|
self.writeln("}") |
|
|
|