Skip to content
This repository was archived by the owner on Sep 7, 2024. It is now read-only.

Tags handling is not consistent with Buku #173

@LeXofLeviafan

Description

@LeXofLeviafan

Tags handling is explicitly described in Buku manpage:

  • Tag name cannot contain comma (,) as it's always treated as a tag separator (so if you try to add a tag with commas it should be treated as multiple tags).
    • additionally, spaces on both sides of every tag are stripped (though the manpage doesn't seem to state it explicitly)
  • Tags are always saved in lowercase.
  • Tags are always sorted after insertion (also removing duplicates).
    • additionally, empty tags are discarded (though the manpage doesn't seem to state it explicitly)

I imagine all of this is implemented as a single “normalization” operation applied on every tags update. I can also say all tags of the bookmark are affected thus, regardless of how it's being edited. (This behaviour is consistent between CLI, interactive mode, and bukuserver.)

In comparison, the current behaviour of Bukubrow is:

  • When adding multiple tags, the string is treated as a single tag (they're parsed as multiple tags when re-read from DB again, but the DB record still has leading/trailing spaces in tags, as well as empty tags if present).
  • Neither order nor character case of tags is normalized upon editing/saving.
  • The add-tag button is disabled when trying to add an existing tag, but it's still quite trivial to add duplicate tags (e.g. by adding foo,bar,baz then separately foo, bar & baz).

I believe tags handling in Bukubrow should replicate that of buku, be applied to in-editor tags list whenever a add-tag button is clicked (or Enter is pressed when tag input is focused), and the action shouldn't be disabled regardless of field content (i.e. any empty/duplicate tags in the input would be simply eliminated when applying normalization).

Alternatively, there can be a global setting (in extension preferences) to enable/disable this behaviour. It wouldn't take much of an effort to implement since there's only two points of application for it (applying/ignoring add-tag action in editor, and applying/skipping normalization during said action).

And yes, the normalization itself shouldn't take much effort either:

let unique = xs => Array.from(new Set(xs)).sort();
tags = unique( [...tags, ...input.split(',')].map(s => s.toLowerCase().trim()) ).filter(s => s);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions