What is the correct use of the RawBlock
function in Pandoc filters?
#!/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)
You are trying to replace an Inline value (Str
) with a Block value (RawBlock
). One can only replace elements with elements of the same type. Use RawInline
instead of RawBlock
.