htdebeer / pandocomatic

Automate the use of pandoc
https://heerdebeer.org/Software/markdown/pandocomatic/
GNU General Public License v3.0
158 stars 14 forks source link

Pandocomatic crash: mapping values are not allowed in this context #110

Closed cls02 closed 1 year ago

cls02 commented 1 year ago

Hi,

Getting this message when running pandocomatic:

[UNEXPECTED ERROR] An unexpected error has occurred. You can report this bug via https://github.com/htdebeer/pandocomatic/issues/new. /opt/homebrew/lib/ruby/gems/3.2.0/gems/psych-5.0.2/lib/psych/parser.rb:62:in _native_parse': (<unknown>): mapping values are not allowed in this context at line 13 column 78 (Psych::SyntaxError) from /opt/homebrew/lib/ruby/gems/3.2.0/gems/psych-5.0.2/lib/psych/parser.rb:62:inparse' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/psych-5.0.2/lib/psych.rb:455:in parse_stream' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/psych-5.0.2/lib/psych.rb:399:inparse' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/psych-5.0.2/lib/psych.rb:323:in safe_load' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandocomatic_yaml.rb:44:inload' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandoc_metadata.rb:198:in block in initialize' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandoc_metadata.rb:198:inmap' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandoc_metadata.rb:198:in initialize' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandoc_metadata.rb:188:innew' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandoc_metadata.rb:188:in extract_metadata' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandoc_metadata.rb:62:inload' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandoc_metadata.rb:51:in load_file' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/command/convert_file_multiple_command.rb:52:ininitialize' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandocomatic.rb:87:in new' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/lib/pandocomatic/pandocomatic.rb:87:inrun' from /opt/homebrew/lib/ruby/gems/3.2.0/gems/pandocomatic-1.0.4/bin/pandocomatic:3:in <top (required)>' from /opt/homebrew/lib/ruby/gems/3.2.0/bin/pandocomatic:25:inload' from /opt/homebrew/lib/ruby/gems/3.2.0/bin/pandocomatic:25:in `

'

htdebeer commented 1 year ago

Thanks for your bug report. I do need more information to reproduce your issue:

Can you also supply a minimal example where this issue occurs? Including a minimal test file and the actual pandocomatic invocation on the command line.

cls02 commented 1 year ago

Hi,

Thanks - I had some problem with the metadata as exported by Scrivener. When I fix that, I now get the following with a simple invocation.

I left the original metadata, as it seems to be related to that, and to incompatible library versions, if I understand the below message.

pandocomatic.yaml and Minimal.md attached for your perusal.

Run:


cls@MacBook-Pro Backsourcing-mmd % pandocomatic -c pandocomatic.yaml Minimal.md
WARNING: Ignoring the pandoc option --verbose because it might interfere with the working of pandocomatic.
[INFO] Loaded addpackages.sty from addpackages.sty
[INFO] Running filter /Users/cls/.local/share/pandoc/filters/assimilateMetadata.rb
JSON parse error: Error in $: Incompatible API versions: encoded with [1,22] but attempted to decode with [1,23].
/opt/homebrew/lib/ruby/gems/3.2.0/gems/paru-1.0.3/lib/paru/filter/metadata.rb:49:in `initialize': undefined method `empty?' for nil:NilClass (NoMethodError)

                    if yaml_string.empty?
                                  ^^^^^^^
    from /opt/homebrew/lib/ruby/gems/3.2.0/gems/paru-1.0.3/lib/paru/filter.rb:279:in `new'
    from /opt/homebrew/lib/ruby/gems/3.2.0/gems/paru-1.0.3/lib/paru/filter.rb:279:in `filter'
    from /opt/homebrew/lib/ruby/gems/3.2.0/gems/paru-1.0.3/lib/paru/filter.rb:251:in `run'
    from /Users/cls/.local/share/pandoc/filters/assimilateMetadata.rb:77:in `<main>'
Error running filter /Users/cls/.local/share/pandoc/filters/assimilateMetadata.rb:
Filter returned error status 1
Error running pandoc => error while running:

pandoc  --bibliography=/Users/cls/.local/share/pandoc/simulareferences.bib \
    --from=markdown \
    --filter=/Users/cls/.local/share/pandoc/filters/assimilateMetadata.rb \
    --filter=/Users/cls/.local/share/pandoc/filters/intquotes.py \
    --filter=/Users/cls/.local/share/pandoc/filters/pandoc_tablenos.py \
    --template=/Users/cls/.local/share/pandoc/svjour3.latex \
    --include-in-header=addpackages.sty \
    --natbib \
    --to=latex \
    --standalone \
    --verbose

Pandoc responded with:

[INFO] Loaded addpackages.sty from addpackages.sty
[INFO] Running filter /Users/cls/.local/share/pandoc/filters/assimilateMetadata.rb
JSON parse error: Error in $: Incompatible API versions: encoded with [1,22] but attempted to decode with [1,23].
/opt/homebrew/lib/ruby/gems/3.2.0/gems/paru-1.0.3/lib/paru/filter/metadata.rb:49:in `initialize': undefined method `empty?' for nil:NilClass (NoMethodError)

                    if yaml_string.empty?
                                  ^^^^^^^
    from /opt/homebrew/lib/ruby/gems/3.2.0/gems/paru-1.0.3/lib/paru/filter.rb:279:in `new'
    from /opt/homebrew/lib/ruby/gems/3.2.0/gems/paru-1.0.3/lib/paru/filter.rb:279:in `filter'
    from /opt/homebrew/lib/ruby/gems/3.2.0/gems/paru-1.0.3/lib/paru/filter.rb:251:in `run'
    from /Users/cls/.local/share/pandoc/filters/assimilateMetadata.rb:77:in `<main>'
Error running filter /Users/cls/.local/share/pandoc/filters/assimilateMetadata.rb:
Filter returned error status 1

Hope this helps. Minimal.md pandocomatic.yaml.txt

cls02 commented 1 year ago

Narrowed it down to the use-template directive in the pandocomatic_ section in metadata. All other fields seem to parse ok.

htdebeer commented 1 year ago

The error "~JSON parse error: Error in $: Incompatible API versions: encoded with [1,22] but attempted to decode with [1,23]`" suggests you're using a newer version of pandoc than that's currently supported by pandocomatic. If you're using pandoc 3.x, can you downgrade to 2.x and try again?

I've already made an issue to upgrade pandocomatic for use with pandoc 3.x (#109), but haven't gotten around to it because I've been moving house.

cls02 commented 1 year ago

This was indeed the case - homebrew had updated pandoc to version 3, and I had not noticed. Thanks for you quick responses, and apologies for wasting your time!

Hope your relocation went well.

htdebeer commented 1 year ago

apologies for wasting your time!

No need to apologize. Every bug report is valuable because it signals an issue with the software, documentation, or what users expect vs what happens. We need these signals to improve the software.

So, thanks for the feedback!

(And I'll try to update pandocomatic for pandoc 3.x in the coming two weeks. I'll let you know when it's finished)

cls02 commented 1 year ago

Thanks!

Casper

From: Huub de Beer @.> Reply to: htdebeer/pandocomatic @.> Date: Wednesday 1. February 2023 at 10.29 To: htdebeer/pandocomatic @.> Cc: Casper Lassenius @.>, State change @.***> Subject: Re: [htdebeer/pandocomatic] Pandocomatic crash: mapping values are not allowed in this context (Issue #110)

apologies for wasting your time!

No need to apologize. Every bug report is valuable because it signals an issue with the software, documentation, or what users expect vs what happens. We need these signals to improve the software.

So, thanks for the feedback!

(And I'll try to update pandocomatic for pandoc 3.x in the coming two weeks. I'll let you know when it's finished)

— Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fhtdebeer%2Fpandocomatic%2Fissues%2F110%23issuecomment-1411735075&data=05%7C01%7Ccls%40aaltofi.mail.onmicrosoft.com%7Ccf9ee7441dec4df766ee08db0436d916%7Cae1a772440414462a6dc538cb199707e%7C1%7C0%7C638108405842365674%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HJdM5J%2B8t%2FlZ0mjcj82gj8xjwJwXNSwGxFJL1IXvWik%3D&reserved=0, or unsubscribehttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAKHWQEBAEQCZTIMRBFWT33WVIUIHANCNFSM6AAAAAAUMOICF4&data=05%7C01%7Ccls%40aaltofi.mail.onmicrosoft.com%7Ccf9ee7441dec4df766ee08db0436d916%7Cae1a772440414462a6dc538cb199707e%7C1%7C0%7C638108405842365674%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=jZV169zZTgSOTEM3F90ykxVVn7GszQ%2FgR9jFyWljYhs%3D&reserved=0. You are receiving this because you modified the open/close state.Message ID: @.***>

htdebeer commented 1 year ago

I've updated pandocomatic for use with pandoc 3. Use pandocomatic version 1.1 or up with pandoc 3.x.