No3371 / obsidian-regex-pipeline

An Obsidian plugin that allows users to setup custom regex rules to automatically format notes.
70 stars 8 forks source link

Refusing to process one example in docs #12

Closed aubreyz closed 2 years ago

aubreyz commented 2 years ago

This is a fantastic plugin - thank you so much for writing it

I have one curious anomaly

All my own regexes work fine, and all the other examples work fine, but one example in the docs throws up an error. It is this one. Whatever I do it says "which contains 0 regex replacements" and does nothing at all. I wondered whether one of the characters might be a unicode character that is not what it seems, so retyped it from scratch, but no matter what I do this attempt to pre-pend something to lines (from the docs) does not work

"^(.+)$"->">$1"

aubreyz commented 2 years ago

OK I located the bug - there seems to be some issue if the regex files are created with windows notepad and/or the index./txt file is edited with windows notepad. If that is done then the newly created rules are "found" but do not work (even though the files look ostensibly identical and obsidian is restarted).

Perhaps something to do with line break format in these files?

Creating the identical rule within the inbuilt editor works fine Take a look at the two attached identical looking files in the zip. The one called

prefix a2 -- works fine prefix a -- does not work

The latter was created with windows inbuilt notepad.exe and says it is Windows-1252 The former was created with the inbuilt editor aftre pressing + and says it is ISO-10646-UCS2-BOM-WIN

prefix a.zip

No3371 commented 2 years ago

I opened the files with VSCode and it shows UTF8, UTF16LE, which seems match the result only the first works. Anyway, I'm afraid that my answer would be just make sure it's UTF8. The plugin use read API provided by Obsidian and we have no control over the process.

aubreyz commented 2 years ago

Yes. I think it probably needs a line in the documentation to point this out - because the error report does not immediately lead one to the problem and it took a long time to figure this out. Probably would also be good when the thing flashes up to say what processing has been done, if the number of regexes in the file is zero, it might hint as to a possible cause (is file in UTF-8 format).

Especially because the nature of the plugin is that an external editor is likely to be used.

No3371 commented 2 years ago

As this does not seem common for now, I'll mention this only in the Readme. Thanks for testing this out!