odkr / pandoc-quotes.lua

Pandoc filter that adapts quotation marks.
MIT License
7 stars 3 forks source link

Error message when running pandoc-quotes.lua #1

Closed JohnCWood closed 4 years ago

JohnCWood commented 4 years ago

I've been using an older version of pandoc-quotes for a while successfully, but am now looking towards updating to a new system, but I'm running into an error when running it. (I'll be working in a Linux\Ubuntu environment and am checking things out in a virtual machine -- Xubuntu 18.04 -- first).

john@john-VB-Xubuntu:~/Documents/Markdown_test_dir$ pandoc -s -o new_test.docx --filter pandoc-citeproc --lua-filter=pandoc-quotes.lua new_test.md 
Error running filter /home/john/.pandoc/filters/pandoc-quotes.lua:
/home/john/.pandoc/filters/pandoc-quotes.lua:192: attempt to call a nil value (global 'sub')
stack traceback:
    /home/john/.pandoc/filters/pandoc-quotes.lua:192: in main chunk

pandoc version: 2.7.3 pandoc-lua version: 0.1.9 In my document's YAML block, lang is set to "de-DE".

Pandoc without using pandoc-quotes works fine when converting to pdf and docx (just without -- in the later case -- converting the quotation marks to the German style that I need).

I would appreciate any help on this. Happy to provide any further information.

JohnCWood commented 4 years ago

Following up on the above, I examined line 192, which was causing the error.

After that, I did some looking around and found this advice:

https://www.luafaq.org/#T1.40

package.config is a string where the first 'character' is the directory separator; so package.config:sub(1,1) is either a slash or a backslash. As a general rule, try to use this when building paths.

So, in the pandoc-quotes.lua file, I changed...

--- The path seperator of the operating system.
PATH_SEP = sub(package.config, 1, 1)

...to...

--- The path seperator of the operating system.
PATH_SEP = package.config:sub(1,1)

...and it worked.

Again, this was on a Xubuntu system. Perhaps this is helpful to you?

petrbouchal commented 4 years ago

Many thanks, can confirm this resolves the issue for me as a well - on a Mac.

frederik-elwert commented 4 years ago

Thank you for the investigation! The proposed fix solves the immediate issue, but I found a series of similar issues after fixing it, e.g. pandoc-quotes.lua:337: attempt to call a nil value (global 'len'). They appeared only when defining my own quot-marks, when using the default, the filter worked. Is there an issue with the imports so some of the functions are not available?

JohnCWood commented 4 years ago

I'm glad to hear that the fix works for other people! As to further problems when using self-defined quotation marks: I don't know. I'm not really that adept with writing lua-filters, I was just lucky with figuring out the other problem. I have been hoping that the developer would respond to this issue.

Maybe someone else has an idea?

frederik-elwert commented 4 years ago

Okay, I found out that there is a version of the filter now included in the somewhat official collection lua-filters. That version does not have the same issues as this one, and it has automatic tests in place to make sure it works under the current pandoc release. So I guess the version in this repo is obsolete now?

JohnCWood commented 4 years ago

Many thanks for finding that! I have also run the version from the lua-filters repo without any of the error messages that were appearing with this version.

odkr commented 4 years ago

Sorry for the radio silence. This repo is not obsolute. It should be in sync with lua-filters. That it isn't is a mistake on my part.