Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chapters2documents.rb example raises an error #77

Closed
xbelanch opened this issue May 2, 2023 · 5 comments
Closed

chapters2documents.rb example raises an error #77

xbelanch opened this issue May 2, 2023 · 5 comments
Assignees
Labels

Comments

@xbelanch
Copy link

xbelanch commented May 2, 2023

Pandoc responded with:

data-dir/filters/chapters2documents.rb:22:in `block in <main>': undefined method `parent' for nil:NilClass (NoMethodError)
	from /home/xbelanch/.rvm/gems/ruby-3.0.0/gems/paru-1.1.0/lib/paru/filter.rb:290:in `instance_eval'
	from /home/xbelanch/.rvm/gems/ruby-3.0.0/gems/paru-1.1.0/lib/paru/filter.rb:290:in `filter'
	from /home/xbelanch/.rvm/gems/ruby-3.0.0/gems/paru-1.1.0/lib/paru/filter.rb:252:in `run'
	from data-dir/filters/chapters2documents.rb:15:in `<main>'
Error running filter data-dir/filters/chapters2documents.rb:
@htdebeer
Copy link
Owner

htdebeer commented May 2, 2023

Thanks for your bug report. However, it's a bit sparse on the details. For me to look into your issue, I need to be able to reproduce your issue on my end. To that end, can you:

  • supply a minimal but complete example where this issue occurs? I.e., have an input file, the actual filter, and the pandoc invocation that results in this error message?
  • tell me which operating system and pandoc version you're using when this issue occurs?

@xbelanch
Copy link
Author

xbelanch commented May 2, 2023

Sorry @htdebeer for the laconic and not helpful bug report. Hope this helps out to reproduce the issue and find the solution:

Operaing System: WSL2 (Linux X99-Rotter 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 GNU/Linux) under Windows 10 Pro 19045.2846.

Pandoc version:

$ pandoc -v
pandoc 3.1.1
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/xbelanch/.pandoc
Copyright (C) 2006-2023 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

I included a simple demo files that raises the error. Btw the full output:

pandoc	--from=markdown \
	--to=html \
	--filter=data-dir/filters/chapters2documents.rb

Pandoc responded with:

data-dir/filters/chapters2documents.rb:22:in `block in <main>': undefined method `parent' for nil:NilClass (NoMethodError)
	from /home/xbelanch/.rvm/gems/ruby-3.0.0/gems/paru-1.1.0/lib/paru/filter.rb:291:in `instance_eval'
	from /home/xbelanch/.rvm/gems/ruby-3.0.0/gems/paru-1.1.0/lib/paru/filter.rb:291:in `filter'
	from /home/xbelanch/.rvm/gems/ruby-3.0.0/gems/paru-1.1.0/lib/paru/filter.rb:253:in `run'
	from data-dir/filters/chapters2documents.rb:15:in `<main>'
Error running filter data-dir/filters/chapters2documents.rb:
Filter returned error status 1

Using configuration hierarchy: - /home/xbelanch/.rvm/gems/ruby-3.0.0/gems/pandocomatic-1.1.0/lib/pandocomatic/default_configuration.yaml - /home/xbelanch/Programming/playground/77/pandocomatic.yml 1 command to execute to convert '/home/xbelanch/Programming/playground/77/sandbox.md' to 'output/index.html'. pandoc --from=markdown \ --to=html \ --filter=data-dir/filters/chapters2documents.rb

77.zip

@htdebeer htdebeer added the bug label May 2, 2023
@htdebeer htdebeer self-assigned this May 2, 2023
@htdebeer
Copy link
Owner

htdebeer commented May 2, 2023

I can reproduce the issue. I think I've introduced this erroneous behavior when I added the before and after blocks feature in #38.

I'll fix this, but that might take a week or so. Until then, as a workaround, only use current_node when Filter's instance variable @ran_before is true. In your example, you can write:

...
  if @ran_before
    doc << current_node if current_node.parent.is_a? Paru::PandocFilter::Document
  end
...

@htdebeer
Copy link
Owner

htdebeer commented May 13, 2023

Can you verify that your issue is resolved with paru version 1.1.1?

@xbelanch
Copy link
Author

Works flawlessly! Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants