@ -2,6 +2,7 @@ from panflute import *
from whitespace import NBSP
from transform import FQuoted
from util import inlinify
# Heavily inspired by: git://git.ucw.cz/labsconf2022.git
def tex ( e , indent_level : int = 0 , indent_str : str = " \t " ) - > str :
@ -103,12 +104,25 @@ def tex(e, indent_level: int=0, indent_str: str="\t") -> str:
close = " \\ endlist "
# FIXME: Starting number of list
if isinstance ( e , Image ) :
return f ' \\ image {{ width { e . attributes [ " width " ] if " width " in e . attributes else " " } }} {{ { e . url } }} '
if isinstance ( e , Figure ) :
return f ' \\ figure {{ { tex ( e . content , indent_level + 1 , indent_str ) } }} {{ { tex ( e . caption , indent_level + 1 , indent_str ) } }} \n \n '
if isinstance ( e , Caption ) :
if inlinify ( e ) is not None :
return f ' \\ caption {{ { tex ( e . content , 0 , " " ) } }} '
if isinstance ( e , ListItem ) :
tag = " : "
if isinstance ( e , Link ) :
tag = " linkurl "
arguments = f ' {{ { e . url } }} '
if len ( e . content ) == 1 and isinstance ( e . content [ 0 ] , Str ) and e . content [ 0 ] . text == e . url :
tag = " url "
else :
tag = " linkurl "
arguments = f ' {{ { e . url } }} '
if isinstance ( e , Math ) :
if e . format == " DisplayMath " :
@ -118,8 +132,8 @@ def tex(e, indent_level: int=0, indent_str: str="\t") -> str:
if isinstance ( e , Note ) :
tag = " fn "
if len ( e . content ) == 1 and isinstance ( e . content [ 0 ] , Para ) :
return f ' \\ fn {{ { tex ( e . content [ 0 ] . content , 0 , " " ) } }} '
if inlinify ( e ) is not None :
return f ' \\ fn {{ { tex ( inlinify ( e ) , 0 , " " ) } }} '
if isinstance ( e , RawInline ) :
if e . format == " tex " :