1

RawBlockPandoc过滤器中函数的正确用法是什么?

#!/usr/bin/env python

from pandocfilters import toJSONFilter, Str, Para, Emph, Header, RawBlock
import re

def replace(key, value, format, meta):
    if key == 'Str':
        if value.startswith('Hello'):
            #return Str("Hi")  # this works
            return RawBlock("opendocument", "Hi")  # this doesn't

if __name__ == '__main__':
    toJSONFilter(replace)
4

1 回答 1

3

您正在尝试用值 ( ) 替换内联值( )。只能用相同类型的元素替换元素。使用而不是.StrRawBlockRawInlineRawBlock

于 2019-06-17T09:17:18.457 回答