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

Lzilioli improvements #7

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

lzilioli
Copy link

@lzilioli lzilioli commented Dec 5, 2023

@lzilioli lzilioli mentioned this pull request Dec 5, 2023
@kaffarell
Copy link
Owner

Thanks for the PR! I left you some comments inline...

@lzilioli
Copy link
Author

lzilioli commented Dec 5, 2023

Hi @kaffarell im not seeing comments anywhere (and have no emails about them) can you point me in their direction?

@kaffarell
Copy link
Owner

Hmm weird, try changing to the "Files changed" tab here on github, then you should see them inlined somewhere in the code...

@lzilioli
Copy link
Author

lzilioli commented Dec 5, 2023

@kaffarell i don't see any comments or conversations in that view, apologies if i am missing something.

image

@@ -151,7 +151,7 @@ export default class TesseractOcrPlugin extends Plugin {
private async getTextFromImage(filePath: string): Promise<string> {
let fullPath = (this.app.vault.adapter as FileSystemAdapter).getFullPath(filePath);
let command = this.settings.tesseractPath + 'tesseract';
let commandArgs = [fullPath, '-', '-l', this.settings.tesseractLanguage];
let commandArgs = [`${fullPath.replace(/ /g, '\ ')}`, "-", "-l", this.settings.tesseractLanguage];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to escape the \ here...
Try maybe something more complete like:
replace(/(\s+)/g, '\\$1')

Copy link
Author

@lzilioli lzilioli Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code snippet only escapes the first space in a sequence of many. We need to escape each individual space.

"path/to my file has a     lot.   of spaces".replace(/(\s+)/g, '\\$1')

returns "path/to\\ my\\ file\\ has\\ a\\ lot.\\ of\\ spaces"

Whereas the regex replace in the PR escapes each individual space

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, right, this should work:

"path/to my file has a     lot.   of spaces".replace(/ /g, '\\ ');

Your solution in the PR will just replace the spaces with spaces :)

Copy link
Author

@lzilioli lzilioli Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe we just need the double quotes and no replace then? The code as modified fixed the issue I was seeing. I do see that my string ends up unmodified with the replace, so it seems like double quotes may be all thats needed here

src/main.ts Show resolved Hide resolved
@kaffarell
Copy link
Owner

kaffarell commented Dec 5, 2023

Oops, github now requires me explicitly publish my own review :/
Should be visible now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants