@ -15,7 +15,6 @@ class FQuoted(Quoted):
def transform ( e : Element , c : Context ) - > Element : # Returns next sibling element to transform
""" Transform the AST, making format-agnostic changes. """
if isinstance ( e , Whitespace ) and bavlna ( e , c ) :
e = NBSP ( )
@ -41,7 +40,7 @@ def transform(e: Element, c: Context) -> Element: # Returns next sibling element
# commands without affecting the state of the current document.
if ( isinstance ( e , Div ) ) and " partial " in e . attributes :
includedDoc = import_md ( open ( e . attributes [ " partial " ] , " r " ) . read ( ) )
nContext = Context ( includedDoc , c )
nContext = Context ( includedDoc , e . attributes [ " partial " ] , c )
includedDoc = includedDoc . walk ( transform , nContext )
e = Div ( * includedDoc . content )
@ -60,9 +59,17 @@ def transform(e: Element, c: Context) -> Element: # Returns next sibling element
## Command defines
# possible TODO: def/longdef?
if isinstance ( e , CodeBlock ) and hasattr ( e , " classes " ) and " python " in e . classes and hasattr ( e , " attributes " ) :
if isinstance ( e , CodeBlock ) and hasattr ( e , " classes " ) and " python " in e . classes and hasattr ( e , " attributes " ) \
and ( " define " in e . attributes or " redefine " in e . attributes ) :
e = handle_command_define ( e , c )
# Pass down metadata 'highlight' and 'highlight_style' as attribute to CodeBlocks
if isinstance ( e , CodeBlock ) :
if not " highlight " in e . attributes :
e . attributes [ " highlight " ] = c . get_metadata ( " highlight " ) if c . get_metadata ( " highlight " ) is not None else True
if not " style " in e . attributes :
e . attributes [ " style " ] = c . get_metadata ( " highlight_style " ) if c . get_metadata ( " highlight_style " ) is not None else " default "
## Shorthands
if isinstance ( e , Span ) and len ( e . content ) == 1 and isinstance ( e . content [ 0 ] , Str ) :
## Handle special command shorthand [!commandname]{}