french-wiktionary-flashcards

Easily create Anki flashcards from Wiktionary data.
Log | Files | Refs | README

commit b390b93e1c86f90c9044323d6a4fa7f59bafc4f0
parent 1a3cba38218d5652be1d8c1d4b165bf980c97831
Author: David Schlachter <t480-debian-git@schlachter.ca>
Date:   Fri,  9 Jan 2026 00:06:43 -0500

Ignore whitespace in lookups and new cards

Diffstat:
Madd.go | 2++
Mui.go | 3++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/add.go b/add.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "net/http" + "strings" tea "github.com/charmbracelet/bubbletea" ) @@ -43,6 +44,7 @@ type options struct { func addCard(c *http.Client, apiURL, deckName, modelName, front, back string) tea.Cmd { return func() tea.Msg { + front = strings.TrimSpace(front) if back == "" { return errMsg(errors.New("definition is blank")) } diff --git a/ui.go b/ui.go @@ -73,8 +73,9 @@ func (m model) Init() tea.Cmd { func lookupWord(db *sql.DB, word string) tea.Cmd { return func() tea.Msg { - var definition string + word = strings.TrimSpace(word) // remove leading / trailing whitespace row := db.QueryRow(`select definition from words where word = ? limit 1`, word) + var definition string err := row.Scan(&definition) if err != nil { if errors.Is(err, sql.ErrNoRows) {