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