htdebeer / pandocomatic

Automate the use of pandoc

Home Page:https://heerdebeer.org/Software/markdown/pandocomatic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pandocomatic crashes when I put two horizontal rules in my input document

Saltlane opened this issue · comments

Hi, I have followed all the instructions, but still can't get Scrivomatic/pandocomatic to work. I did the rbenv install to see if it was a ruby issue, but still fails. Can you help? Log attached. Thanks

scrivomatic.log

I am not familiar with scrivomatic, and your log file doesn't help me much to investigate your issue. Can you supply me with a minimal reproducible scenario using pandocomatic only?

Apologies, I thought you had written them all. I will try to reproduce outside of Scrivener (which is the scrivomatic script part) and use Pandocomatic only. It may take me a day or two to test and I will report back. Thanks

I have set up a test with pandocomatic only and got the same errors.

Pandocomatic version 1.1.0
Pandoc version 3.1.6.2

Command executed 'pandocomatic test.md'

Log:
timothyjsmith@MacBook-Pro documents % pandocomatic test.md
[UNEXPECTED ERROR] An unexpected error has occurred. You can report this bug via https://github.com/htdebeer/pandocomatic/issues/new.
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/psych.rb:456:in parse': (<unknown>): did not find expected alphabetic or numeric character while scanning an alias at line 3 column 1 (Psych::SyntaxError) from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/psych.rb:456:in parse_stream'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/psych.rb:390:in parse' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/psych.rb:349:in safe_load'
from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandocomatic_yaml.rb:44:in load' from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandoc_metadata.rb:198:in block in initialize'
from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandoc_metadata.rb:198:in map' from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandoc_metadata.rb:198:in initialize'
from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandoc_metadata.rb:188:in new' from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandoc_metadata.rb:188:in extract_metadata'
from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandoc_metadata.rb:62:in load' from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandoc_metadata.rb:51:in load_file'
from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/command/convert_file_multiple_command.rb:52:in initialize' from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandocomatic.rb:87:in new'
from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/lib/pandocomatic/pandocomatic.rb:87:in run' from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-1.1.0/bin/pandocomatic:3:in <top (required)>'
from /usr/local/bin/pandocomatic:23:in load' from /usr/local/bin/pandocomatic:23:in

'

test .md file:
test.md

Thanks for supplying the minimal scenario! I've been able to reproduce it.

I notice you have put two horizontal rules in the test file using three dashes (---). That's the correct pandoc syntax for horizontal rules. However, it is also the pandoc syntax to start and end a YAML metadata block. And pandocomatic uses these three dashes to find and read these YAML metadata blocks before it runs pandoc. Unfortunately, pandocomatic cannot reliably determine if two lines with three dashes are two horizontal rules or a YAML metadata block.

Luckily, you can easily work around this limitation by using four or more dashes to denote a horizontal rule in your input documents.

This work around indeed fixes the issue, however it's hard to find the file with the issue, since searching for '---' will return almost every file with a YAML data block. Would It be possible to provide the filename that causes the error a hint, because the current error message is not helpful at all?

That should be possible, I'll look into adding and printing the filename where things go wrong.

By the way, does option "--debug" help to locate the problematic file?

Also relates to #112, which asks for more logging.

I invoke pandocomatic with the following command line:

pandocomatic -m -b -d ./ -i src -o dest

Where the -b equals the --debug if I am not mistaken, so the output I shared is with debug mode enabled.

I agree with you: It isn't very helpful. And I've gotten more bug reports regarding the YAML parsing bit, so I'll try to make the error reporting in these situations more clear. And if I'm doing that anyway, I can also check if the error is caused by the three-dashed horizontal lines or some other issue.

Fixing the three dashes would be nice, but knowing the file it fails is the best. In case of any other unknown errors it makes it way easier to debug. BTW the software is amazing and rendering very nice docs and pdfs. Thank you so much for your time and effort! Love the tool.

I've changed the behavior when reporting errors during reading metadata blocks. It is available in pandocomatic version 1.1.1. Does this error message suffice to find the file where pandocomatic gets stuck parsing metadata / horizontal lines?

Thank you Huub, updated to 1.1.1 and ran my conversion script that calls pandoc. It gives very neat error messages now. The message on the (4) dashes is very helpful in general, but the thing that is especially helpful is the mentioning of the filename that contains issues, and the naming of the line and column number to further detail the location.

Thanx a million!