DCsunset / pandoc-include

A pandoc filter to allow file and header inclusion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pandoc-include crash when the first line of some code is indented

aubertc opened this issue · comments

Consider the following MWE:

```
    I'm indented!
I'm not.
```

pandoc compiles it just fine to

<pre><code>    I&#39;m indented!
I&#39;m not.</code></pre>

but with the latest update, pandoc test.md --filter pandoc_include.py -o test.html crashes with

Traceback (most recent call last):
  File "pandoc_include.py", line 272, in <module>
    main()
  File "pandoc_include.py", line 268, in main
    return pf.run_filter(action, doc=doc)
  File "/home/caubert/.local/lib/python3.7/site-packages/panflute/io.py", line 224, in run_filter
    return run_filters([action], *args, **kwargs)
  File "/home/caubert/.local/lib/python3.7/site-packages/panflute/io.py", line 205, in run_filters
    doc = doc.walk(action, doc)
  File "/home/caubert/.local/lib/python3.7/site-packages/panflute/base.py", line 264, in walk
    ans = list(chain.from_iterable(ans))
  File "/home/caubert/.local/lib/python3.7/site-packages/panflute/base.py", line 262, in <genexpr>
    ans = ((item,) if type(item) != list else item for item in ans)
  File "/home/caubert/.local/lib/python3.7/site-packages/panflute/base.py", line 259, in <genexpr>
    ans = (item.walk(action, doc) for item in obj)
  File "/home/caubert/.local/lib/python3.7/site-packages/panflute/base.py", line 275, in walk
    altered = action(self, doc)
  File "pandoc_include.py", line 251, in action
    includeType, name, config = is_code_include(elem)
  File "pandoc_include.py", line 80, in is_code_include
    value, name, config = is_include_line(new_elem)
  File "pandoc_include.py", line 48, in is_include_line
    firstElem = elem.content[0]
  File "/home/caubert/.local/lib/python3.7/site-packages/panflute/base.py", line 106, in content
    return self._content
AttributeError: 'CodeBlock' object has no attribute '_content'
Error running filter pandoc_include.py:
Filter returned error status 1

This was not the case before this update, and can be resolved by removing the indentation from the first line.

This bug is fixed in commit 24383d8.
Feel free to reopen if it still exists.