DCsunset / pandoc-include

A pandoc filter to allow file and header inclusion
MIT License
67 stars 14 forks source link

Another issue with code blocks and horizontal lines #24

Closed aubertc closed 3 years ago

aubertc commented 3 years ago

The following markdown file:

``` * ```

when compiled with

pandoc --filter pandoc-include test.md -o test.html

returns

Traceback (most recent call last):
  File "~/.local/bin/pandoc-include", line 8, in <module>
    sys.exit(main())
  File "~/.local/lib/python3.7/site-packages/pandoc_include/main.py", line 380, in main
    return pf.run_filter(action, doc=doc)
  File "~/.local/lib/python3.7/site-packages/panflute/io.py", line 224, in run_filter
    return run_filters([action], *args, **kwargs)
  File "~/.local/lib/python3.7/site-packages/panflute/io.py", line 205, in run_filters
    doc = doc.walk(action, doc)
  File "~/.local/lib/python3.7/site-packages/panflute/base.py", line 264, in walk
    ans = list(chain.from_iterable(ans))
  File "~/.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 "~/.local/lib/python3.7/site-packages/panflute/base.py", line 259, in <genexpr>
    ans = (item.walk(action, doc) for item in obj)
  File "~/.local/lib/python3.7/site-packages/panflute/base.py", line 275, in walk
    altered = action(self, doc)
  File "~/.local/lib/python3.7/site-packages/pandoc_include/main.py", line 363, in action
    includeType, name, config = is_code_include(elem)
  File "~/.local/lib/python3.7/site-packages/pandoc_include/main.py", line 98, in is_code_include
    value, name, config = is_include_line(new_elem)
  File "~/.local/lib/python3.7/site-packages/pandoc_include/main.py", line 67, in is_include_line
    if (len(elem.content) not in [3, 4]) \
  File "~/.local/lib/python3.7/site-packages/panflute/base.py", line 106, in content
    return self._content
AttributeError: 'HorizontalRule' object has no attribute '_content'
Error running filter pandoc-include:
Filter returned error status 1

Note that the file does not perform any actual inclusion and compile just fine without the filter.

DCsunset commented 3 years ago

Thanks for your feedback. It seems that some objects don't have the _content attribute. So in the latest commit, I add a check to fix this problem. It should also fix #23.

aubertc commented 3 years ago

https://github.com/DCsunset/pandoc-include/commit/143648375e1714692346b8c4230f4dbe59720d12 fixes it.

Thanks for resolving the issue so fast. When will the pip package be updated?

DCsunset commented 3 years ago

Hello, I have just updated the pip package. Closing it.