|
|
@ -11,10 +11,14 @@ from .output_generator import OutputGenerator |
|
|
|
from .images import ImageProcessor, ImageProcessorNamespaceSearcher |
|
|
|
|
|
|
|
from .whitespace import NBSP |
|
|
|
from .elements import FQuoted |
|
|
|
from .elements import FQuoted, FLineMarkup |
|
|
|
from .context import Group, InlineGroup, BlockGroup, Context |
|
|
|
from .util import inlinify |
|
|
|
|
|
|
|
def color_to_rgb(color): |
|
|
|
import matplotlib.colors |
|
|
|
return matplotlib.colors.to_rgb(color) |
|
|
|
|
|
|
|
class UCWTexGenerator(OutputGenerator): |
|
|
|
imageProcessor: ImageProcessor |
|
|
|
_bold: int |
|
|
@ -254,7 +258,7 @@ class UCWTexGenerator(OutputGenerator): |
|
|
|
"AlignDefault": r"\quad#\quad\hfil" |
|
|
|
} |
|
|
|
self.writeln(r"\vskip1em") |
|
|
|
self.writeln(r"\halign{\strut"+"&".join([aligns[col[0]] for col in e.colspec])+r"\cr") |
|
|
|
self.writeln(r"\leavevmode\vbox{\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{\vskip 0.3em\hrule\vskip 0.3em}") |
|
|
@ -262,7 +266,7 @@ class UCWTexGenerator(OutputGenerator): |
|
|
|
self.writeln(r"\noalign{\vskip 0.3em\hrule\vskip 0.3em}") |
|
|
|
self.generate(e.foot.content) |
|
|
|
self.indent_less() |
|
|
|
self.writeln("}") |
|
|
|
self.writeln("}}") |
|
|
|
self.writeln(r"\vskip1em") |
|
|
|
|
|
|
|
def generate_TableRow(self, e: TableRow): |
|
|
@ -296,6 +300,16 @@ class UCWTexGenerator(OutputGenerator): |
|
|
|
|
|
|
|
def generate_Div(self, e: Div): |
|
|
|
self.generate(e.content) |
|
|
|
|
|
|
|
def generate_FLineMarkup(self, e: FLineMarkup): |
|
|
|
self.ensure_empty(2) |
|
|
|
r,g,b = color_to_rgb(e.color) |
|
|
|
self.writeln(r"\linemarkup{\rgb{"+f"{r} {g} {b}"+"}}{") |
|
|
|
self.indent_more() |
|
|
|
self.generate(e.content) |
|
|
|
self.indent_less() |
|
|
|
self.writeln(r"}") |
|
|
|
self.ensure_empty(2) |
|
|
|
|
|
|
|
def generate_LineBlock(self, e: LineBlock): |
|
|
|
self.writeln() |
|
|
|