pandoc crashes if I try to replace an image
Closed this issue · 6 comments
mtomassoli commented
I'm writing a filter for pandoc, but if I try to remove images I get an error. Here's a minimal filter:
from pandocfilters import toJSONFilter, RawBlock
def filter(key, value, format, meta):
if key == 'Image':
return RawBlock('html', 'ok')
if __name__ == "__main__":
toJSONFilter(filter)
Here's the error:
pandoc: Error in $.blocks[17].c[0]: failed to parse field blocks: failed to parse field c: mempty
CallStack (from HasCallStack):
error, called at pandoc.hs:144:42 in main:Main
I call pandoc without any extra options, just --filter my_filter.py
and -o output.html
.
Version:
pandoc 1.19.2.1
Compiled with pandoc-types 1.17.0.4, texmath 0.9, skylighting 0.1.1.4
on Windows 10 x64
jgm commented
What does pandoc --version say?
And are you using an up-to-date version of the pandocfilters
library?
+++ Massimiliano Tomassoli [Dec 01 17 13:22 ]:
… I'm writing a filter for pandoc, but if I try to remove images I get an
error. Here's a minimal filter:
from pandocfilters import toJSONFilter, RawBlock
def filter(key, value, format, meta):
if key == 'Image':
return RawBlock('html', 'ok')
if __name__ == "__main__":
toJSONFilter(filter)
Here's the error:
pandoc: Error in $.blocks[17].c[0]: failed to parse field blocks: failed to
parse field c: mempty
CallStack (from HasCallStack):
error, called at pandoc.hs:144:42 in main:Main
I call pandoc without any extra options, just --filter my_filter.py and
-o output.html.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, [1]view it on GitHub, or [2]mute the
thread.
References
1. #66
2. https://github.com/notifications/unsubscribe-auth/AAAL5FRMzm9KphqHcYw14qSJcnIsHRY1ks5s8G4bgaJpZM4Qy7nz
mtomassoli commented
Pandoc --version says
pandoc 1.19.2.1
Compiled with pandoc-types 1.17.0.4, texmath 0.9, skylighting 0.1.1.4
I tried both pandocfilters-1.4.1 and -1.4.2.
jgm commented
Oh, the problem is that you use RawBlock instead of RawInline.
An image is an Inline.
Sorry, this library doesn't have very good error reporting. You might try panflute instead!
mtomassoli commented
I'm writing a <figure>
which is a block element. I thought I could choose what to use. Is there a way?
Maybe I should replace the Para...
jgm commented
You can't put a block where an inline should go.
Instead, you might try matching on Para blocks
that contain just one thing, an Image, and replacing
these whole Para blocks with your raw html block.
+++ Massimiliano Tomassoli [Dec 02 17 00:04 ]:
… I'm writing a
which is a block element. I thought I could choose what to use. Is
there a way?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, [1]view it on GitHub, or [2]mute the
thread.
References
1. #66 (comment)
2. https://github.com/notifications/unsubscribe-auth/AAAL5E2zHKDsYRAuscuu-T9o2H0wfXm5ks5s8JQJgaJpZM4Qy7nz
mtomassoli commented
I solved by replacing the containing Para. Thanks for the help and the library!