louietan / anki-editor

Emacs minor mode for making Anki cards with Org
700 stars 87 forks source link

How to use a dash as part of a tag? #37

Closed bmansurov closed 5 years ago

bmansurov commented 5 years ago

Adding a tag with a dash creates two tags. For exmaple, "world-capitals" would be cteated as ":world:capitals:". Is there way to create one tag with a dash, like ":world-capitals:"?

bmansurov commented 5 years ago

Never mind. It's a limitation of org-mode.

arbox commented 5 years ago

Yep, you cannot do it, since - is ambiguous, it's used for tag searches and cannot be part of a tag. Use underscores :)

eyeinsky commented 3 years ago

@arbox May I ask if you know whether there is a defined format for tags Anki? (perhaps a list of allowed characters)

arbox commented 3 years ago

@eyeinsky,

I looked in the AnkiEditor's source code a couple of years ago and could find this RE: "^\\([[:alnum:]_@#%]+\\)+$".

But this issue is a compatibility issues of Anki and Org-mode. The Org-mode manual states: "tags are normal words containing letters, numbers, ‘_’, and ‘@’.".

Dashes are not allowed in Org-mode tags since a dash represents the minus sign, the tag negation for tag searches. And AnkiEditor replaces them with dashes effectively breaking a tag into many. I hope I could help you.

eyeinsky commented 3 years ago

@arbox But I guess if only syncing tags in one direction (from org-mode tags to Anki) then it should simply work, right? (as letters, numbers, ‘_’, and ‘@’ are all allowed in Anki)

arbox commented 3 years ago

@eyeinsky , yes, that's true. Simply define compatible tags.