ahrm / sioyek-python-extensions

Python wrapper and simple addons for sioyek PDF viewer
GNU General Public License v3.0
164 stars 7 forks source link

Debugging commands #15

Closed fleimgruber closed 1 year ago

fleimgruber commented 1 year ago

I am trying https://github.com/ahrm/sioyek-python-extensions#-import_annotations after setting the python in prefs_user.config:

python "C:\Users\user\project\.venv\Scripts\python.exe"

as mentioned in https://github.com/ahrm/sioyek-python-extensions/issues/1#issuecomment-1403921159. Now how can I debug this? Running the command : _import_annotations does not seem to have any effect. I can import the sioyek library from CLI alright:

.\.venv\Scripts\python.exe -c "import sioyek.import_annotations"
ahrm commented 1 year ago

You can run the python command manually from the command line:

python -m sioyek.import_annotations "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}"

(after replacing the %{} variables with the correct values), and see if it works.

fleimgruber commented 1 year ago

@ahrm thanks for checking back. I saw changes in the PDF opened in sioyek after running the command.

An observation: It's a two-column paper and the highlight annotation is colored a bright yellow as expected - the contents of the left column up until the highlight annotation are colored in a lighter yellow though which disappears if the highlight annotation is not visible any more, i.e. scrolling it out of the visible range. If this is not a known issue, I will create a separate one and try to reproduce with a minimal PDF.

To the issue at hand: How can I search for annotation contents to check whether the import was successful?

ahrm commented 1 year ago

How can I search for annotation contents to check whether the import was successful?

You can see a list of highlights by pressing gh.

fleimgruber commented 1 year ago

Ok, it seems to work from CLI, but not with _import_annotations from inside sioyek. How to debug _import_annotations further?

Also, only the highlighted text is shown, not the annotation contents (this is what SumatraPDF calls the text that can be associated with a highlight). Do you have an annotated PDF that you could share with which I can test this more?

fleimgruber commented 1 year ago

For reference, I currently run with this prefs_user.config:

python "C:\Users\user\project\.venv\Scripts\python.exe"

new_command _import_annotations python -m sioyek.import_annotations "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}"

edit: It works with

new_command _import_annotations "C:\Users\user\project\.venv\Scripts\python.exe" -m sioyek.import_annotations "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}"
ahrm commented 1 year ago

Also, only the highlighted text is shown, not the annotation contents (this is what SumatraPDF calls the text that can be associated with a highlight)

We don't have that in sioyek.

fleimgruber commented 1 year ago

Also, only the highlighted text is shown, not the annotation contents (this is what SumatraPDF calls the text that can be associated with a highlight)

We don't have that in sioyek.

That's too bad. Do you mean that we don't have that yet or that you don't plan on working on it? How difficult would it be to add this functionality for a new contributor? Would this belong to extensions or sioyek core?

fleimgruber commented 1 year ago

Regarding the observation in https://github.com/ahrm/sioyek-python-extensions/issues/15#issuecomment-1584453023, I could not reproduce the behavior in a two-column article compiled locally with LaTeX, so I suspect the issue is with the PDF with which I tested.

ahrm commented 1 year ago

Do you mean that we don't have that yet or that you don't plan on working on it?

Currently, I don't have any plans to add this feature, this may change in the future though. For now, you could add a bookmark in the same location as the highlight if you want to add some text information.