pelican-plugins / search

Pelican plugin that adds site search capability
47 stars 9 forks source link

expected newline, found an identifier #3

Open ghost opened 2 years ago

ghost commented 2 years ago

Steps up to this point:

After that I got this error.

CRITICAL Exception: Search plugin         __init__.py:550
                    reported Error: expected                        
                    newline, found an identifier at                 
                    line 438 column 11   

Help! I do not understand Python at all, so I don't have any insight into the issue beyond what I have here. :( I am happy to provide additional information if requested (and given a little instruction on how).

justinmayer commented 2 years ago

Stork version 1.3 was just released and is not yet supported. The docs are at least somewhat clear that the supported version is 1.2.x, so you'll need to download and use that version until this plugin has been updated for Stork 1.3 compatibility.

ghost commented 2 years ago

I figure I should re-open this since I have come across the same issue even after getting a compatible version. On a Debian Bullseye machine I built Stork 1.2.1 via Cargo. rustc and Cargo are both version 1.57.0. Stork itself works fine.

Pelican is in a venv with Python 3.9.2, Pelican 4.7.1, and pelican-search 1.0.0 as the only plugin. All changes to my theme and pelicanconf.py are the same as in the original post.

I attempted to build with pelican, and I got a similar error.

[15:33:53] CRITICAL Exception: Search plugin reported       __init__.py:550
                    Error: expected newline, found an                      
                    identifier at line 448 column 11 
justinmayer commented 2 years ago

Hi Alex. I'm sorry to hear that you're having the same problem with Stork 1.2.1. Which theme are you using? This search plugin is still new, and while I've been using it without problems for several months, it hasn't been widely exposed to against a broad range of content, themes, and settings.

The first suggestion I can offer is to invoke Pelican with --debug to see whether there is more context regarding where the error is originating. If you need help interpreting the traceback, you can paste it into https://dpaste.com/ and then share a link to it here.

I also highly recommend that you test with as many "stock" components as possible. For example:

  1. Use pelican-quickstart to generate a fresh project.
  2. Create one new very-simple Markdown article and put it in content/.
  3. Follow the Search plugin install/configuration docs
  4. Try building with --debug

Can you try that and let me know what you discover?

ndeville commented 2 years ago

I have the same issue.

Pelican version: 4.8.0
Python version: 3.8.9 Stork version: 1.5.0

Here are my debug infos, if helpful: https://dpaste.com/35CVJ6H5F

Not sure if relevant, but I noticed in CalledProcessError: Command '['stork', 'build', '--input', '/Users/redacted/search.toml', '--output', '/Users/redacted/redacted.github.io//search-index.st']' returned non-zero exit status 1. that the path to search-index.st has 2 forward slashes instead of 1.

ndeville commented 2 years ago

Problem solved - my bad. Some of my Pelican articles had quotes in their title that weren't escaped, so in search.toml for example:

[[input.files]]
path = "foo/i-like-spam/index.html"
url = "foo/i-like-spam"
title = "I "like" spam"

Escaping the quotes in all the article titles that had them solved the issue (eg title above in Markdown would be I \"like\" spam).

And my search engine is now working :)

Thank you for this plugin! Really easy to implement.

justinmayer commented 2 years ago

@ndeville: I'm glad you were able to resolve the issue.

@oiseaumanifesto: I never got a response to my comments above, so for now I will close this issue.

In the interim, I have updated the README with details for Stork 1.5, which I have successfully tested on multiple sites. I also just released v1.0.1 of this plugin, which resolves an issue with incorrect search result URLs when searching from non-home pages.

justinmayer commented 1 year ago

After having merged #15, I now see a spurious backslash before double-quotation marks in the search result titles. So in my testing, the escaping added in #15 is adding a backslash where there shouldn't be one.

I then locally reverted the escaping logic from #15, and the spurious backslash went away. And I didn't have any trouble with search index generation — the double-quotation marks were already escaped properly inside search.toml when using the "title": page.title method that was in place before the changes introduced in #15. Perhaps the problem reported in this issue was actually a Stork problem that was fixed somewhere between v1.2 and v1.5? 🤷

I'm confused as to what caused the problem reported in this issue, since I can't reproduce it. Until someone can, having already reverted #23, I am inclined to also revert the changes in #15.

Can anyone reliably reproduce the reported problem with Stork v1.5.0 and pelican-search v1.0.1?

cc: @s3lph