> from panflute import * > p1 = Para ( Str ( 'Spam' ), Space, Emph ( Str ( 'and' ), Space, Str ( 'eggs' ))) > p2 = Para ( Str ( 'eggs' )) > p3 = Plain ( Emph ( Str ( 'eggs' ))) > doc = Doc ( p1, p2, p3 ) > doc. Will be replaced instead, but only if possible As a solution, the closest ancestor (e.g. Note: If the replacement is a block, it cannot be put in place ofĪ Str element. Usually applied to an entire document (a Doc element) Walk through the element and its children Note that elem.offset(1) = elem.next Return type :Įlement | None replace_keyword ( keyword, replacement ) ¶ Note that elem.offset(-1) = elem.prev Return type : Return a sibling element offset by n Return type : Note that elem.ancestor(1) = elem.parent Return type : (such as Table that has children in the header andĬaption attributes). Note: some elements have children in attributes other than content Only available for elements that accept *args. Or Inline) that are “children” of the current element. Sequence of Element objects (usually either Block Stop_if ( function, optional) – function that takes (element) as argument. You don’t want to use the current document of an element. Only use this variable if for some reason walk ( no_action ) Parameters :Īction ( function) – function that takes (element, doc) as arguments.ĭoc ( Doc) – root document used to access metadata, From panflute import * def no_action ( elem, doc ): pass doc = Doc ( Para ( Str ( 'a' ))) altered = doc.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |