nb icon indicating copy to clipboard operation
nb copied to clipboard

Title and Description mangled when adding bookmarks

Open fred-o opened this issue 2 months ago • 5 comments

When adding a bookmark like this:

nb https://github.com/xwmx/nb

I end up with a mangled Title and Description, where a newline is introduced between each word, and between the first and second letters of each word (see attached file). 20251016130110.bookmark.md

As far as I can tell, this is not restricted to GitHub pages, but happens every time I add a bookmark.

My setup:

❯ nb version
7.22.1
❯ nb env
_ME=nb
_MY_PATH=/etc/profiles/per-user/fredrik/bin/nb
EDITOR=hx
NB_ACE_ENABLED=
NB_ACE_MD_GUTTER=
NB_ACE_RELATIVE_LINE_NUMBERS=
NB_ACE_SOFT_TABS=
NB_ACE_KEYBOARD=
NB_AUDIO_TOOL=
NB_AUTO_SYNC=1
NB_AUTO_SYNC_SECONDS=60
NB_BOOKMARK_CONTENT_CLEANUP_TOOL=
NB_BOOKMARK_CONTENT_CONVERSION_TOOL=
NB_BROWSE_MARKDOWN_READER=markdown+emoji+raw_html+east_asian_line_breaks
NB_BROWSE_SERVER_TOOL=accept
NB_BROWSE_SUPPORT_LINKS=
NB_BROWSER=
NB_COLOR_PRIMARY=69
NB_COLOR_SECONDARY=8
NB_COLOR_THEME=nb
NB_CUSTOM_CSS=
NB_CUSTOM_CSS_URL=
NB_CUSTOM_JAVASCRIPT=
NB_CUSTOM_JAVASCRIPT_URL=
NB_DATA_TOOL=
NB_DEFAULT_EXTENSION=md
NB_DEFAULT_TEMPLATE=
NB_DIR=/home/fredrik/SynologyDrive/Notes
NB_DIRECTORY_TOOL=
NB_EDITOR=hx
NB_ENCRYPTION_TOOL=openssl
NB_FOLDERS_FIRST=
NB_FOOTER=1
NB_GUI_BROWSER=
NB_HEADER=2
NB_IMAGE_TOOL=
NB_INDICATOR_AUDIO=🔉
NB_INDICATOR_BOOKMARK=🔖
NB_INDICATOR_DOCUMENT=📄
NB_INDICATOR_EBOOK=📖
NB_INDICATOR_ENCRYPTED=🔒
NB_INDICATOR_FOLDER=📂
NB_INDICATOR_IMAGE=🌄
NB_INDICATOR_PINNED=📌
NB_INDICATOR_TODO=✔️ 
NB_INDICATOR_TODO_DONE=✅
NB_INDICATOR_VIDEO=📹
NB_LIMIT=15
NB_MATHJAX_ENABLED=
NB_MARKDOWN_TOOL=
NB_NOTEBOOK_PATH=/home/fredrik/SynologyDrive/Notes/home
NB_PINNED_PATTERN=
NB_SERVER_HOST=localhost
NB_SERVER_PORT=6789
NB_USER_AGENT=
NB_SYNTAX_THEME=base16
NBRC_PATH=/home/fredrik/.nbrc
PAGER=less

ack:        
ag:         
bat:        /etc/profiles/per-user/fredrik/bin/bat
code:       
curl:       /run/current-system/sw/bin/curl
emacs:      
git:        /etc/profiles/per-user/fredrik/bin/git
gvim:       
gpg:        /etc/profiles/per-user/fredrik/bin/gpg
highlight:  
less:       /run/current-system/sw/bin/less
lynx:       
macdown:    
mate:       
mvim:       
nano:       /run/current-system/sw/bin/nano
nc:         
ncat:       /run/current-system/sw/bin/nc
nvim:       
openssl:    /etc/profiles/per-user/fredrik/bin/openssl
pandoc:     /etc/profiles/per-user/fredrik/bin/pandoc
pygments:   
readable:   /etc/profiles/per-user/fredrik/bin/readable
rg:         /etc/profiles/per-user/fredrik/bin/rg
subl:       
tig:        /etc/profiles/per-user/fredrik/bin/tig
w3m:        /etc/profiles/per-user/fredrik/bin/w3m
vim:        
bash --version: GNU bash, version 5.3.3(1)-release (x86_64-pc-linux-gnu)
uname -a: Linux finn 6.12.47 #1-NixOS SMP PREEMPT_DYNAMIC Thu Sep 11 15:21:47 UTC 2025 x86_64 GNU/Linux

fred-o avatar Oct 16 '25 11:10 fred-o

Hi @fred-o, thanks for the report. I've looked into this and experimented a bit, but still don't know the cause and I haven't been able to reproduce the issue.

For reference, the bookmark content extraction for title and description involves downloading the page with either Chrome, Chromium, wget, or curl in the _download_from() function, then uses sed to extract the content (it's a little more complicated for <title> tags, but the issue exists with both description and title), then cleans the content up a little with awk, sed, and w3m if it's available. Somewhere in that sequence of operations newlines are being added with your system's configuration. Copilot doesn't have any relevant insights so far. I'll have to keep investigating this.

xwmx avatar Oct 26 '25 23:10 xwmx

Thank you for looking into this. I've been trying to debug a little on my side, and will do more testing.

FWIW, I'm invoking nb from fish rather than bash, but I don't think that should matter.

fred-o avatar Oct 27 '25 21:10 fred-o

If I uninstall w3m, the command works as expected, so it looks like that's where the problem lies.

fred-o avatar Oct 28 '25 12:10 fred-o

@fred-o Thanks for the info. Is this the w3m package you are using?

https://mynixos.com/nixpkgs/package/w3m

xwmx avatar Oct 28 '25 23:10 xwmx

Yeah, it's the standard w3m from nixpkgs-unstable.

❯ w3m --version
w3m version w3m/0.5.5, options lang=en,m17n,image,color,ansi-color,mouse,gpm,menu,cookie,ssl,ssl-verify,external-uri-loader,w3mmailer,nntp,gopher,ipv6,alarm,mark

fred-o avatar Oct 29 '25 07:10 fred-o