xwmx / nb

CLI and local web plain text note‑taking, bookmarking, and archiving with linking, tagging, filtering, search, Git versioning & syncing, Pandoc conversion, + more, in a single portable script.
https://xwmx.github.io/nb
GNU Affero General Public License v3.0
6.66k stars 188 forks source link

Error when adding bookmark within WSL(1) #9

Closed zsoltika closed 4 years ago

zsoltika commented 4 years ago

Hi,

when I try to add a bookmark I get an error:

╰─➤  nb https://hackurls.com/
Wrong __data_start/_end pair

I'v searched for this message within the repo without finding anything so I figured this might came from an external program, and it's w3m that crashes with this URL (and each and every URL) so it is an external issue.

However how can one configure to have a different CLI browser by default (e.g. elinks)?

Or e.g. pandoc can be used to convert the page directly to markdown like:

pandoc -i $URL -t markdown | wherever_to.md
xwmx commented 4 years ago

Thanks for the heads up! I'm going to check it out on a Windows machine. The preferred terminal browser is not yet configurable.

xwmx commented 4 years ago

I tested it and looked into this a little. I get that error when trying to run w3m on its own in an Ubuntu terminal on Windows.

Currently, nb checks to see whether w3m is available in the environment and, if w3m is, nb uses it to do some extra things like convert HTML entities in page descriptions to their representative characters, and that appears to be where the error occurs. If w3m is broken in WSL even when it's available, it might require an explicit platform check in a few places to exclude use of w3m under WSL. I'm still looking into this...

xwmx commented 4 years ago

I updated nb to skip w3m on WSL 1, so this error should be resolved and if you have lynx installed it will use that automatically now. I also like your idea about converting the HTML to markdown, and that's now the fallback for when neither w3m or lynx is found. If pandoc is also not found, then the page source is displayed in less.

These changes are available as of version 5.5.4. Please re-open the issue if you run into additional problems with this.

Thank you!

zsoltika commented 4 years ago

I also confirm that this workaround fixes it for me too on WSL(1). Thanks for the quick fix!