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

expected newline, found an identifier #3

Open
2 tasks done
ghost opened this issue Nov 29, 2021 · 7 comments · Fixed by #15
Open
2 tasks done

expected newline, found an identifier #3

ghost opened this issue Nov 29, 2021 · 7 comments · Fixed by #15
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Nov 29, 2021

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

  • OS version and name: FreeBSD 13.0-RELEASE-p4
  • Python version:3.8.12
  • Pelican version: 4.7.1
  • Version of this plugin: 1.0.0

Steps up to this point:

  • I installed Stork as needed for this plugin via Rustup. stork --version reports 1.3.0.
  • I set up a venv with Pelican and generated some posts using the default theme. It all generated okay.
  • I installed pelican-search via pip in the venv
  • I set edited the theme to add the CDN code and add the search box.
  • I added SEARCH_MODE = "output" and SEARCH_HTML_SELECTOR = "main" to the pelicanconf.py file.
  • I called pelican to regenerate the site.

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).

@ghost ghost added the bug Something isn't working label Nov 29, 2021
@justinmayer
Copy link
Contributor

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
Copy link
Author

ghost commented Dec 5, 2021

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
Copy link
Contributor

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?

@justinmayer justinmayer reopened this Dec 7, 2021
@ndeville
Copy link

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
Copy link

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
Copy link
Contributor

@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
Copy link
Contributor

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

@justinmayer justinmayer reopened this Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants